implementing servos

2,264 views
Skip to first unread message

Nicholas Quihampton

unread,
Mar 8, 2013, 1:41:49 AM3/8/13
to web...@googlegroups.com
is it possible to add the controls for 3 servo's to the UI

trouch

unread,
Mar 8, 2013, 3:54:16 AM3/8/13
to web...@googlegroups.com
yes it's possible
                // Only for Chrome and Safari, create a slider that pulse out a -45 to +45° angle on GPIO 9
                button
= webiopi().createAngleSlider(9);
                content
.append(button);


On Fri, Mar 8, 2013 at 7:41 AM, Nicholas Quihampton <bra...@bigpond.com> wrote:
is it possible to add the controls for 3 servo's to the UI

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nicholas Quihampton

unread,
Mar 11, 2013, 5:13:48 AM3/11/13
to web...@googlegroups.com
i added that to index.html  and nothing appears on the cambot page

trouch

unread,
Mar 11, 2013, 6:05:26 AM3/11/13
to web...@googlegroups.com
check the js console output


--

Nicholas Quihampton

unread,
Mar 12, 2013, 5:56:49 AM3/12/13
to web...@googlegroups.com
I dont know what you mean by this


On Friday, 8 March 2013 17:41:49 UTC+11, Nicholas Quihampton wrote:

Nicholas Quihampton

unread,
Mar 15, 2013, 3:27:29 AM3/15/13
to web...@googlegroups.com
what is the js console output

trouch

unread,
Mar 15, 2013, 3:16:47 PM3/15/13
to web...@googlegroups.com
javascript console.



--

Nicholas Quihampton

unread,
Mar 16, 2013, 3:56:02 AM3/16/13
to web...@googlegroups.com
i get this when i try to start it



On Friday, 8 March 2013 17:41:49 UTC+11, Nicholas Quihampton wrote:

Nicholas Quihampton

unread,
Mar 20, 2013, 5:03:03 AM3/20/13
to web...@googlegroups.com
i have tyred to change the pin number but i still get the same message


On Friday, 8 March 2013 17:41:49 UTC+11, Nicholas Quihampton wrote:

trouch

unread,
Mar 20, 2013, 6:26:58 AM3/20/13
to web...@googlegroups.com

Nicholas Quihampton

unread,
Apr 6, 2013, 12:46:28 AM4/6/13
to web...@googlegroups.com
thanks, i updated to latest version and it fixed that error that i was getting but the slider still wont appear on the page 


On Friday, 8 March 2013 17:41:49 UTC+11, Nicholas Quihampton wrote:

trouch

unread,
Apr 6, 2013, 4:35:43 AM4/6/13
to web...@googlegroups.com
slider only works with chrome and safari.


--

Vitor Carvalho

unread,
Apr 8, 2013, 2:51:04 PM4/8/13
to web...@googlegroups.com
Hello,

how slider works?

When I change it to +45 for example, what happens in the python side?
It's possible to change the range from -45:+45 to 0:180?

Thanks!

trouch

unread,
Apr 8, 2013, 3:27:35 PM4/8/13
to web...@googlegroups.com
PWM frequency is 50Hz, a pulse each 20ms (period)
Servo angle implementation in webiopi use futaba standard, which is the most used :
0° (neutral) => 1520µs = 1.52ms
with a 400µs / 45° travel
-45° => 1120µs = 1.12ms
+45° => 1920µs = 1.92ms

This come from R/C, where axis can have positive and negative values.

You can override Javascript function :
WebIOPi.prototype.createAngleSlider = function(gpio) {
        var slider = $('<input type="range" min="-45" max="45" step="1">');
        slider.attr("id", "angle"+gpio);
        slider.bind("change", function() {
                w().pulseAngle(gpio, slider.val());
        });
        return slider;
}
actually the server side convert the angle into a pulse duration to make a ratio over the period.
it then uses the pwmWriteRatio function to write a duty-cycle ratio between 0.0 (0%) and 1.0 (100%)

be careful with your servo limit.
you will draw too much current if you go bounces.
it can damage the servo and your power.

you should use w().pulseRatio(...) Javascript function, to make your own slider calibrated for your servo.

