[PD] pd/arduino pwm > servo motor

Martin Peach martin.peach at sympatico.ca
Fri Oct 20 06:59:28 CEST 2006

tim wrote:
> I have a servo motor which is to be driven by pduino / Arduino.
> The following firmware directly uploaded to the arduino (near bottom 
> of page):
> http://itp.nyu.edu/physcomp/Labs/Servo
> runs well.
There you have a timing loop running on the arduino.
> With some modifications the motor moves between 2 positions smoothly 
> enough.
> However, trying the same from pd using the pduino (fermata) firmware 
> and the arduino help pd patch, it's quite a different story.
> The pulse-train needed for the PWM control of the servo motor seems 
> too irregular (due to pd/comport timing?) such that the motor is not 
> positioned cleanly but jumps around. (at least, that's my interpretation)
In that case you send on/off messages from pd to the arduino telling it 
to switch pins on and off.
> I tried both sending PWM from ports 9,10 or 11 (the Amtel-built-in 
> pwm) and generating some software pwm on other digital out ports.
I don't think the arduino implements hardware pwm yet, so it doesn't 
matter which pin you use.
> Is there a way to get rid of this jitter?
The way is to implement pwm on the arduino itself. There are two ways to 
do this: software and hardware. The Servo firmware uses software to 
set/reset the pins in a timing loop. But it isn't doing anything else. 
The pduino has to do analog conversions and send data as well, so unless 
interrupts are used it would be jittery too at a finer level.
The Atmel microcontroller itself has 3 pwm pins that can run 
independently of the software once they are set up, but I don't think 
anyone has implemented that yet. If you look at the firmata code it does 
nothing when either mode of pwm is requested. I have translated the 
firmata code to PIC16F767 and intend to implement software pwm for 
servos soon. I don't know when it's going to happen with firmata for the 
actual arduino.
There is no way to get around the jitter in the comport because it has 
to operate in between the audio block processing time slots in pd.
I think there need to be pduino commands to move stepper motors too, 
because there are jitter issues there as well.

More information about the Pd-list mailing list