|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 12, 2015 4:16 pm |
|
|
Quote: |
The problem seems to be the motor control and I'm getting 3v from each
of the four motor outputs into the h bridge.
|
Ok, let's look at your schematic and at the L293D data sheet.
On the right side of your schematic, at the top, you appear to have
a 7805 regulator, with 9v as the input voltage. It puts out +5v, which
you have connected to Vcc1 and Vcc2 on the L293D.
The L293D data sheet shows that Vcc1 is the logic power supply voltage
and Vcc2 is the motor controller voltage. You are using +5v for both.
http://www.ti.com/lit/ds/symlink/l293.pdf
In the L293D data sheet, look at page 5, in the 2nd block titled:
Quote: | Electrical characteristics, VCC1 = 5 V, VCC2 = 24 V, TA = 25°C |
Look at the specifications for Voh. The minimum output voltage on
the motor driver pins (1Y,2Y,3Y,4Y) is Vcc2 - 1.8v, and the typical output
voltage is Vcc2 - 1.4v.
This means that with +5v connected to Vcc2 as the motor power supply,
your motor driver pins will be between 3.2v and 3.6v. Your complaint
is that you only see 3.3v, but according to the data sheet, that's exactly
what you should see.
If you want more voltage on the motor driver pins, then you need to
increase the voltage on pin Vcc2 (but not on Vcc1, leave it at +5v).
Also make sure that you have a strong power supply for Vcc2 that can
deliver enough current to run your motors, while maintaining the desired
motor driver voltage. |
|
|
Jammie1000000
Joined: 06 Nov 2015 Posts: 8
|
Motor Control Code |
Posted: Thu Nov 12, 2015 4:21 pm |
|
|
I am happy with my setup. But I am always getting 3.3V into the four H Bridge inputs all the time. Obviously, I only want 1 or 2 inputs to be a high voltage while the rest are low to control the two motors. The 3.3V itself is enough to close the H bridge and turn a motor on, but obviously with all four closed, it won't work. Hence why I think there is a problem with the code, not the hardware. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 12, 2015 4:33 pm |
|
|
Post your latest motor control program so we can look at it, while also
looking at your schematic. |
|
|
Jammie1000000
Joined: 06 Nov 2015 Posts: 8
|
Motor control code |
Posted: Thu Nov 12, 2015 5:42 pm |
|
|
The code is still the same as on the previous page. |
|
|
wangine
Joined: 07 Jul 2009 Posts: 98 Location: Curtea de Arges, Romania
|
Re: Motor control code |
Posted: Thu Nov 12, 2015 6:06 pm |
|
|
Jammie1000000 wrote: | The code is still the same as on the previous page. |
You just didn't understand what PCM_p say. Like i say don't take more than 20 min, to start over. I made you a proteus schematic to see how should look the connection on your bridge driver L293D, anyway take less than 20 min, can download from here, i upload now. http://www.filedropper.com/testbou
In time when i complie your code i found some issues.
1: Remove the
Code: | wait_for_power_on(); |
in the while loop, better option is to enable a ext_int on pin C0 and put there that function, or simply put in main before while() loop.
2: Your adc don't work on all 4 channels. I didn't stay to see why, i just notice your code work with first motor, but don't work with second.
3: The Code: | wait_for_power_on(); |
function made your Pic to run once and wait again for power switch, if its already pushed it will stay in while loop forever waiting, then its completely wrong.
Correct your schematic and post the next issue. |
|
|
wangine
Joined: 07 Jul 2009 Posts: 98 Location: Curtea de Arges, Romania
|
|
Posted: Thu Nov 12, 2015 6:25 pm |
|
|
To long to edit:
Now your code working , i will post just main part , the rest is identical like you post in page 1 of topic, just need to look in pdf of pic to see what is minimum time for ADC conversion, i increase to 20ms, and now working like you want, but...... if the project is for your school, the code don't follow your flowchart posted earlier.
Code: | void main()
{
int left_sensor;
int right_sensor;
int front_sensor;
int rear_sensor; //define sensor variables
setup_adc_ports(All_Analog); //set up ADC
setup_adc(ADC_CLOCK_DIV_32);
wait_for_power_on(); //wait for power switch to be turned on
delay_ms(500);
output_high(WHITE_LED_FRONT); //switch on LED's for line sensors
output_high(WHITE_LED_REAR);
while(true)
{
set_adc_channel(6); //set up left sensor
delay_ms(20);
left_sensor = read_adc();
set_adc_channel(5); //set up right sensor
delay_ms(20);
right_sensor = read_adc();
set_adc_channel(7); //set up front sensor
delay_ms(20);
front_sensor = read_adc();
set_adc_channel(1); //set up rear sensor
delay_ms(20);
rear_sensor = read_adc();
// wait_for_power_on(); //wait for power switch to be turned on
// delay_ms(500);
// output_high(WHITE_LED_FRONT); //switch on LED's for line sensors
// output_high(WHITE_LED_REAR);
if(left_sensor<CUTOFF_IR_LEFT) //Opponent seen on left sensor
if(right_sensor<CUTOFF_IR_RIGHT) //Opponent in front
sensor(1); //move forward
else //opponent on left
sensor(2); //rotate left
else if(right_sensor<CUTOFF_IR_RIGHT) //opponent seen on right side
sensor(3); //rotate right
else if(front_sensor<CUTOFF_LDR_FRONT) //line seen on front LDR
sensor(4); // move backwards
else if(rear_sensor<CUTOFF_LDR_REAR) //line seen on rear LDR
sensor(1); //move forwards
else
sensor(0); //spin
}
} |
also can put POT instead of my BUTTON to simulate like in real. Personally i don't like Proteus but was single way to make you to understand how your code works. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Fri Nov 13, 2015 1:51 am |
|
|
The other thing about the schematic, is the lack of capacitors, on both the PIC, and the regulator. Since the driver is driving the motor, the output of the regulator will over-voltage, when the motor free wheels. Danger.....
The connections to B4 are also unclear. Can't actually read what voltages are on the switch connections. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Nov 13, 2015 2:46 am |
|
|
There are a lot of problems in this project. Some are bugs, some are poor design decisions and there is a general feel of disinterest (for example the unreadable posted schematic).
The fact that all 4 outputs are at 3.3V is strange. Why it is 3.3V was explained by PCM Programmer, but glancing at the code it doesn't make sense that all 4 outputs are active at the same time.
In general: whenever you have a program problem you don't understand, then simplify your program so you can focus at each function individually.
For example, your motor problem: Start with the most simple program to drive 1 motor in a fixed direction, this is only 5 lines of code. When that is confirmed to be working add the second motor and verify again. Then add a few fixed driving sequences, a few seconds each. Continue expanding your program, only adding a new feature when you have confirmed the previous version to work correctly. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|