I have it working using the python library and running the example.py .
Although this is a good start I want to integrate the shield into a project that is web based and uses cgi files to control the motors. The cgi files contain individual GPIO calls to 4 GPIO pins to control the motors. The command for forward is
I would also like to control the motor driver directly without the library by writing to the GPIO pins directly. I thought this code may work but so far now action.
Rather than rewriting all the web base code can you tell me how to achieve my goal as I am going around in circles
I will most appreciate some help on this.
import RPi.GPIO as GPIO
GPIO.setup(18,GPIO.OUT) // GPIO24 M1DIR
GPIO.setup(22,GPIO.OUT) // GPIO25 M2DIR
GPIO.setup(32,GPIO.OUT) // GPIO12 M1PWM
GPIO.setup(33,GPIO.OUT) // GPIO13 M2PWM
# by selection True and False I should be able to turn on and off the motors
Yes, by default forum users should be getting email notifications when their posts get replies. You might try checking your spam folder or white list "firstname.lastname@example.org", which is the address the forum notifications come from.
You should be able to run man gpio on your Raspberry Pi to see a list of options for the gpio utility. It looks like you can use the mode subcommand to change the pin to PWM mode, and then use pwm to set the duty cycle. If that works, you should also try using pwmr to get a PWM frequency of 20 kHz. You might find this video useful, too.
Can you describe how your code is not working? Can you verify that you are actually running your code in /etc/rc.local after making your edits? (Note that you will probably have to reboot.) Also, do you have access to an oscilloscope?
Every time I change the code in rc.local I do reboot
First I run the non pwm versions of the cgi files and all is fine. The motors spin. I have a number of cgi files for forward backward etc and all work as desired
when I change the code in rc.local and in the cgi files and run the programs all I get is a very slight click. but no spinning. May be I need to also configure some other aspect like the frequency
hope this helps
So long as your connections have remained the same, it does sound like there is an issue with generating PWM signals. I recommend using an oscilloscope to look at the output of those PWM pins to see what is happening there.