After a bit if faffing around with wires and batteries and stuff I realised that there needed to be a ground from the driver to the pi otherwise there was no circuit for the signal to travel around. Secondly I found out the the L298 driver board has an on off button. It's not labelled and I have not seen any mention of it online so I only discovered it by accident when I accidentally pressed it while attaching the ground wire.
It is the white square shaped thing at the bottom of the board:
Once these two things were done the motors ran fine. I ran the test program I had written and it worked perfectly:
import RPi.GPIO as GPIO, sys, threading, time
#use physical pin numbering
GPIO.setmode(GPIO.BOARD)
#pins: 7:motor4, 11:motor3, 13:motor2, 15:motor1.
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
#motor test
GPIO.output(7,GPIO.HIGH)
time.sleep(1)
GPIO.output(7,GPIO.LOW)
time.sleep(1)
GPIO.output(11,GPIO.HIGH)
time.sleep(1)
GPIO.output(11,GPIO.LOW)
time.sleep(1)
GPIO.output(13,GPIO.HIGH)
time.sleep(1)
GPIO.output(13,GPIO.LOW)
time.sleep(1)
GPIO.output(15,GPIO.HIGH)
time.sleep(1)
GPIO.output(15,GPIO.LOW)
time.sleep(1)
GPIO.cleanup()
I decided this was a good point to give some time to the mechanical engineering degree I am studying; mechanics comes easier to me than electronics. Clearly.
On Tuesday I was up at 4.30 am again with another idea that wouldn't go away, I woke up and wrote a quick Matlab program that would do the calculations for me that I need to do for mechanical design unit. It worked first time, the hand calculations I did agreed with it so I was very happy that I had done something that didn't require 10 hours of problem solving.
On reflection, the 10 hours of problem solving I've done on the robot is more a reflection of my understanding of electronics rather than the difficulty of the problem.
No comments:
Post a Comment