dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Help!!!!

Thu Apr 17, 2014 8:36 pm

Hi All, never heard of Raspberry Pi until about an hour ago, an assistant in Maplin told me a bit,
My daughter is in her last year at uni and is onto her final pieces, so I got one of those "can you help Dad" calls

Katie wants to Automate approx 10-20 cocktail umbrellas just to open and close in a sequence or to be pir/pressure activated,
my initial thought was to use small servo's to operate the umbrellas and have some form of transmitter/receiver set-up but then Katie said about Arduino's so i went off to maplins and hey presto i'm now trying to learn quickly about RP and hopefully get some advice and guidance from forum members PLEASE ??

Cheers
Tim

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Help!!!!

Fri Apr 18, 2014 1:49 am

dadcanyouhelp wrote:Hi All, never heard of Raspberry Pi until about an hour ago, an assistant in Maplin told me a bit,
My daughter is in her last year at uni and is onto her final pieces, so I got one of those "can you help Dad" calls

Katie wants to Automate approx 10-20 cocktail umbrellas just to open and close in a sequence or to be pir/pressure activated,
my initial thought was to use small servo's to operate the umbrellas and have some form of transmitter/receiver set-up but then Katie said about Arduino's so i went off to maplins and hey presto i'm now trying to learn quickly about RP and hopefully get some advice and guidance from forum members PLEASE ??

Cheers
Tim
well... with the right hardware and code, the Pi could do it. So could an Arduino. What are you thinking for hardware? Servos can work with the Pi, but there are probably other options that could work too.

Do remember that the Pi's GPIO pins are 3.3v with a max of 16 mA per pin with a max total of 50 mA.

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Fri Apr 18, 2014 6:31 am

Thanks for your reply, I can do standard household wiring and basic electrics but this is all new to me so I need to be starting at the beginning !
Regarding which hardware, this is where I need advice what servos and ones that will work with Pi, I'm more that capable of making linkage from servo to the cocktail umbrellas
Cheers
Tim

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help!!!!

Fri Apr 18, 2014 7:54 am

How big are the umbrellas? :)

I can picture 10 or 20 cocktail umbrellas, but you are going to need 10 or 20 servos to operate them. Probably the smallest RC model servo will be adequate, but you'll need space to tuck them away and then some sort of linkage to the umbrellas.

Here's a handy collection to get you thinking:
http://www.pololu.com/category/23/rc-servos

Hooking them up is easy, but I suggest you get one and play with it first. RC servos usually have three wires. One is power, one is ground, and the other is a position control signal into the servo. Typically the servo takes about 5V, so get a small 5V PSU (4xAA batteries will do). You can power a micro servo from the Pi itself, but since you'll have several you will need a separate, beefier power supply. Hook up the servo power line to the positive line of the battery power pack. Hook up servo ground to Pi ground *and* the negative line of the battery pack. Connect the servo control line to a GPIO pin on the Pi GPIO connector. Done!

Next is software. Google pigpio or servoblaster and see if you can find enough info to get started (there has been a lot written about servos and Pis). If you're stuck, ask for more help.

Next, buy more servos and hook them up in the same way, but using other GPIO lines. You can drive up to 17 servos this way (there are 17 control lines on the GPIO connector). If Katie wants 20 umbrellas you'll need to get creative, so try to curb her enthusiasm. Explain that 16 is a nice computery number, so it would make a reasonable limit...

Finally, write some cool software in Python that does what she wants. Or better still, show her how to use Google to learn about writing software to do what she wants.

Bottom line, your project is do-able, but we must still obey the laws of physics.

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Fri Apr 18, 2014 11:22 am

Thanks for your detailed reply.

The cocktail umbrellas are 12cm wide when open. If 16 is a reasonable limit, we could perhaps do it in clusters of 16 as the space where she'll be showing her work is quite airy and large, so just 16 on their own will be a bit dwarfed!

She's going to concentrate on the software whilst I work on the hardware so it'll be a learning curve for us both!

Cheers
Tim

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help!!!!

Fri Apr 18, 2014 12:00 pm

You can have as many umbrellas as you want! After you've used up all the GPIO pins you need more hardware (although, at $35 a pop, just buying more Pis is probably not a crazy expansion strategy).

