A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
Hello, I am new to this group and am just begining to look into PIC microcontrollers for my robot project that I intend to make heavy use of common hobby servos in. I know this is likely a well beaten topic, and that there is plenty of pre-made solutions on the market, but in this robot project I am currently playing around with design ideas for improving my existing servo control solution. (A serial servo controler made by Netmedia) My first design concept was to use two PICs for every eight servos the first a simple 20Mhz PIC with an internal 16-bit timer/counter that will be hooked to a 8 channel multiplexer and the second a PIC with at least 8 12-bit ADC channels and some form of RS-485 or SPI support. The timer PIC will be used to create a 0-3ms PWM signal with 16-bit resolution and to control the multiplexer which will divide the signal. The other microcontroller that will be connected to the timer will be measuring the servo's actual position and vary the 16-bit PWM values for each of the controller's eight servos to achieve a 12-bit position sent to it from the robot's central processor. As I see it the timer PIC will cycle through each of the loaded values by setting the multiplexer to the correct channel, setting the multiplexer's input pin high and then setting the internal timer/counter's value. The timer/counter will count down with each tick of the system's 20MHz clock until it reaches 0 at which point an interrupt routine is called which sets the multiplexer's input pin low and then switches to the next channel repeating the process over and over again. I figure at at around 20Mhz I should be able to get a 0-3ms pulse width which shared with eight other servos I should get a 40Hz refresh rate which according to my research on hobby servo control should work. My questions for the group are: 1. Is this feasable on a PIC? (Can I get the timer interrupt thingy to work and would there be enough CPU left to handle the communications with the controlling PIC.) 2. Is there a particular PIC that would be idealy suited for this job? 3. Is there a better way? Considering the following: A. I intend to control upwards of 16 servos (more than one controlling PIC is fine so long as its not over 8 or too damn costly). B. I would idealy want somewhere around 12 bits of PWM resolution between the critical 1-2ms or 1.25-1.75ms PWM range of most servos with enough slack on either side that I can operate each servo to its individual limits. Any help would be most appreciated. |