Hi all, I have a question regarding the breakout module found here:
https://www.bananarobotics.com/shop/How-to-use-the-HG7881-(L9110)-Dual-Channel-Motor-Driver-Module
I have followed the coding sample in the Arduino sketch and converted it to Picaxe BASIC, however, I do not seem to be getting the same results. From what I understand, one of the pins (A-1A or B-1A) is used for speed control using a PWM signal, and the other (A-1B or B-1B) is used for direction using a digital output. In addition, on the reverse direction of the motor, it is stated that an inverted duty cycle must be used, hence the reverse FOR loop. Here is the code I wrote:
What happens with this code is that the motor turns in one direction from slow to fast, but for the reverse cycle, it just stalls, then starts over again once the reverse loop completes. I managed to get it working using the following code:
However I am unsure as to why this works by turning pinC.3 into an input on one cycle, then turning pinc.5 into an input on the reverse cycle. Could anybody kindly explain why the first code, which seems be exactly what was written in the Arduino sketch in the link provided, works. Am I overlooking something in my first code posting? Any help would be appreciated. Thanks in advance.
https://www.bananarobotics.com/shop/How-to-use-the-HG7881-(L9110)-Dual-Channel-Motor-Driver-Module
I have followed the coding sample in the Arduino sketch and converted it to Picaxe BASIC, however, I do not seem to be getting the same results. From what I understand, one of the pins (A-1A or B-1A) is used for speed control using a PWM signal, and the other (A-1B or B-1B) is used for direction using a digital output. In addition, on the reverse direction of the motor, it is stated that an inverted duty cycle must be used, hence the reverse FOR loop. Here is the code I wrote:
Code:
pwmout c.3, 150,100
main:
high c.5
for b0= 255 to 0 step - 1
pwmduty c.3, b0
sertxd("Forward: ",#b0,cr,lf)
next b0
low c.5
for b0= 0 to 255
pwmduty c.3, b0
sertxd("Reverse: ",#b0,cr,lf)
next b0
goto main
Code:
main:
dirsC=%11110111
pwmout c.5, 150,100
for b0= 255 to 0 step -1
pwmduty c.5, b0
sertxd("Forward: ",#b0,cr,lf)
next b0
pwmout c.3, 150,100
pause 100
dirsC=%11011111 ' changing pin 5 to input worked
for b0= 0 to 255
pwmduty c.3, b0
sertxd("Reverse: ",#b0,cr,lf)
next b0
goto main