Once again, I suggest you try it with one, then go from there. Servos can be bought cheaply from DealExtreme or HobbyKing or a bazillion other places on the internet.

User avatar
Douglas6
Posts: 4874
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Help!!!!

Fri Apr 18, 2014 12:25 pm

When you're ready to scale this up, consider a dedicated PWM controller like this. These would help by offloading the PWM duties, simplify wiring and scale easily. 992 synchronized cocktail umbrellas would be epic.

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Sun Apr 27, 2014 8:52 pm

Hello again!

So me and Katie are sitting with our just setup Raspberry Pi and servo. And looking blankly at each other! What is the first step from here? We have been reading about the pulse width modulation which we understand but don't know how to do. We've never used Linux before and we really are in a state of confusion so if someone could just give us a guide of how to start controlling the servo we would be so grateful!

We have: an advanced solderless breadboard, a 5v servo, and the GPIO Breakout Board.

Help!
Thanks so much for all your previous help- we really are total novices/numpties so bear this in mind!
Tim and Katie.

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Help!!!!

Sun Apr 27, 2014 9:02 pm

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Help!!!!

Sun Apr 27, 2014 9:49 pm

dadcanyouhelp wrote:Hello again!

So me and Katie are sitting with our just setup Raspberry Pi and servo. And looking blankly at each other! What is the first step from here? We have been reading about the pulse width modulation which we understand but don't know how to do. We've never used Linux before and we really are in a state of confusion so if someone could just give us a guide of how to start controlling the servo we would be so grateful!

We have: an advanced solderless breadboard, a 5v servo, and the GPIO Breakout Board.

Help!
Thanks so much for all your previous help- we really are total novices/numpties so bear this in mind!
Tim and Katie.
Have you got a servo model number. I ask because that determines whether you can test the servo using the Pi's power or whether you will need an external power supply.

The servo will have three wires. What colour are they?

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Sun Apr 27, 2014 10:05 pm

Hi, thanks for coming back to us,
the servo is a tower pro sg-5010
wires are brown/red/yellow ,
we do have a external power block that takes 4 x aa batteries.

I've connected the 100mm rainbow cable to the Pi and have just soldered the box header to the pcb
cheers
Tim and Katie

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Help!!!!

Sun Apr 27, 2014 10:13 pm

You really need hardware timed PWM to get the best from servos. I suggest you download pigpio as it'll let you test out your servo from the command line.
Cut & paste

Code: Select all


wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
make install

Connections are brown to battery -ve, red to battery +ve, yellow to a gpio of your choice.

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Sun Apr 27, 2014 10:40 pm

Thanks for the reply.

Downloaded ServoBlaster, I assume this is like PigPio?

We're currently busy trying to attach the server to the gpio, then will attempt to run Servoblaster. Then we will try to put some code in to see if we have some sort of movement? I saw this code on another website:

Code: Select all

[root@alarmpi user]# ./servod

    Board revision:                  2
    Using hardware:                PWM
    Using DMA channel:              14
    Idle timeout:             Disabled
    Number of servos:                8
    Servo cycle time:            20000us
    Pulse increment step size:      10us
    Minimum width value:            50 (500us)
    Maximum width value:           250 (2500us)
    Output levels:              Normal

    Using P1 pins:               7,11,12,13,15,16,18,22
    Using P5 pins:

    Servo mapping:
         0 on P1-7           GPIO-4
         1 on P1-11          GPIO-17
         2 on P1-12          GPIO-18
         3 on P1-13          GPIO-27
         4 on P1-15          GPIO-22
         5 on P1-16          GPIO-23
         6 on P1-18          GPIO-24
         7 on P1-22          GPIO-25
Is that the sort of thing we could try just as an initial experiment?

Cheers guys!

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Help!!!!

Sun Apr 27, 2014 10:54 pm

Yes, you can use servoblaster.

I should have mentioned you must also connect the -ve (ground) of the battery to a Pi ground pin.

You don't need to write any code to test your servo.

For servoblaster, in a terminal window, just issue a command such as

echo 3=120 > /dev/servoblaster

