Author Topic: how to 50$ robort with L293D ?  (Read 1822 times)

0 Members and 1 Guest are viewing this topic.

Offline junkmanTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
how to 50$ robort with L293D ?
« on: March 10, 2011, 06:01:29 AM »
don't know much about programing so need help
i connected vcc 1, vcc 2, enable 1, enable 2 to 5v
                ground to ground
                output 1,2 to left motor and output 3,4 to right motor

can i connect inputs 1,2,3,4 to PD 0,1,2,3 and change program functions of left motor and right motor so it will work?
             

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: how to 50$ robort with L293D ?
« Reply #1 on: March 11, 2011, 06:03:55 PM »
WebbotLib and Project Designer will show you how to do it, along with a wiring diagram, - as well as write the L293 pwm code.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline junkmanTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: how to 50$ robort with L293D ?
« Reply #2 on: March 11, 2011, 10:52:18 PM »
thanks man  just what i needed

Offline junkmanTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: how to 50$ robort with L293D ?
« Reply #3 on: March 24, 2011, 01:10:07 AM »
// Define two light sensors connected to ADC channels 0 and 1
#define sensorLeft ADC_NUMBER_TO_CHANNEL(0)
#define sensorRight ADC_NUMBER_TO_CHANNEL(1)

in the above code to set the sensors to channels 0 and 1. What are channels? how do they relate to i/o pins ? 

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: how to 50$ robort with L293D ?
« Reply #4 on: March 25, 2011, 02:16:09 AM »
ADC channels are just pins that can be selected to supply an external voltage input to the ADC. The term 'channel' is often used with multiplexer inputs, and the ADC inputs of the ATmega are an example of an analogue multiplexer.

In Project Designer you will see pins labeled ADC0 to ADC5. You want to use ADC0 and ADC1 which are pins 23 and 24 respectively.

Offline junkmanTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: how to 50$ robort with L293D ?
« Reply #5 on: March 27, 2011, 11:32:04 PM »
thanks hopslink i get it now

but got new problem. (hope fully the last) my code compiled ok when i use it for a atmega168 but gives an error for atmega8 neeed more space about 4.5kb more .(at my local dealer atmega168 out of stock and cant say when he get more, but he got atmega 8)
is it  not possible to run l293d on a atmega 8 or is my code poorly written and taking unnecessary space ?
i am using webbotlib
code bellow (to make it to 168 just changed the include and lib and hz)
Code: [Select]
#include "sys/atmega8.h"
#include <motorPWM.h>
#include "a2d.h"

// Define two light sensors connected to ADC channels 4 and 5
#define sensorLeft ADC_NUMBER_TO_CHANNEL(5)
#define sensorRight ADC_NUMBER_TO_CHANNEL(4)

// Define two motors
MOTOR left = MAKE_MOTOR_3_PIN(FALSE, D0,D1,D2);
MOTOR right = MAKE_MOTOR_3_PIN(TRUE , D3,D4,D5);

// Create the list - remember to place an & at the
// start of each servo name
MOTOR_LIST motors[] = {&left,&right};

// Create a driver for the list of motors
MOTOR_DRIVER bank1 = MAKE_MOTOR_DRIVER(motors);

//the larger this number, the more likely your robot will drive straight
#define threshold 8

// In my initialising code - pass the list of motors to control
void appInitHardware(void){

// Initialise the motor controller
motorL293Init(&bank1);

// Give each servo a start value of 'stop'
act_setSpeed(&left, 0);
act_setSpeed(&right,0);
}
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
uint8_t lightLeft = a2dConvert8bit(sensorLeft);
uint8_t lightRight = a2dConvert8bit(sensorRight);
if(lightLeft > lightRight && (lightLeft - lightRight) > threshold){

// go left
act_setSpeed(&left,DRIVE_SPEED_MIN);
act_setSpeed(&right,DRIVE_SPEED_MAX);
}else if(lightRight > lightLeft && (lightRight - lightLeft) > threshold){

// go right
act_setSpeed(&left,DRIVE_SPEED_MAX);
act_setSpeed(&right,DRIVE_SPEED_MIN);
}else{

// Go forwards
act_setSpeed(&left,DRIVE_SPEED_MAX);
act_setSpeed(&right,DRIVE_SPEED_MAX);
}
return 20000; // wait for 20ms to stop crazy oscillations
}

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: how to 50$ robort with L293D ?
« Reply #6 on: March 28, 2011, 03:07:51 AM »
Quote
...is it  not possible to run l293d on a atmega 8 or is my code poorly written and taking unnecessary space ?...
It is not that your code is poorly written, or that the ATMega8 won't run a motor driver...

In order to make Webbotlib simple to use while providing complex functionality it has to include 'core' code, and it is this that uses most of the code space in the ATMega8. This core will be virtually the same size for all ATMega IC's so though it consumes most of the code space in an ATMega8 it will be less than half of the '168 code space.

Try using Webbotlib 2.x. It uses some clever work in the background to make the core code smaller so you should be able to fit your code in the ATMega8 (no guarantee though). If this doesn't work then you have to select another Webbotlib supported ATMega, use another library :(, or write your own code to do all the work. :'(   
« Last Edit: March 28, 2011, 04:56:46 AM by hopslink »

Offline junkmanTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: how to 50$ robort with L293D ?
« Reply #7 on: March 31, 2011, 09:09:43 PM »
thanks again hopslink
i think i gona bye a atmega32 and make a new board
it will help me in future to (gona try the pid line following one)

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: how to 50$ robort with L293D ?
« Reply #8 on: April 01, 2011, 12:41:06 PM »
If you can find one then use the ATMega328P (28 pin DIP) it will drop into your current board and gives 32k of program memory.

Its also has more facilities than the older ATMega32 despite the ATMega32 being physically bigger.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here

data_list