Log in

View Full Version : What is the best way to make forward reverse



guanerrr
- 10th April 2006, 17:19
Hi,

I'm currently developing a robot powered by two motors. I connect the motors to a driver to pin c1 and c2 (for forward) and c3 and c4 (for reverse) of PIC 16F877A. I try move left and right. When I move left, I need to make left move reverse and right motor forward. How I can do that using HPWM or PWM? I found that HPWM only support forward because it only has 2 channel.

<code>
hpwm 1, 100, 1000
hpwm 2, 100, 1000
</code>

When I try using PWM, only the last line is executed.
<code>
pwm portc.1, 100, 100 'forward right
pwm portc.4, 100, 100 'reverse left
</code>

why only last line is executed?
What is the best way to make forward reverse using hpwm or pwm. TQ

picster
- 10th April 2006, 17:59
In most cases, you use the PWM only to supply the speed of the motor, not the direction. If you use something like a L298 dual H-bridge to drive your motors and look after polarity reversal, you're all set.

------------Picster------------

guanerrr
- 11th April 2006, 04:21
Actually I already used that driver. I told in the first post of this thread that I connect to the motors through a driver to the PIC port c1, c2, c3 and c4. I just need to progam forward reverse using hpwm or pwm.

Acetronics2
- 11th April 2006, 09:26
Hi, guanerr ...

Just have a look to new PICs with the Enhanceded PWM module ...

they can drive by soft all types of output bridges !!! reverse is also here !!!

see 16F 684 i.e.

Alain

guanerrr
- 11th April 2006, 17:01
But I already installed with 16F877A. I don't wanna waste my time and money. I think there must be a solution.