If you are using the gpio known as 3. Check the servoblaster documentation for the relationship between its numbering scheme and the pin numbers.

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Sun Apr 27, 2014 11:10 pm

Stuck on the software now :(

I *think* i've installed servo blaster, and set it to load the kernel whenever the pi is booted. So then I open lxterminal... What exactly do I have to type?! Sudo Python? I'm so sorry I'm asking such stupid questions... this is so embarrassing haha!

also we're using gpio pin 23, is that okay?

Edited to add: When I type in echo 23=120 > /dev/servoblaster, this comes up: bash: echo: write error: invalid argument

Have I not installed it correctly?

Thanks so much.

Katie.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help!!!!

Mon Apr 28, 2014 6:33 am

The syntax is servo number=position,

So, you are using servo number 5, I think, so try this:

echo 5=120 > /dev/servoblaster

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Mon Apr 28, 2014 6:53 pm

Thanks for that; the above command worked a couple of times, then the servo appeared to jam?

Edited to add: it seems to work once then not again, and I can feel resistance in the servo. Any idea where we're join wrong?

we have the servo wires
red 5v
brown gnd
yellow gpio23

i also notice that sometimes when i attach the servo red positive to the 5v pi supply it causes the pi to crash ??
why is this happening
again thank for all your help and patience
tim and Katie

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Help!!!!

Mon Apr 28, 2014 7:07 pm

The Pi can't supply a great deal of power through the microUSB socket. The servo you are using is quite power hungry and could easily take more power than the Pi can supply. The Pi will be starved of power for the CPU and will die. Power the servo from an external power source.

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Help!!!!

Mon Apr 28, 2014 7:11 pm

dadcanyouhelp wrote: ...
it seems to work once then not again, and I can feel resistance in the servo.
...
Once the servo reaches the commanded position it will stay there until it's told to move. Try a different value in the echo command, values from 100 to 200 should be safe.

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Mon Apr 28, 2014 7:35 pm

Once again a massive help Joan!

Undertand why it wasn't moving now! The only thing is, we feel like there's resistance when its hooked up to the pi, whereas when its not got any power, the servo can be turned by hand? Is this normal? Just wanting to check. Dad thinks the fact that it feels like it's being "held" in position is wasting power?

As for writing a pattern or sequence of movements, is it simple a case of writing a list of echo commands with varying values between 50 and 200? I'm guessing there's a better way...

Katie :)

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Help!!!!

Mon Apr 28, 2014 7:58 pm

dadcanyouhelp wrote: ...
The only thing is, we feel like there's resistance when its hooked up to the pi, whereas when its not got any power, the servo can be turned by hand? Is this normal? Just wanting to check. Dad thinks the fact that it feels like it's being "held" in position is wasting power?
As for writing a pattern or sequence of movements, is it simple a case of writing a list of echo commands with varying values between 50 and 200? I'm guessing there's a better way...
...
When a servo is powered and is receiving pulses it will stay in the commanded position against any attempt to move. Servos are used to control things like model aircraft flaps and rudders. You wouldn't be happy if you asked for a steep climb but the servo gave up when the wind blew.

You could use a bash script for your initial tests. It would be quite natural to use a language like Python if you need to interact with button presses and such like.

In bash you'd do something along the following lines

Code: Select all

#!/bin/bash
#servo-test
for ((p=100; p<200; p+=10))
do
   echo "goto $p"
   echo 5=$p >/dev/servoblaster
   sleep 0.5
done
chmod +s servo-test
./servo-test

boyoh
Posts: 1474
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Help!!!!

Mon Apr 28, 2014 9:28 pm

dadcanyouhelp wrote:Hi All, never heard of Raspberry Pi until about an hour ago, an assistant in Maplin told me a bit,
My daughter is in her last year at uni and is onto her final pieces, so I got one of those "can you help Dad" calls

Katie wants to Automate approx 10-20 cocktail umbrellas just to open and close in a sequence or to be pir/pressure activated,
my initial thought was to use small servo's to operate the umbrellas and have some form of transmitter/receiver set-up but then Katie said about Arduino's so i went off to maplins and hey presto i'm now trying to learn quickly about RP and hopefully get some advice and guidance from forum members PLEASE ??

