16 Channel Servo Board Timing Errors

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
arctic_eddie
 
Posts: 233
Joined: Tue Feb 28, 2012 6:01 pm

16 Channel Servo Board Timing Errors

Post by arctic_eddie »

I'm working on a project whereby the servo board is being used as an interrupt pulse(10usec) generator on channel 0 followed later(2msec) by another pulse(4msec) on channel 1. This setup runs at 50Hz. The remaining time in the 20msec span is used to analyze an external response from the second pulse fed to analog A0.

On my Owon SDS7102 digital oscilloscope using the Measure function, I find the frequency is 53.55Hz and the period is 18.67msec. This is an error of 7.1% and more than I would expect. So question 1 is:

1. What determines the clock frequency in the servo controller chip? There is no connection to the 16MHz CPU clock.

To check my scope, I programmed this test code into my sketch. I used channel 15 and set the PWM freq to 50Hz, the On time to 0, and the Off time to 2048. This generates a square wave with a 50% duty cycle. The output of this signal is sent to D8 on the Uno. Code in the setup() section records micros() at the start of a positive transition and reads it again at the next rise. The time difference is then the period of the oscillation. The printed value is 18.656msec which agrees with the oscilloscope.

Since there doesn't seem to be any way of adjusting the clock, I will probably use the test code as a runtime startup calibrator. The measured period will be compared to the desired period and the new PWM freq reset using the ratio of the two numbers.

Therefore:
float newfreq = oldfreq * 18.656 / 20.0;

Do you see another other solution?

User avatar
westfw
 
Posts: 1919
Joined: Fri Apr 27, 2007 1:01 pm

Re: 16 Channel Servo Board Timing Errors

Post by westfw »

The datasheet says that there is a 25Mhz internal clock. Presumably RC. Since the chip is intended to drive LEDs at variable brightness, and the board is designed to drive servos, it does not surprise me that this clock would have a relatively low accuracy (+/- 10% ?) However, I couldn't actually find a specification for the clock accuracy in the datasheet.

The chip itself has an external clock input, but it doesn't look accessible from the adafruit pcb. You could presumably connect a high-accuracy clock instead of using the internal clock...

User avatar
arctic_eddie
 
Posts: 233
Joined: Tue Feb 28, 2012 6:01 pm

Re: 16 Channel Servo Board Timing Errors

Post by arctic_eddie »

I suspected as much since no crystal is found on the PCB. An R/C network for the oscillator at that frequency is probably somewhat temperature dependent.

I added my on-the-fly corrector to the setup() portion of the sketch. With a single iteration, the error is down to 0.12%. It costs one digital pin but the correction is worth the trouble. It may turn out that the error is stable for a particular PCB/chip combo so can be included in the code.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”