Eric.

Vitor Carvalho

unread,
Apr 8, 2013, 4:04:03 PM4/8/13
to web...@googlegroups.com
Hi Eric, thanks for your reply.

I read in the wiki, that pulseAngle waits a angle between -45 and +45, I have to override this function too?

ps.: The servo motor is tremendous, even if I do not move the slider.

I'm using the raspian ocidentallis and in this distribution, you can change the pwm by editing the file
echo '90' > /sys/class/rpi-pwm/pwm0/servo
the servo is stopped this way. It's possible to let the servo stopped with slider?

trouch

unread,
Apr 8, 2013, 5:45:42 PM4/8/13
to web...@googlegroups.com
"tremendous" ?

Vitor Carvalho

unread,
Apr 8, 2013, 6:40:42 PM4/8/13
to web...@googlegroups.com
sorry my english.
the servo it's shaking a lot, even I don't move the slider
Message has been deleted

Daniele Cacciabaudo

unread,
Apr 9, 2013, 6:31:58 PM4/9/13
to web...@googlegroups.com
Hi Eric, this issue happen to me too! The servo shaking even the slides don't move.

trouch

unread,
Apr 10, 2013, 2:13:14 AM4/10/13
to web...@googlegroups.com
see bugtracker


On Wed, Apr 10, 2013 at 12:31 AM, Daniele Cacciabaudo <danieleca...@gmail.com> wrote:
Hi Eric, this issue happen to me too! The servo shaking even the slides don't move.

Daniele Cacciabaudo

unread,
Apr 10, 2013, 3:28:34 PM4/10/13
to web...@googlegroups.com
I try to update the RPIO.PWM as recommended
in the link http://www.raspberrypi.org/phpBB3/viewtopic.php?t=36670&p=315941 (issue 42), but nothing has changed.
Do you have any advice for me?
Thanks in advance

trouch

unread,
Apr 10, 2013, 3:40:19 PM4/10/13
to web...@googlegroups.com
there is nothing to use webiopi with RPIO.PWM out of the box.
you can :
wait for a later webiopi release
or
make a custom script with some macros to call RPIO.PWM functions etc...

there is other discuss on the google group about pwm

Daniele Cacciabaudo

unread,
Apr 10, 2013, 4:37:36 PM4/10/13
to web...@googlegroups.com
thank you very much for your reply. and good continuation with the development of webiopi!! i stay tuned.

Nicholas Quihampton

unread,
Apr 10, 2013, 8:05:34 PM4/10/13
to web...@googlegroups.com
i have tested it with both safari and google chrome and the slider still won't appear in either web browsers 


On Friday, 8 March 2013 17:41:49 UTC+11, Nicholas Quihampton wrote:

Daniele Cacciabaudo

unread,
Apr 13, 2013, 1:18:07 AM4/13/13
to web...@googlegroups.com
Meanwhile , i create a custom script with some macros to call RPIO.PWM functions.
it works very well!
I have attached the files. I hope they can be helpful to other people.

Il giorno mercoledì 10 aprile 2013 22:37:36 UTC+2, Daniele Cacciabaudo ha scritto:
thank you very much for your reply. and good continuation with the development of webiopi!! i stay tuned.
On Wed, Apr 10, 2013 at 9:40 PM, trouch <tro...@trouch.com> wrote:
there is nothing to use webiopi with RPIO.PWM out of the box.
you can :
wait for a later webiopi release
or
make a custom script with some macros to call RPIO.PWM functions etc...

there is other discuss on the google group about pwm
On Wed, Apr 10, 2013 at 9:28 PM, Daniele Cacciabaudo <danieleca...@gmail.com> wrote:
I try to update the RPIO.PWM as recommended
in the link http://www.raspberrypi.org/phpBB3/viewtopic.php?t=36670&p=315941 (issue 42), but nothing has changed.
Do you have any advice for me?
Thanks in advance
On Wed, Apr 10, 2013 at 8:13 AM, trouch <tro...@trouch.com> wrote:
see bugtracker


