Thursday, April 7, 2011

Servo controller with eeprom and playback

Having already successfully create a simple servo board with eeprom and playback we looked at how to improve on a relatively simple design.

We've decided to use a larger eeprom, Atmel's AT45DB041D is a massive 4Mbit device (512kb) with a simple-to-use SPI interface. There are other eeprom chips we could have used, but we are already familiar with this one, from a previous project, and how it's memory space is laid out and addressed (256-byte pages).

In the original servo controller, we had problems getting the playback to sync up with the onscreen editor - mainly because of the way playback was coded.
In this board, we're going to use the same approach for playback as we did for the parallel servo processing. That is, we're going to keep a timer running and compare it's value to a required value. When the running timer value exceeds the required value, we will perform an action. Because we already have a timer raising an interrupt every millisecond and we monitor for 20ms having passed (when all the servo pins are reset to start their repeating signals) it makes sense to use this interrupt for playback timing too.

Simply put, every time we reset the servo output pins, we'll increase an internal (two-byte) counter. So our counter increases by one every 20ms. Using a two-byte counter, that goes up to 65,535 this means we can create playback animations that are 65535/50 = 1,310 seconds in length (almost 22 minutes).

In eeprom, we store animations as a series of servo commands, written as four-byte instructions:
  • The first two bytes are the "timecode" of when the animation is to play - i.e. the counter number when the next servo needs to move (so at every 20ms or 50hz, to move a servo after 1 second, the counter number will be 50. To move another servo after 3.4 seconds, the counter number will be 3.4*50 = 170, and so on).
  • The next byte is the servo number to move
  • The final byte is the degree of movement required.

During the processing part of the main code loop, we can read four bytes from eeprom and compare the current timecode counter (which is updated on an interrupt) to the required timecode for the next servo. When the current timecode counter value exceeds the servo movement timecode, we move the servo in accordance to the other two bytes. When this is done, we can read another four bytes from eeprom.
In doing this, we can create an animation by listing which servos need to move by how much and after how much time. If two or more servos need to move together, the instructions would actually be carried out sequentially (one after the other) but the delay between them would be so small, as to appear to have been carried out at the same time.



Example data for animation playback:
50,1,90 (after one second, move servo one to extreme left)
100,2,120 (after two seconds, move servo two to about 30 degrees)
150,3,200 (after three seconds, move servo three to extreme right)
200,2,200 (after four seconds, move servo two to extreme right)
250,4,150 (after five seconds, move servo four to about mid-point)

We could continue this sequence, for example

300,3,100 (after six seconds, move servo three to extreme left)
300,1,200 (after six seconds, move servo one to extreme right)

Consider the "check-timecode" approach with the data above:
When the timecode counter hits 301, this value is greater than the 300 in the first instruction, so servo three is moved to its new position. Now, we read in the next set of values. Even if the timecode has increased (to 302 or greater) this is still more than the 300 in the second instruction. So servo one is moved to the extreme right and the next values are read from eeprom.

Normally, the timecode counter value will not have had time to increase between moving the two servo values but we can see from the example above that even if it does, the second servo is only about 1/50th of a second late moving and the servo controller board soon "catches up" and eliminates any delay.

The only requirement for this approach to work is that the data stored in eeprom is already sorted by timecode (with earliest instructions first in the list). Because we're going to use some custom built software for allow the user to build their animations, we can get the PC/host computer to do this sorting for us and don't need to worry about implementing a bubble sort in a microcontroller!

Wednesday, April 6, 2011

Meet AVA, iRobot's New Telepresence Robot

iRobot's first telepresence robot, "connectr", didn't exactly fly off the shelves. So now their at it again, but with a new and better start. AVA is iRobot's newest telepresence robot. The robot can ovoid objects, has three omni-wheels (for excellent turning radius), adjustable height to meet up with humans face, PrimeSense sensors, bumper sensors, laser rangefinders, and scanning acoustic sensors. A microphone and camera are automatically built in because of its main purpose of video telepresence. Its even more cool that iRobot has an app platform for AVA and this will allow developers to create new possibilities for the robot. For now the price remains unknown, but keep your fingers crossed because this bot may go on sale in just a few years! Thanks for reading and check out this bot in action in the video below!

Servo board controller - parallel not serial

