Saturday, August 31, 2013

Receiver v3 sketching

In the end of my last post I mentioned that I was working on yet another revision of my receiver. The main reasons being the lack of hardware PWM support in the v2 revision as well as the difficulty of making the boards for a v2. Receiver v2 was designed for DIY manufacture of the PCB, which meant that it had to be possible to build without plated vias. This then meant that I couldn't have vias under components, and again that the boards had to be relatively large. To combat the boards becoming excessively big, I decided to split it to a two board design. This was a huge improvement on the v1 though, which was a three board design.

The biggest issue in the v3 is the hardware PWM. The processor used in v2 (the Atmel ATMEGA168) has only two hardware PWM channels capable of reasonable resolution servo pulses. This is the reason why v2 does the servo updates with bit-banging in software. Now, I could've just gone with some other processor which has at least eight reasonable PWM channels. However, as the ATMEGAx8 family of processors have worked well and since I'm quite familiar with them, I wanted to find a solution which allowed me to continue using them in the receiver.

As I am clearly exceeding the capabilities of the ATMEGAx8 processors, I do in fact need a new IC on the board. I was planning on using just a simple cheap analog multiplexer, namely the venerable 4051, which is a 1-to-8 bidirectional analog mux and costs around 0.20 €. As a servo pulse is high for a period of 1-2 ms every 20 ms and low the rest of the time, I can multiplex multiple servo channels on a single 16 bit hardware PWM channel. The idea is that while one channel is outputting its pulse, the other channels are at their low state. This is very similar to the pulse position modulation used in old analog RC transmitters and receivers.

Outputting 8 channels gives me 2.5 ms (= 20 ms/8) per channel. In other words, each channel has 2 ms time allocated for the actual pulse + 0.5 ms setup time. During the half millisecond we just need to run an ISR, which selects a new channel on the mux and loads the appropriate pulse width for it. It is a simple thing to do with a huge amount of time to do it. This means that the servo update requires almost no CPU time. Also, by adding a second mux and using the second 16 bit hardware PWM channel, I could trivially get up to 16 channels. 

The board is not really that big of an issue. Companies like ITead Studio provide PCB prototyping services, which give you 10 boards for 10 dollars. For that price it really doesn't make sense to do inferior quality boards at home. Of course I only need two or three boards, but it's still quite a reasonable price for those. The size limitation for the cheap boards is 5x5 cm, which should be easily achieved as the v2 boards already fit the limit. The multiplexer takes some additional space, but I'm confident the space saved by being able to use a more efficient board layout will more than pay it back.

No comments:

Post a Comment