Cheers
Tim
You are very ambitious with your first Pi project
You said you understand domestic electrics
I think you will find the electronics you will be involved
With on this project will be more complicated.
The hardware will have to be designed first to your
Doughters idea, Then she will designed the
Program to interface the hardware with the Pi
I hope you can buy the hardware ready made
You will get a lot of ideas on this forum
but picking the right one will be the problem

I wish you luck with the project

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

dadcanyouhelp
Posts: 11
Joined: Thu Apr 17, 2014 7:54 pm

Re: Help!!!!

Mon Apr 28, 2014 10:11 pm

Hi Joan,
Thanks once again for your reply, we wouldn't have got this far without your help
servo is working fine and we understand the way is works, all is mechanically making sense, just got to sort the coding now !!! we tried copying and pasting the bash code and nothing happened, is there a more simplified version ?
we've done the ms down to 90 and up to 210 is the "chmod +s servo-test" part of the coding
i know we must sound pretty dumb, but honestly we've never done anything like this before,
regards
Katie and Tim

...
[/quote]
When a servo is powered and is receiving pulses it will stay in the commanded position against any attempt to move. Servos are used to control things like model aircraft flaps and rudders. You wouldn't be happy if you asked for a steep climb but the servo gave up when the wind blew.

You could use a bash script for your initial tests. It would be quite natural to use a language like Python if you need to interact with button presses and such like.

In bash you'd do something along the following lines

Code: Select all

#!/bin/bash
#servo-test
for ((p=100; p<200; p+=10))
do
   echo "goto $p"
   echo 5=$p >/dev/servoblaster
   sleep 0.5
done
chmod +s servo-test
./servo-test[/quote]

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Help!!!!

Mon Apr 28, 2014 10:21 pm

The stuff I put in the

Code: Select all

 
blocks is a bash script. You need to create a file (say called servo-test) and enter that text. You then tell Linux it is a program by using

chmod +x servo-test

That command sets the executable bit for file servo-test. You then run the file using

./servo-test

in the directory containing the file.

Simplest way to create the file is probably

nano servo-test

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Help!!!!

Mon Apr 28, 2014 11:41 pm

dadcanyouhelp wrote: Undertand why it wasn't moving now! The only thing is, we feel like there's resistance when its hooked up to the pi, whereas when its not got any power, the servo can be turned by hand? Is this normal? Just wanting to check. Dad thinks the fact that it feels like it's being "held" in position is wasting power?
This is exactly what is happening, as Joan said. It is using power to maintain its position, but if the load on the motor is small (like, say, a cocktail umbrella) then very little power will be used to hold the position. I think servoblaster will allow you to write a 0 to the servo output, which will turn it off and allow the servo to be moved again by hand. Again, since you have a small load, once the servo has reached its commanded position it's not going to move away from that position by itself.
As for writing a pattern or sequence of movements, is it simple a case of writing a list of echo commands with varying values between 50 and 200? I'm guessing there's a better way...

Katie :)
Now that you are an expert on mechatronic art installations (no, really, there's nothing more to it other than wiring up a thousand servos) you have discovered there is no magic, and you have to do all the work yourself. Simply writing a list of echo commands with varying values over time is *exactly* what you will do. The trick is to do it in an efficient way that is easy for you to type in or change without losing your patience.

Here's one suggestion. Picture a player-piano with a paper roll with holes in it to play a tune. Over time, the paper roll passes over pins that drive the piano keys. The holes make a sound. No hole=no sound. You could do something similar. Have a text file where each line represents a unit of time, say 0.2 seconds, so 5 lines is one second. On each line have 16 columns. In each column, enter the desired position of each servo at that time. Now write a program (in Python, of course) that opens the file, reads a line, extracts 16 numbers, writes 16 control values to servoblaster (using echo, or some other method), waits 0.2s and then reads the next line.

That would Just Work.

There are probably a hundred other ways to do this, and I may do a bit of googling for alternative for you, since this project is interesting. Basically, if you want the motors to move to a series of positions over time, you have to make something that sends the appropriate position values at the appropriate time.

Return to “Beginners”