Go Down

Topic: Servo Movement Recording (Data Logging?) (Read 6924 times) previous topic - next topic


 Hello everyone!

 I was wondering if anybody has tried to record servo movents using an arduino. I imagine you would have to incorporate some type of flash memory device ... like an SD card.
 I would like to be able to record the movements of up to 8 servos at once... for maybe 2 minutes max.

  I was looking at RAPU by Brookshire Software .. very expensive @ $300 ... heard it's "buggy at best."

 I know this is very possible with the Arduino. I just need a little help getting started.

P.S.  This would be used for making some cool Halloween animatronics.



May 05, 2008, 06:34 am Last Edit: May 05, 2008, 06:35 am by mem Reason: 1
Your implementation will be dependent on how the servos are controlled. If you use a radio control transmitter then you could monitor the signal from the 'training port' that most 6 or 8 channel transmitter have.  This is a sequence of pulse widths from each of the channels that can be easily measured by the arduino.

Your challenge would then be to decide how to store this information efficiently, and how to play it back. The arduino built in ram is barely sufficient to store a second or so of raw data, although you could compress this by storing only the changes in data. But perhaps the external memory storage you mention is best. The actual raw data rate for 8 servos pulsed is 400 bytes per second using 256 bit resolution.

It sounds like a fun project. Perhaps you could say more about what you want to control and what options you have for controlling the servos you want to record.  


 Thanks for the reply mem. I was thinking about maybe using an RC transmitter ...  but wasn't sure if I could accurately store & then reproduce that many PWM signals with the arduino.

  ... I was thinking more along the lines of using at least 2 arduinos:

Arduino # 1 duties:

1)  Receive analog input from pots (I realize there are only 6 analog input pins)
2)  Spit out serial data to a Pololu Micro Serial Servo Controller

Arduino # 2:

1)  "Listen" in on the serial data that arduino # 1 is spitting out
2)  Write an exact copy of this data to a memory stick
3)  Spit out the same serial data at the same rate it was received (For playback of servos at a later time).
4)  Control something like the Daisy Mp3 player by Make ... to have audio synched to the servo movement.

  The Pololu Micro Serial Servo Controller can use 2 protocols ... 1 is their own and the other is the Mini SSC II by Scott Edwards. I would prefer to use Scott's because it only requires 3 bytes of serial data opposed to Pololu's 5 or 6 byte sequence.

 This would all be used for Halloween animatronic props. I would like to be able to mirror the movements of a human skull at first. Using only 4 servos to begin with:  Jaw, Head Left & Right, Head Up & Down, Head Tilt side to side. Later on if I get all this to work, I would animate the arms and possibly the fingers. Maybe control some pneumatic cylinders, RGB LED's for the eyes ... etc.
  I don't want to have a dedicated PC running for each prop. I would much rather have a few $20 arduinos controlling the show.

 I want to make a "helmet" that I could wear that would provide the potentiometer feedback... that way when the mp3 voice file is playing I can just memorize the words and "lip sing" it all the while moving my head and arms, etc ... probably have another helper that could hit the occasional switch for LED's to light or something.

 I believe this is the way Hollywood makes their film animatronics seem so life like. Ibet it saves a ton of time doing it this way.



May 05, 2008, 03:17 pm Last Edit: May 05, 2008, 03:18 pm by mem Reason: 1
Hi Phil,

That sounds like it would work, although I would think you could do it with a single arduino and the pololu board.

In 'recording' mode
1)  Receive analog input from pots (see below for another option for geting position data)
2)  Spit out serial data to a Pololu Micro Serial Servo Controller  
3)  Write an exact copy of this data to a memory stick  (or store data as binary )

In 'playback' mode
1) read data from memory stick (convert binary to ascii if necessary)
2)  Spit out the same serial data at the same rate it was recorded
3)  Control something like the Daisy Mp3 player by Make ... to have audio synched to the servo movement.

