okissele
Posts: 6
Joined: Tue Mar 12, 2013 11:34 pm

Steering a standard servo with Gertboard

Tue Mar 19, 2013 8:42 am

Hello,
I just started with my PI, made a first steering of the DC motor using as a basis a motor.c program from Gertboard software set. It uses hardware PWM (GPIO 17 and GPIO 18). I would like to add a steering of the standard servo. So I have to use a software PWM and different GPIOs. Does somebody have a ready-to-use code (C or Python) and the description of pins/bridges to be set? I saw one or two videos but it is not simple to reproduce all what is shown.

Thank you in advance.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Steering a standard servo with Gertboard

Tue Mar 19, 2013 10:28 am

The easiest way to have good control over a servo with Gertboard is to use the ATMega along with one of the example sketches like the sweep sketch. That's how I did my original flag waving demo.
Alex Eames RasPi.TV, RasP.iO

okissele
Posts: 6
Joined: Tue Mar 12, 2013 11:34 pm

Re: Steering a standard servo with Gertboard

Tue Mar 19, 2013 11:23 am

Hello,
The IDE I can get from: https://projects.drogon.net/raspberry-pi/gertboard/.
First I need to install Arduino IDE et cet.
Is it what you used?
But the code for the servo itself is not there (so I understand). Could you provide the code and wiring description?
Thanks.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Steering a standard servo with Gertboard

Tue Mar 19, 2013 12:06 pm

If you go through all the procedures in the Gertboard manual (and Drogon's site for the avrsetup and IDE install) you will have learnt enough to do it for yourself. The sweep sketch is one of the example sketches in the IDE.

Once you've got to that point, if you need it, I will help with the wiring. It isn't difficult. But you need to go through the procedures.
Alex Eames RasPi.TV, RasP.iO

emos
Posts: 12
Joined: Sun May 12, 2013 11:44 pm

Re: Steering a standard servo with Gertboard

Sun May 12, 2013 11:51 pm

Yes. But the Sweep sketch states all you need to wire in is Pin 9 which is PB1. :cry: So giving that having to use the gertboard requires more than one wire I am guessing I need to use the BUF as mentioned above.

So that means wire BUF1 to PB1. Set the jumper over the output of B1 and the servo pulse cable(blue) into the input. That does not seem to work . So am I getting that last cable step wrong ?

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Steering a standard servo with Gertboard

Mon May 13, 2013 11:49 am

emos wrote:Yes. But the Sweep sketch states all you need to wire in is Pin 9 which is PB1. :cry: So giving that having to use the gertboard requires more than one wire I am guessing I need to use the BUF as mentioned above.

So that means wire BUF1 to PB1. Set the jumper over the output of B1 and the servo pulse cable(blue) into the input. That does not seem to work . So am I getting that last cable step wrong ?
You need to do PB1 to B1 on J3 and servo pulse to BUF1 near the leds. Jumper B1 set to output.
GND lead of servo to Gertboard GND and 5V servo lead to 5V supply. GND of 5V supply also to Gertboard GND.
Alex Eames RasPi.TV, RasP.iO

emos
Posts: 12
Joined: Sun May 12, 2013 11:44 pm

Re: Steering a standard servo with Gertboard

Mon May 13, 2013 10:25 pm

Thanks that worked. Now making sense of that PB1 is pin 9 as required by the sweep sketch. To go through the Buf 1 [input] to wire PB! to B1 input. I jumper off the output as PB1 will provide the input to Buf 1. I wire the control cable [orange on the servo] to Buf 1. The ground cable from the servo goes in the ground of PB1 and the positive servo cable to the positive battery. I ground the battery cable to the ground on PB1.It does not seem to matter where it is ground I think ?

I connected the servo to a nerf gun much to the annoyance of my wife .. somewhat childish :oops: but I found the brush motor test a bit dull, just moving a motor is not that interesting. I think I'll move onto accepting input from the PI to the atmega chip to "fire" the trigger rather than an endless loop. Thanks for the help with the wiring and raspi.tv

Then maybe a more grown up project ... a PIR sensor, servo and pi camera next.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Steering a standard servo with Gertboard

Tue May 14, 2013 7:17 am

emos wrote:It does not seem to matter where it is ground I think ?
Ultimately the grounds on the Gertboard are all connected to each other and Pi GND. You could use any of the GND or -| pins on the Gertboard and it would still work.
emos wrote: I connected the servo to a nerf gun much to the annoyance of my wife .. somewhat childish :oops: but I found the brush motor test a bit dull, just moving a motor is not that interesting.
They're just test programs after all. Interesting is where you come in once you've seen how each element can be controlled. But glad to see you've got your creativity in full swing already. :lol:
emos wrote:I think I'll move onto accepting input from the PI to the atmega chip to "fire" the trigger rather than an endless loop. Thanks for the help with the wiring and raspi.tv

Then maybe a more grown up project ... a PIR sensor, servo and pi camera next.
You're welcome for the help. Fortunately I have a flag-waving servo permanently wired to my Rev 1 Gertboard "Whackadoodle" demo so it was fairly easy to figure out what you needed to do. There's so many wires on it that I can't bear to dismantle it - and anyway, any further software dev work I do will be done on a Rev2 Gertboard. Having said that though, I did enable Wii accelerometer control of the LEDs yesterday for the Cambridge Jam on Saturday. I always try to add something new. Still not using the ADC and DAC on this rig - but I think I will be before long. Not many available ports left on the GPIO though :D
Alex Eames RasPi.TV, RasP.iO

LinuxCircle
Posts: 26
Joined: Sat May 04, 2013 2:03 am
Contact: Website

Re: Steering a standard servo with Gertboard

Thu Jul 04, 2013 2:56 am

A modified Arduino Sketch that actually works with HS 422 servo, Gertboard and Raspberry Pi:
http://www.linuxcircle.com/?p=640

Fantastic tutorial page! :mrgreen:
www.linuxcircle.com

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Steering a standard servo with Gertboard

Thu Jul 04, 2013 7:34 am

LinuxCircle wrote:A modified Arduino Sketch that actually works with HS 422 servo, Gertboard and Raspberry Pi:
http://www.linuxcircle.com/?p=640

Fantastic tutorial page! :mrgreen:
You would say that - you wrote it. :lol:
Alex Eames RasPi.TV, RasP.iO

Return to “HATs and other add-ons”