[PD] arduino-help.me.please.pd [gadlletas]

Hans-Christoph Steiner hans at eds.org
Mon May 29 01:02:55 CEST 2006


I am pretty sure that the hardware PWM in the Arduino is too fast to  
control a servo.

Do you have the specs for the PWM signal that you need to send to the  
servo?  This actually reminds me, this might be an application of  
[pwm], since servos actually need pretty low frequency PWM signals to  
control them, like 50 Hz or so IIRC.

.hc

On May 28, 2006, at 5:59 PM, nomeparece wrote:

> hi list,
>
> I've been trying to control a servo from within pd using the  
> [arduino] and the [pwm] objects.
>
> my newbeness keeps me from being able to see/make the servos move,  
> i explain what im doing with some comments inside the following  
> patch (below)
>
> im sure the servos are ok, red pin=5v, brown pin=GND, orange pin= 
> (tried in pwm0, pwm1,etc,,), i have tried them with a potentiometer  
> and all is fine.. the board if flashed correctly..not sure what i  
> might be missing.. :/ any help, warmly welcome.
> tchuss!
> /a
>
>
> #N canvas 139 73 1013 660 10;
> #X msg 507 212 open \$1;
> #N canvas 162 133 538 388 serin 0;
> #X obj 120 61 cnv 15 15 15 empty \$0-number-canvas 3 4 8 0 14 -233017
> -1 0;
> #X obj 200 225 s \$0-number-canvas;
> #X obj 60 61 hradio 15 1 0 4 empty empty empty 0 -6 0 8 -225271 -1
> -1 3;
> #X obj 59 147 outlet;
> #X obj 60 13 inlet;
> #X msg 200 202 label \$1;
> #X obj 200 180 makefilename %d;
> #X obj 59 108 int;
> #X connect 2 0 7 0;
> #X connect 4 0 2 0;
> #X connect 5 0 1 0;
> #X connect 6 0 5 0;
> #X connect 7 0 3 0;
> #X connect 7 0 6 0;
> #X coords 0 -1 1 1 76 17 1 60 60;
> #X restore 507 189 pd serin;
> #X text 504 171 serial port #;
> #X text 755 605 released under the GNU GPL;
> #X text 397 595 (C) Copyright 2006 Hans-Christoph Steiner  
> <hans at at.or.at>
> ;
> #X msg 567 212 close;
> #X obj 414 544 print --------------------;
> #X obj 759 355 tgl 15 0 empty empty changes 0 -6 0 8 -262144 -1 -1
> 0 1;
> #X obj 644 95 hradio 15 1 0 14 empty empty empty 0 -6 0 8 -262131 -1
> -1 10;
> #X obj 621 96 tgl 15 0 empty empty empty 0 -6 0 8 -262131 -1 -1 1 1
> ;
> #X obj 640 168 +;
> #X obj 621 142 * 14;
> #X obj 640 189 + 200;
> #X floatatom 646 212 5 0 0 0 - - -;
> #X obj 644 114 t b f;
> #X obj 706 358 tgl 15 0 empty empty all 0 -6 0 8 -262144 -1 -1 0 1
> ;
> #N canvas 100 289 622 341 decode 0;
> #X obj 241 26 inlet;
> #X obj 46 189 & 1;
> #X obj 72 189 & 2;
> #X obj 98 189 & 4;
> #X obj 46 213 tgl 15 0 empty empty 0 4 25 1 12 -262144 -1 -1 0 1;
> #X obj 72 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 2
> ;
> #X obj 98 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 4
> ;
> #X obj 124 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 8;
> #X obj 150 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 16;
> #X obj 182 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 32
> 32;
> #X obj 215 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 64;
> #X obj 248 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 128;
> #X obj 287 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 256;
> #X obj 326 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 512;
> #X obj 365 213 tgl 15 0 empty empty 10 -1 25 1 12 -262144 -1 -1 0 1024
> ;
> #X obj 409 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 2048;
> #X obj 453 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 4096
> 4096;
> #X obj 499 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 4;
> #X obj 124 189 & 8;
> #X obj 150 189 & 16;
> #X obj 182 189 & 32;
> #X obj 215 189 & 64;
> #X obj 248 189 & 128;
> #X obj 287 189 & 256;
> #X obj 326 189 & 512;
> #X obj 365 189 & 1024;
> #X obj 409 189 & 2048;
> #X obj 453 189 & 4096;
> #X obj 499 189 & 8192;
> #X obj 261 273 outlet;
> #X connect 0 0 1 0;
> #X connect 0 0 2 0;
> #X connect 0 0 3 0;
> #X connect 0 0 18 0;
> #X connect 0 0 19 0;
> #X connect 0 0 20 0;
> #X connect 0 0 21 0;
> #X connect 0 0 22 0;
> #X connect 0 0 23 0;
> #X connect 0 0 24 0;
> #X connect 0 0 25 0;
> #X connect 0 0 26 0;
> #X connect 0 0 27 0;
> #X connect 0 0 28 0;
> #X connect 1 0 4 0;
> #X connect 2 0 5 0;
> #X connect 3 0 6 0;
> #X connect 18 0 7 0;
> #X connect 19 0 8 0;
> #X connect 20 0 9 0;
> #X connect 21 0 10 0;
> #X connect 22 0 11 0;
> #X connect 23 0 12 0;
> #X connect 24 0 13 0;
> #X connect 25 0 14 0;
> #X connect 26 0 15 0;
> #X connect 27 0 16 0;
> #X connect 28 0 17 0;
> #X restore 836 553 pd decode buttons;
> #X obj 409 89 hsl 128 15 0 1 0 0 empty empty PWM_control_(0-1) -2 -6
> 1 10 -225271 -1 -1 5900 0;
> #X msg 415 519 bang;
> #X obj 606 340 arduino 3;
> #X floatatom 683 116 5 0 0 0 - - -;
> #X text 753 81 7;
> #X text 648 81 0;
> #X text 794 81 10;
> #X msg 405 173 \$2 \$1;
> #X obj 405 151 pack float symbol;
> #X msg 516 110 PWM2;
> #X msg 480 110 PWM1;
> #X msg 445 110 PWM0;
> #X obj 418 281 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 16383
> 16383;
> #X obj 418 244 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
> 1;
> #X obj 417 382 spigot 0;
> #X obj 467 353 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 1;
> #X obj 417 404 route analog0 analog1 analog2 analog3 analog4 analog5
> ;
> #X obj 765 474 route digital;
> #X obj 838 494 print GARBAGE;
> #X floatatom 781 554 6 0 0 0 - - -;
> #X text 744 122 how many analogIns to enable:;
> #X obj 756 183 tgl 15 1 empty empty empty 0 -6 0 8 -257472 -1 -1 0
> 1;
> #X text 779 182 enable/disable digitalIns;
> #X msg 756 201 digitalIns \$1;
> #X msg 745 156 analogIns \$1;
> #N canvas 162 133 546 396 serin 0;
> #X obj 165 61 cnv 15 15 15 empty \$0-analog-number-canvas 6 4 8 0 14
> -233017 -1 0;
> #X obj 60 61 hradio 15 1 1 7 empty empty empty 0 -6 0 8 -225280 -1
> -1 6;
> #X obj 59 147 outlet;
> #X obj 60 13 inlet;
> #X msg 200 202 label \$1;
> #X obj 200 180 makefilename %d;
> #X obj 59 108 int;
> #X obj 200 225 send \$0-analog-number-canvas;
> #X connect 1 0 6 0;
> #X connect 3 0 1 0;
> #X connect 4 0 7 0;
> #X connect 5 0 4 0;
> #X connect 6 0 2 0;
> #X connect 6 0 5 0;
> #X coords 0 -1 1 1 121 17 1 60 60;
> #X restore 746 136 pd serin;
> #X text 839 81 13;
> #X text 596 67 turn on output mode for each pin (off = input);
> #X obj 718 528 spigot;
> #X obj 751 510 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
> 1;
> #X obj 718 549 print;
> #X msg 732 291 231 \, 20 \, 226 \, 213;
> #X text 434 244 this will flash any pin set to output;
> #N canvas 0 22 473 330 speed 0;
> #X obj 21 41 inlet;
> #X obj 21 62 maxlib/speedlim 100;
> #X obj 21 84 outlet;
> #X obj 82 125 inlet;
> #X obj 82 146 maxlib/speedlim 100;
> #X obj 82 168 outlet;
> #X obj 92 135 inlet;
> #X obj 92 156 maxlib/speedlim 100;
> #X obj 92 178 outlet;
> #X obj 102 145 inlet;
> #X obj 102 166 maxlib/speedlim 100;
> #X obj 102 188 outlet;
> #X obj 112 155 inlet;
> #X obj 112 176 maxlib/speedlim 100;
> #X obj 112 198 outlet;
> #X obj 122 165 inlet;
> #X obj 122 186 maxlib/speedlim 100;
> #X obj 122 208 outlet;
> #X obj 132 175 inlet;
> #X obj 132 196 maxlib/speedlim 100;
> #X obj 132 218 outlet;
> #X connect 0 0 1 0;
> #X connect 1 0 2 0;
> #X connect 3 0 4 0;
> #X connect 4 0 5 0;
> #X connect 6 0 7 0;
> #X connect 7 0 8 0;
> #X connect 9 0 10 0;
> #X connect 10 0 11 0;
> #X connect 12 0 13 0;
> #X connect 13 0 14 0;
> #X connect 15 0 16 0;
> #X connect 16 0 17 0;
> #X connect 18 0 19 0;
> #X connect 19 0 20 0;
> #X restore 417 426 pd speed limiting for displaying values with  
> pegging
> the CPU;
> #N canvas 77 268 462 312 debugging 0;
> #X obj 136 31 inlet;
> #X obj 324 29 inlet;
> #X obj 27 31 inlet;
> #X obj 162 81 spigot;
> #X obj 159 106 select 255;
> #X obj 184 246 print;
> #X obj 184 227 list;
> #X obj 96 80 spigot;
> #X obj 210 201 bang;
> #X obj 96 101 print;
> #X obj 181 138 mapping/tolist;
> #X obj 208 181 change;
> #X obj 208 159 list-abs/list-len;
> #X connect 0 0 7 1;
> #X connect 1 0 3 1;
> #X connect 2 0 7 0;
> #X connect 2 0 3 0;
> #X connect 3 0 4 0;
> #X connect 4 0 10 1;
> #X connect 4 1 10 0;
> #X connect 6 0 5 0;
> #X connect 7 0 9 0;
> #X connect 8 0 6 0;
> #X connect 10 0 6 1;
> #X connect 10 0 12 0;
> #X connect 11 0 8 0;
> #X connect 12 0 11 0;
> #X restore 655 377 pd debugging stuff;
> #X text 627 275 use raw data to save settings more compactly;
> #X floatatom 417 451 5 0 0 0 - - -;
> #X floatatom 476 451 5 0 0 0 - - -;
> #X floatatom 535 451 5 0 0 0 - - -;
> #X floatatom 594 451 5 0 0 0 - - -;
> #X floatatom 653 451 5 0 0 0 - - -;
> #X floatatom 712 451 5 0 0 0 - - -;
> #X obj 502 132 symbol;
> #X obj 417 262 metro 100;
> #X floatatom 416 134 5 0 0 0 - - -;
> #X text -35 23 halo hans \, today i have been trying again to use this
> patch but in a straightfwd way \, or at least following my novice  
> logic
> i havent been able to control the connected to the arduino servo. PIN
> red to 5v PIN brown to GND PIN orange to: i have tried pwm0 \, pwm1
> \, pwm2 on the board and paired with this patch \, then moving the
> slider..but i only see the tx lights blink. i have tried the digital
> outputs turning on the output mode for different pins (PIN orange to
> all 0 to 7 pins on the board and it moves only when its connected to
> 0 (Rx) cause of the little data/electricity that flows from the  
> computer
> to the board adding and moving an hslider \, connected directly to
> the [arduino 3] object and with 0 -1 range-properties makes the tx
> little light in the arduino blink but the servo still doesnt react
> or move. i have used the servo with a potentiometer so i know how to
> connect and feed electricity to it. i see pd tells me: [comport]  
> opened
> serial line device 3 (/dev/tty.usbserial-1B1) im not sure what im  
> doing
> wrong \, must be a dumb little thing. any clue appreciated \, buena
> energia \, alejo;
> #X connect 0 0 19 0;
> #X connect 1 0 0 0;
> #X connect 5 0 19 0;
> #X connect 7 0 51 2;
> #X connect 8 0 14 0;
> #X connect 8 0 20 0;
> #X connect 9 0 11 0;
> #X connect 10 0 12 0;
> #X connect 11 0 10 0;
> #X connect 12 0 13 0;
> #X connect 12 0 19 0;
> #X connect 14 0 11 0;
> #X connect 14 1 10 1;
> #X connect 15 0 51 1;
> #X connect 17 0 25 0;
> #X connect 17 0 61 0;
> #X connect 18 0 6 0;
> #X connect 19 0 31 0;
> #X connect 19 1 51 0;
> #X connect 24 0 19 0;
> #X connect 25 0 24 0;
> #X connect 26 0 59 0;
> #X connect 27 0 59 0;
> #X connect 28 0 59 0;
> #X connect 29 0 19 0;
> #X connect 30 0 60 0;
> #X connect 31 0 33 0;
> #X connect 32 0 31 1;
> #X connect 33 0 50 0;
> #X connect 33 1 50 1;
> #X connect 33 2 50 2;
> #X connect 33 3 50 3;
> #X connect 33 4 50 4;
> #X connect 33 5 50 5;
> #X connect 33 6 50 6;
> #X connect 34 0 16 0;
> #X connect 34 0 36 0;
> #X connect 34 0 45 0;
> #X connect 34 1 35 0;
> #X connect 38 0 40 0;
> #X connect 40 0 19 0;
> #X connect 41 0 19 0;
> #X connect 42 0 41 0;
> #X connect 45 0 47 0;
> #X connect 46 0 45 1;
> #X connect 48 0 19 1;
> #X connect 50 0 53 0;
> #X connect 50 1 54 0;
> #X connect 50 2 55 0;
> #X connect 50 3 56 0;
> #X connect 50 4 57 0;
> #X connect 50 5 58 0;
> #X connect 50 6 34 0;
> #X connect 59 0 25 1;
> #X connect 60 0 29 0;
>
>
>
>
>
>
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/ 
> listinfo/pd-list


________________________________________________________________________ 
____

"[W]e have invented the technology to eliminate scarcity, but we are  
deliberately throwing it away to benefit those who profit from  
scarcity."
                                                      -John Gilmore





More information about the Pd-list mailing list