April Maker challenge 2- servo driver IC

Lately I've become obsessed with multiprocessing solutions for hobby level embedded systems. A PIC12F683 is a reasonably powerful 8-bit microcontroller in an 8-pin package, and it sells for right around $1 in qty 25. This can provide a powerful means for offloading certain functions of a circuit to another IC at minimal cost, allowing you to do heavier lifting in your main circuit than you otherwise might have. An example is servo-motor control with the Arduino. It's quite do-able, but you may find yourself in a project where you want to control a servo's rotational position based on user input from a potentiometer. In that case, using precious CPU cycles from the Arduino in the system just to read the pot and update the servo periodically is a drag. So why not take an 8-pin PIC and make a simple IC that reads digital inputs and converts the value to a servo angle?

It'd be easy enough- the servo output is a PWM signal but the duty cycle is low. The motor holds position expecting a pulse every 20ms, and the pulse is usually in the range of 1-2ms for 0° to 180°. That leaves you a minimum of 18ms to read the analog voltage(s) and calculate the next pulse length. At 8MHz (the maximum internal clock speed of the '683), each instruction is 500ns in length. If we do 8-bit math, we can have 256 variations representing 0° to 180°. Making the assumption that the pulse needs to be 1.5ms +/- .5ms, we have a 1ms dynamic range to express with 256 slices- about 4us per slice or 8 instruction cycles. I think that's probably enough time to do a pretty accurate timing routine for three channels, using three analog inputs, which is handy, because the '683 has 6 I/O pins, so that's three analog ins and three pulse outs.

Comments

Popular posts from this blog

Breadboarding the Arduino- part 1

18 Essential Skills for a Maker

In Which I Create A Kerfuffle