Tuesday, 3 November 2015

Finally Moving!

I woke up early (4.30am) on Sunday as I had an idea and it wouldn't go away.  Usually a line sensor will give a combination of on off readings from 3 sensors.  I was wondering how easy it would be to get the outside sensors to measure what proportion of the central IF signal was being bounced back; essentially trying to get some crosstalk but put it to use. If setup right then these readings could be used to set the pwm for the motors; the benefit of this would be smoother direction changes and a greater range of direction change.  I have no idea if this would work or how I would do it which seems to be a regular occurrence for this project.  There was also the small matter of my chassis still not actually moving.

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:


So if you're working with an L298N driver board and it doesnt work, check its grounded to the pi as well as the power supply and make sure the on/off button is on.

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