Tags

, , , ,

Chinese New Year holidays were over and the FYP timeline is getting tighter. Unfortunately the 3D printer is still under maintenance. I hope the vendor will get back to the lab personnel soon.

Chinese New Year was fun but packed with other stuffs as well. Engineer and Society seemed fun at the start because I used to enjoy History lessons. But too much interesting historical stories are not appropriate for my final semester 😦 Did our presentation on Tuesday but we are still required to do some amendments to our slides. Still doing it now. Schneider competition deadline is drawing really near and everyday I am receiving notification in the inbox to submit our idea soon. Will settle it by tomorrow!

Back to FYP, sometimes i get stressed up when there are a lot of unknown problems during the configuration process and I hardly find any solution on the internet because the amount of Raspberry Pi + Gertboard user facing such problem is too little. So I could only troubleshoot by trial and error or keep on redoing the procedure stated in the tutorial or try a different set of instructions.

Anyhow, it is an invaluable process that is worth going through. 🙂 Somehow those stresses keep me going and work harder until I get there.

Anyway I tested the mini servo (TowerPro) with Raspberry Pi. Connected up the servo to the GPIO pins.

Servo connections

Servo connections

Raspberry Pi GPIO connection

Raspberry Pi GPIO connection

Created new python files to test the servo as follow:

2014-02-06 11.02.14

Turn the servo to 0, -180, 180 degree.

Turn the servo to 0, -180, 180 degree.


Code:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(7,GPIO.OUT)

p = GPIO.PWM(7,50)
p.start(7.5)

try:
	while True:
		p.ChangeDutyCycle(7.5)
		time.sleep(1)
		p.ChangeDutyCycle(12.5)
		time.sleep(1)
		p.ChangeDutyCycle(2.5)
		time.sleep(1)

except KeyboardInterrupt:
	p.stop()

	GPIO.cleanup()

Raspberry Pi could not provide a very accurate servo position as observed from the test. Therefore Arduino would do a better job. But I do not have the R-Pi to Arduino interface except the Gertboard. Gertboard has the ATMega chip as well. Gordon project website provided some guidelines to setup and configure Arduino IDE on Raspberry Pi and to initialize the chip on Gertboard.

Wires connection for avrsetup

Wires connection for avrsetup

Arduino IDE on Raspberry Pi

Arduino IDE on Raspberry Pi

I was able to start the Arduino IDE on Raspberry Pi but there are some errors during the uploading process:

Upload error

Upload error

I tried to reset the chip by shorting the RESET wire to 0V [** TRY AGAIN**] and redo the configuration. If all fail, I would need to rewrite the RPi Image. Backup is troublesome and it takes too large a space on my laptop! 😦

UPDATE: It is solved now: ATmega works for Gertboard and Raspberry Pi! Yay!

Advertisements