So grossely, I am doing a line following robot, if I use PWM, then the sensors are not working. Also, I only have two channel to use PWM, so only two motors can use HPWM on one chip. right?
k
So grossely, I am doing a line following robot, if I use PWM, then the sensors are not working. Also, I only have two channel to use PWM, so only two motors can use HPWM on one chip. right?
k
HI,
I am using an H-bridge L293. It seems that there are thre wires per motor for control. 1 for neg. , 1 for pos. and one for the HPWM. The PWM is put on the CCP1, while the other do not matter, as long as they are configured as 1 or 0 right ? well thats what I concluded from what I read. Is there any reason why this code would not work ? I am not getting any output
if right > left Then
temp =right-left
temp= temp * 254
temp= temp/right
PORTC.4=0
PORTC.5=1
HPWM 1,255-temp,1000
HPWM 2,255,1000
Else
temp =left-right
temp= temp * 254
temp= temp/left
PORTC.4=1
PORTC.5=0
HPWM 2,255-temp,1000
HPWM 1,255,1000
Endif
To be more precise, the circuit seems to wok without the motor connected. when i conencted the motor, then the LCD screens shows very low numbers, and the motor might turn just for 1-2 seconds, otherwise it makes a noise, I guess thats my 2000hz
Just one time the motor turned on and changes direction 3 times very quickly.
Should my power supply for the L293 be different then for the pic ?
k
last code still not working
Again i hear a buzz, and sometime the motor turns a little.
Also on the oscilloscope, sometime he output is sitting at zero, or when its oscillating, it looks like its going from -4 to 1volt
if right > left Then
temp =right-left
temp= temp * 254
temp= temp/right
PORTC.4=0
PORTC.5=1
HPWM 1,255-temp,2000
HPWM 2,255,2000
Endif
if left >= right then
temp =left-right
temp= temp * 254
temp= temp/left
PORTC.6=0
PORTC.7=1
HPWM 2,255-temp,2000
HPWM 1,255,2000
Endif
lerameur,
Why don't you create an excel sheet and see all numbers?
Have all possible right and left values in a row, and do the formula, put the result in another row.
Then you can see how the numbers behave, from a possible minimum value to a possible maximum value.
-------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
It's usualy a good pratice to split your PSU lines. You could use one regulator/line.Should my power supply for the L293 be different then for the pic ?
Also, when dealing with POWER, you should split your GND lines (analog, Digital, PowerDevices) then tie them at them at a single point.
It's also good practice to isolate POWER from Logic. OPTO couplers come handy in those case.
Be sure ALL psu line are well filtered and noise free.
Another things... be sure you Motor don't need much current than regulator can give.
O.K, could you provide more details, wich motor model you use and post your schematic here.last code still not working
Again i hear a buzz, and sometime the motor turns a little.
Also on the oscilloscope, sometime he output is sitting at zero, or when its oscillating, it looks like its going from -4 to 1volt
Personnally i hate guessing. I'm sure we could find the solution faster if you posted the whole thing on your first post.
Please for the next(s) time(s) give us all you have. A schematic is often a MUST. If you have a board layout too.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks