Controlling servo with Flash

Hello,

I am trying to control my arduino (and connected servo) via Flash AS3. Controlling LEDs with PWM doesn't seem to be a problem but my servo is acting weird. I hooked up the servo at a PWM port and tried to control its position with a slider in Flash. The problem is that the servo moves almost randomly in every direction, and sometimes it has a delay. Also, it seems that the servo only reacts to my values when they are between 70 and 240 (between 180 and 240 it is working the best, but still quite random and not smooth at all).
Also controlling the servo by pure AS3 code (a counter that changes the PWM value) results in the same problem. Does anyone know what could be the cause? The servo works fine when using original Arduino software (standalone).

Cyroq

I hooked up the servo at a PWM port

Bad move. Try using PPM.

Can you tell me more about why this is a bad move? Most of the beginner tutorials say a pwm is good to control a servo (and using Arduino software for programming worked great with PWM ports).
I haven't heard of PPM before, can anybody help me how to set this up? Thanks for the answer!

Most of the beginner tutorials say a pwm is good to control a servo

It's a good way of driving simple DC motors, but not R/C servos.
I'd change my source of tutorials, if I were you.

R/C servos expect a 1-2ms pulse every 20ms (Pulse Position Modulation); a pulse repetition frequency of 50Hz.

Arduino PWM (Pulse Width Modulation) is a 1-100% mark:space ratio at a frequency of nearly 500Hz.

It won't do any good for your power consumption, and may cause heating problem in your servo(s).

Hmm ok that's clear. How can I do this with Arduino/Flash? I am now using the Glue 'program' to translate AS3 to Arduino but there is no PPM option or something like that.

but there is no PPM option or something like that.

You use the servo software library function:

Lefty

Is that a code that uses PPM? The Sweep example on the page was the exact code I used when I programmed Arduino without using Flash. Now is my question, how do I use it within AS3?

Is that a code that uses PPM?

Yes, the Servo library correctly uses PPM to control the servo.

Okay, but how can I use this in AS3? I assume I can't just use the attach() functions etc.
For example, a piece of AS3 where the pins are defined looks like this:

'digitalOut',  // Pin 9   pwmOut or digitalIn or digitalOut

Since I can't set a pin to PPM I am wondering how to do this.

Does anybody know the Glue library for AS3 in Flash? I understand I need to use the Servo Library for Arduino, but how to control this by using Glue?
I hope someone can give me an answer :slight_smile:

as3glue already has an ArduinoWithServo.as class (I believe it's included in the default download). You can learn about it on the as3glue Google code page Hope this helps.

http://code.google.com/p/as3glue/source/browse/trunk/Glue/as3/net/eriksjodin/arduino/ArduinoWithServo.as?spec=svn51&r=51

Hi there,

I am also trying to crontrol a couple of servos with sliders in flash with as3glue. Did you come right eventually?

Would be great if I can see your actionscript. Seem to have hit a wall here.

Thanks

I've hit a wall here as well. Anyone have luck with Flash + AS2/3 Servo control?

Yeah I've managed to figure it out hey, I am using a neat little ui I designed in flash to control the transmitter of a toy rc car. I dont have the files here now, but I will upload a more detailed post when I have a moment.

Ok, please do! I'd love to see how you got the servo working. Did you have to modify the AS3Glue Classes? :smiley:

No not at all, just incorporated them into my own code. Will try upload somthing this evening for you. I also found it quite tricky, are you using serpoxy or tinkerproxy and firmata...

I found these links quite useful...

http://cote.cc/blog/interfacing-flash-and-arduino-from-scratch-part-1

http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication-as3/

I am using serproxy. Everything runs great, except I can't get my servo to have any precision. It jumps around, has deadspots between 0-30 and 180-255 when sending PWM signals. The servo also makes weird noises and gets hot if I dont unplug it once I send PWM signals.

I am using serproxy. Everything runs great, except I can't get my servo to have any precision. It jumps around, has deadspots between 0-30 and 180-255 when sending PWM signals. The servo also makes weird noises and gets hot if I dont unplug it once I send PWM signals.

Servos usually don't use PWM from an arduino, they use PPM generated from the servo library.