View Full Version : forum


melfin
Fri, 26 Oct 2007 13:42:00 GMT
controlling 18 servos
Hi. I was wondering which chip form the PIC33f you have used on the IC hexapod? Also how did you manage to control up to 24 servos from the single chip? I can only find chips with 8 PWM channels onboard.
mdenton
Tue, 6 Nov 2007 22:31:00 GMT
re: controlling 18 servos
Hi Melfin,

I use multiplexer chips to give me the additional PWM channels. So if you use an 8 channel multiplexor, and you have 8 PWM outputs, you could have up to 64 servos. :)

The PCB I developed for this is called the p.Brain. This is a dsPIC33FJ128GOP206, 4 8 channel multiplexers configured to use 6 outputs each giving 24 PWM channels at up to 80Hz using the standard 1 to 2ms PWM range. Also incorporated is 1Kb external eeprom, on board 3.3V regulator and two LED's for debugging.

The p.Brain is plugged into a motherboard which distributes the PWM signals, and gives access to the two serial ports on the dsPIC, along with 8 digital/analogue inputs, and 4 digital I/O lines.

I may release a bare bone version of the p.Brain, this will be as a platform for people who need a powerful 16bit processor, and multiple PWM outputs for robot control projects. The p.Brain will come with no code, but I will provide examples of how to run 24 PWM outputs in C for the hi-tech compiler.

cheers

Matt.
Brian Howell
Fri, 14 Dec 2007 11:06:00 GMT
Re: controlling 18 servos

Using a multiplexer to increase the possible number of servos, that's a great idea that never occured to me. Can I ask what chip you selected for your designs?

mdenton
Fri, 14 Dec 2007 11:16:00 GMT
Re: controlling 18 servos

Hi Brain,

Any 1 to 8 line or 1 to 4 line TTL or CMOS multiplexor will work. Such as 74HC238.

Matt.

Demmo
Sat, 15 Dec 2007 11:22:00 GMT
Re: controlling 18 servos

Hi M@,

could you give me some tips about multiplexing PWM channels? As far as I know I have to repeat PWM signal after maximum 20ms. Pulse width is usually about 0.8-2.2ms (1.5ms neutral). How should it work like? Should it in a sequence make following steps:

- turn off previosus PWM (because next servo shouldn`t receive previous signal after switching)

- select next servo on multiplexer

- turn on PWM with new parameters

..and so on, or there is another (micro ;))magic way?

If there is a force or terrain adaptation everything should be calculated in main loop, changes in PWM etc executed after timer interrupt? or this uC should only control servos without any calculations?

cheers ;)

mdenton
Mon, 17 Dec 2007 10:02:00 GMT
Re: controlling 18 servos

Hi,

The PWM multiplex method that you have stated is correct. If your uC has enough power such as the p.Brain, then do all your PWM and gait algorithms within one uC.

Matt.

Demmo
Mon, 17 Dec 2007 17:39:00 GMT
Re: controlling 18 servos

I`ll have to decide which functions should the controller have and then I`ll put uC which can handle them :) Mainboard will be probably equipped with ARM because its cheap (1/3 price of servo ;)) and quite powerfull - I`d like to use neural networks (as algorithms) for few functions without using external computer so (many)^n MIPS will be needed :D

servo controller doesn`t need ARM but... who knows? maybe this spider will start jumping and dancing because of having 2 ARMs onboard? ;)

Justin
Sat, 29 Dec 2007 12:17:00 GMT
Re: controlling 18 servos

You can also create a PWM in software using interrupts. I have created 32 PWM channels for a 4x4x4 LED cube with a dsPIC33FJ128GP710.

If you want more details you can e-mail me.

Justin

Justin
Sat, 29 Dec 2007 12:18:00 GMT
Re: controlling 18 servos

Opps, my e-mail did not show up.

mdenton
Sun, 30 Dec 2007 11:00:00 GMT
Re: controlling 18 servos

The problem I find when using software PWM outputs, is when two PWM outputs are equal to each other, there is a slight delay glitch in one of the PWM outputs (caused by the ISR trying to servis two outputs simultaniously). This is not much of a problem in LED´s, but in servos is not desirable. This can be minimised by using fast processor clocks so the glitch is barely noticable, but if you have hardware PWM.. its usually better.

Matt.

Justin
Mon, 31 Dec 2007 12:02:00 GMT
Re: controlling 18 servos

When I make my hexapod I am going to try software PWM and if it glitches I'll tell you.

When I made my software PWM I used one interrupt to act as a counter. Each time the ISR was called it added one to a variable that I'll call counter. Then each value for the servos was compared to the counter. If is was less than or equal to then the pin was high, if it was greater then it was low. This code makes the PWM lines change within .5us of each other with the dsPIC running at 80Mhz. This may not work as well with servos as you have a 20ms delay between pulses and the ISR would have to be called for many wasted cycles. I will have to adapt it some, maybe use a second interrupt to wait the 20ms delay then enable the other? I am waiting for a regulator for my Robostix so I can't test yet.