On Wed, Apr 10, 2013 at 12:31 AM, Daniele Cacciabaudo <danieleca...@gmail.com> wrote:
Hi Eric, this issue happen to me too! The servo shaking even the slides don't move.

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+unsubscribe@googlegroups.com.
rasprover.py
index.html

trouch

unread,
Apr 13, 2013, 6:16:27 AM4/13/13
to web...@googlegroups.com
that's the idea, until I improve PWM natively in webiopi.
2 suggestions :
- use webiopi 0.6 script loading facility and syntax, you'll find a cambot2 folder in examples to start with
- remove GPIO.pulseRatio calls


To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.

Daniele Cacciabaudo

unread,
Apr 13, 2013, 11:31:33 AM4/13/13
to web...@googlegroups.com
Ok, thank you!

Inviato da iPhone

Andrés Sanhueza

unread,
Dec 5, 2013, 11:17:07 AM12/5/13
to web...@googlegroups.com
Hi daniele, thx for uploading those files =) 

But i have a question, once you have added the macros in the rasprover.py (server.addMacro(go_forward)) , how do you call them from javascript? 
i cant see the index.html :( 

thnx!


On Saturday, April 13, 2013 2:18:07 AM UTC-3, Daniele Cacciabaudo wrote:
Meanwhile , i create a custom script with some macros to call RPIO.PWM functions.
it works very well!
I have attached the files. I hope they can be helpful to other people.

Il giorno mercoledì 10 aprile 2013 22:37:36 UTC+2, Daniele Cacciabaudo ha scritto:
thank you very much for your reply. and good continuation with the development of webiopi!! i stay tuned.
On Wed, Apr 10, 2013 at 9:40 PM, trouch <tro...@trouch.com> wrote:
there is nothing to use webiopi with RPIO.PWM out of the box.
you can :
wait for a later webiopi release
or
make a custom script with some macros to call RPIO.PWM functions etc...

there is other discuss on the google group about pwm
On Wed, Apr 10, 2013 at 9:28 PM, Daniele Cacciabaudo <danieleca...@gmail.com> wrote:
I try to update the RPIO.PWM as recommended
in the link http://www.raspberrypi.org/phpBB3/viewtopic.php?t=36670&p=315941 (issue 42), but nothing has changed.
Do you have any advice for me?
Thanks in advance
On Wed, Apr 10, 2013 at 8:13 AM, trouch <tro...@trouch.com> wrote:
see bugtracker


On Wed, Apr 10, 2013 at 12:31 AM, Daniele Cacciabaudo <danieleca...@gmail.com> wrote:
Hi Eric, this issue happen to me too! The servo shaking even the slides don't move.

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.

trouch

unread,
Dec 5, 2013, 11:22:13 AM12/5/13
to web...@googlegroups.com
server.addMacro is oldshool
you now have python decorators to declare macros in a custom script.


Eric / trouch.

Andrés Sanhueza

unread,
Dec 5, 2013, 11:41:23 AM12/5/13
to web...@googlegroups.com
Thank you ! 

But eric, got another question, in order to move a servo with PWM, i need 20 ms betweeen each Pulse(50hz) (regardless the dutycycle), but the function 
webiopi.pulseRatio(gpio), gives a 100 ms separation betweeen pulses , i know i can modify this with RPIO.GPIO from python (that´s why i asked in the first place), 
but there isnt a simple way in order to change de frequency of the pulses from Webiopi?

thank so much all your work , greetings from chile =)  

trouch

unread,
Dec 5, 2013, 12:40:58 PM12/5/13
to web...@googlegroups.com
WebIOPi PWM implementation uses a 50hz signal

WebIOPi DOES NOT use RPIO.GPIO

Andrés Sanhueza

unread,
Dec 9, 2013, 6:39:32 PM12/9/13
to web...@googlegroups.com
Eric, im measuring CreateAngelSlider(...) with and oscilloscope and it gives a 40ms period between pulses =( , i guess i´ll try to use macros to call RPIO functions

Andrés Sanhueza

unread,
Dec 9, 2013, 6:39:58 PM12/9/13
to web...@googlegroups.com
Thank you for your replies!
Reply all
Reply to author
Forward
0 new messages