Many moons ago, we put together a multiple channel servo controller which generated a lot of interest on YouTube.

As part of the newly-relaunched NerdClub website, it made sense to write a few posts about how the all-new 20 channel controller works. Kits will be made available to anyone who just wants to get their hands on a working servo board, without the need to puzzle out all the clever code.

For this board, we're using the trusty old PIC 18F4550 microcontroller. You can use the lower-voltage 18LF version of this chip too, but we're sticking with the 5V version (see schematics later on).

Many people have asked how we managed to get beyond the theoretical limit of 8 servos on a 20ms pulse. For anyone not familiar with servo control, the way a servo works is it receives a signal of between 1ms and 2ms in duration (1ms = extreme left position, 2ms = extreme right). This signal has to be repeated every 20ms.



In practice, a servo signal is usually between 0.8ms and 2.4ms in length. Allowing for up to 2.5ms per servo, and repeating each signal every 20ms, this means we can send 20/2.5 = 8 signals one after the other, before having to return to the first servo to repeat the whole process all over again.



This is where we challenged the assumption that the servo signals have to all be sent serially (one after the other). We took the "parallel" approach - we turn on all servo pins at the same time, then compare the current time (in milliseconds) from the on signal start, to an array of "off values". Every time the current timer exceeds the "off value", the corresponding output pin is turned off.

Let's say we've an array of three off values:
servooff[1]=1000
servooff[2]=1500
servooff[3]=2000

We turn on all three servo pins at the same time, and start a timer running.
During the main code loop, we compare the current running timer value (converted into milliseconds) against each of the three off values. When the running timer exceeds 1000, we send servo pin one low (turn off the servo signal). This is the same as a 1ms servo signal (which sets servo one to the extreme left position). After the timer exceeds 1500 (1.5ms) servo pin 2 goes low (servo two is set to the mid-position) and after the running timer exceeds 2000 (2ms) servo pin 3 goes low (setting servo three to the extreme right position).

Because the signals need to repeat every 20ms, we now have 18ms of hanging around before we reset the running timer and turn on all servo pins again.
(in fact, these 18ms are used for other processing such as receiving and processing user input, getting data from an SPI eeprom chip and so on).

Using this "parallel" method of processing the servo signals, we can have many more than just eight servos. We stopped at 20 because our PIC microcontroller has 40 pins - 4 are used for power and USB, 5 for SPI clocking an eeprom chip, a few push-button inputs, serial comms (send and receive) and we decided to leave a couple of spares.


Parallel method of controlling servo signals - all are turned on at the same time, and switched off at different times (between 0.8ms and 2.4ms after being switched on).

Tuesday, April 5, 2011

New website and projects

Welcome to the updated, new-for-2011 Nerd Club website!
We've learned from the old site and we're now using the excellent Blogger platform not only for our content, but for images and videos too. We had lots of interest on the old blog site, but when our own server went down, it took all the photos posted on there with it - so lots of posts didn't make much sense without illustrations to explain what was going on!

This new site is an improvement on the old: we're still going to be making cool stuff and writing about it here (including schematics and source code where appropriate) but we've also included links to a video website and even a shop, where you can buy kits of all your favourite geeky gadgets.

Things may be a little slow during these early weeks, as we spend time getting familiar with the hosting platform again, and getting things like the shopping cart integrated with the rest of the site, but don't worry - we'll soon be spouting off about all kinds of nerdy stuff on a regular basis!

In the meantime, here are some links to a couple of other blogs which ramble on about some of the other projects we're involved in:

Ben's Crazy Cube Reader Project
Homebrew Digital Drum Kit
All the latest goings on at BuildBrighton
http://ping.fm/j909t
Check it Out!
Make sure to check out our CNC Machining Today Blog with the latest industry news.

Crain’s Detroit Business - 8/13/2001

Father Prepares Son To Take Company’s Reins

“The family has a good reputation in the industry”, said Jim Preston, owner of Ferndale-based Meier Screw Products.  “They are high-quality people, high-integrity people.  I have referred people to them if a customer comes to me with a high-volume job.”

“Only about 15% of family owned companies survive the transition from the second generation to the third.  J.C. Gibbons Manufacturing Inc., a precision machining company in Livonia, plans to be one of them.”