Big Trak Project.

Phil2014-07-20 20.14.21

Phil was started as a bit of fun to mess around with robotics . He had two powerful motors and a battery pack included . So one day I hook up a H bridge chip and got him moving . He was sluggish and some needed a kick to get him moving . Seeing all these motor control boards around I decided to upgrade him . I choose the PiRoCon board from 4 Tronix and the upgrades have not stopped since.

Spec`s.

15000mAh dual output battery pack for the Pi

4.5volt AA battery pack for the motors

version B Raspberry Pi

PiRoCon Board

Pi Camera

Creative HD Webcam

HC-SR04 Ultra Sonic Sensor

Pan and Tilt kit , not function as yet

PO18 I2c Dual line display

Original rocket launcher

DS18B20 Temp sensor

Loads of Lego

The first part we decided to get working was the motors using the new board. Following the excellent instructions we had Phil moving forward , backwards , left and right in no time . One problem we found is if we turned Phil with the standard tank method of one wheel going forward and one backwards he would turn to fast . So we tried just having the opposite wheel turn.

So for him to turn left the right wheel goes forward and to turn right the left wheel goes forward. At this stage we were running him on the 3 C batteries for power to the motor and where impressed with the speed however we decided to try 3 AA batteries and we had the same performance . This gave us one great advantage more space to add more goodness. Once the days and days of testing was done. We started writing Phil`s code or OS .

We used functions for forward , backwards , left and right. The function just control two GPIO pins .The board uses 4 four pins for basic motor control but it can handle PWM too. We set the GPIO up as follows .

GPIO.setup(19, GPIO.OUT)
GPIO.setup(21, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(26, GPIO.OUT)

Forward function –

def forwards():

GPIO.output (19, 0)
GPIO.output (21, 1)
GPIO.output (24, 0)
GPIO.output (26, 1)

Backward function –

def backwards():

GPIO.output (19, 1)
GPIO.output (21, 0)
GPIO.output (24, 1)
GPIO.output (26, 0)

As you can see backwards is the opposite of forwards , all we do is send a ON signal to a pin to make that motor go forward or backwards . Each motor has 2 pins, motor 1 – pin 19 and 21 \ motor 2 – pin 24 and 26 . To give you an idea of how to turn right here`s it function –

def right():

GPIO.output (24, 0)
GPIO.output (26, 1)

We have one last control function Stop it sets all the pins to OFF.

We use a while statement to control Phil . Inside the repeating while statement there are several IF statement that are checking if a key was pressed  , if the key is pressed it runs the a function. ie if f is pressed run function forward.

Next we decided to give Phil eyes . We choose a Creative HD Webcam mainly because I has a spare one floating around. The code for this is nothing special we use a program called Motion . It was configured and a simple HTML page written to display the images . There is a 5 – 8 sec delay in viewing the image .

Next was the weapons system . I had the original rocket launcher for Big Trak . It took a lot of head scratching to get this working but after speaking to Leo White he put me on to the right path. On the big trak the rockets are fired by an infra red signal but on the Jr version it is fired by a 5 volt pulse. So after learning this firing the rockets was easy just make a pin go high. There was an issue with this it would fire all four rockets and the program would need to be reloaded to allow us to fire them again. we timed how long the mech took to fire one rocket and it was just under 2 seconds. So we wrote a bit of code to ask to user if they wanted single or multi fire . 2 for single and 10 for multi . The code to fire looks like this .

GPIO_FIRE = 12

GPIO.output(GPIO_FIRE,True) ## Turn on GPIO pin 12 fire the rockets
print ” Fire Fire Fire Fire ”
lcd_test(“Fire Fire Fire”,”attack”,10,0,0)
time.sleep(float(rate))
GPIO.output(GPIO_FIRE,False)

rate comes from the user`s input either 2 or 10 . With this code we can reload while the main program is still running.

Next we added the ultra sonic sensor. The idea behind the sensor is that if Phil gets to close to an object he will stop and move out of the way . This part is still an on going project however he is able to give distance readings . There is a bit we struggled on with this ——-

Comments are closed.