An important design decision is whether to store the data at the sampled rate (50 times per second is typical) or just store data change values and intervals. If you use a memory stick you will have plenty of capacity so it may be easiest just to store every sample for every servo.

Another decision is how you control the servos to get the motions you want to record. Using joysticks may be more convenient than individual pots. If so, cannibalizing a cheap RC transmitter from ebay may be worth looking at. If you do use an RC transmitter, and it has a 'trainer port' then you may want to consider monitoring this to get your servo positions instead of doing multiple analogReads on individual pots.


That would be really great if I could do it with one Arduino.

 I think I would rather save the data at the sampled rate ... less chance of losing anything. If I use a 2GB SD card ... I would think that could store a vast amount of serial data.

 I don't think I will be able to use the RC transmitter pots. I have to work some pots into a helmet that would attach to my head to track my movements.

... What would be seen at the trainer port?



Storing all the data is easier and you would use less than 100k bytes per minute, or half that if 256 byte resolution was enough. Anyway, storage is not a problem if you use an external sd card.

Yes, it sound like an RC  transmitter would not be much help if you will 'record' using a helmet for input. How were you planning to sense helmet motion using pots? Have you considered using something like a wii nunchuck attached to the helmet to get the recordings?


 256 resolution will be sufficient. I've been searching like crazy for an example where someone saved serial data to an SD card, but can't find anything. I did find the hardware for the SD card:


  I'm not sure exactly how I would build the helmet. I did think about the wii nunchuck but would like to keep it simple using some cheap pots.

 I think right now I'll worry about figuring out the data logging part.



May 05, 2008, 06:01 pm Last Edit: May 05, 2008, 06:25 pm by mem Reason: 1
Before finalizing your decision about a memory card, have a thorough search on which technology has the easiest interface support for the arduino. Ideally, I think you want a library that allows you to read and write data as if it was an array of bytes.

Variable length strings are awkward to manage in a file system and if you use fixed length strings, you might as well use fixed length binary data. My suggestion is you have each data 'sample' as a two byte pair, the first is the servo number and the second byte is the servo position where 0 and 255 represent the extremes of movement. To start, it could make things simple if you treated the SD card as a two dimensional array, where one dimension is the servo number (from 1 to 8) and the other dimension is the sequential value of the servo for all the samples you have taken.

Once you figure out how you will do the data logging you may want to look a some of the nunchuck interfaces published. The
video here gives an idea of what can be done and the interfacing of published code is not all that difficult.


  hmm. There aren't any libraries available for writing to flash memory. I wish there were. Maybe I should 1st try to save the data on my PC via Processing.

 I probably will end up going with a Wii nunchuck interface. Looks like I could simply strap it to top of my helmet and it would translate head movements. Still gonna need to figure out the jaw and arm pots.



May 05, 2008, 07:48 pm Last Edit: May 05, 2008, 08:05 pm by mem Reason: 1
Have a look at some of the i2c (aka TWI) interfacing to external flash that has been done on the arduino. A 256k chip http://www.sparkfun.com/commerce/product_info.php?products_id=525 would give you two minutes of recording of six servos.

edit: I just realized that the chip linked is 256k bits, you would need a couple of these: http://ww1.microchip.com/downloads/en/DeviceDoc/21941E.pdf  for two minutes recording at a 50hz frame rate and they are a lot more expensive.

But you could experiment with a lower recorded frame rate. It may be that you only need to store 5 or ten samples every second instead of 50 if your movements are relativly smooth.

Also, I do recall reading somewhere that people have got conventional card memory working with the arduino so don't give up on that either.

You could actually test using Arduino program memory and that would give you quite a few seconds of playback. It would not be too difficult to write a processing sketch that captured your data and created a header file that could later be read by your arduino sketch to create the C statements to define the array in program memory.  

You can also test a second or two of record and playback in ram using just one  or two servos.

The nunchuck has a two axis pot in addition to the xyz accelerometers so you may be able to use that for the jaw and arm.



Gotten anywhere with this? Im trying to do the same thing

Go Up