After the faults with controller board 1, I wanted to respin another controller board ASAP. These boards arrived yesterday and with a swift order from RS, so did a load of components! On the previous board, I was using a large STM32 device with many pins and driving the motors directly through level shifter chips. This seemed alright theoretically but in practice was a little temperamental. This matched with the inability to tristate the outputs warranted the change.
This time round, I’ve decided to go for 4000 series shift registers with tristateable outputs – the glorious 4094. This chip is pretty much the 4000 equivalent of the 74HC595 that has found use in every low voltage shift register application ever. This chip however does have logic inputs with the same voltage requirement as the supply. As they will be running off my 12V supply, this requires 12V logic. You can now see where I stand: 12V logic requirements, 3V microcontroller…. level shifter!
This is by far the worst mistake I’ve made ever! In my hunt for a 3.3V regulator that was stable with lower capacitance values, I settles on the UA78M33CDCY, a 3.3V 500mA regulator offered by TI. What I didn’t realise however was that these regulators have a different pinout to other SOT223 regulators that I’ve used, ugh! In the end, I ended up using a standard AMS1117.
I could’ve used a standard logic shifter chips – somewhat like the chips used on driver board 1 but instead, I’ve opted for standard RTL inverters. To ease the component count, I’ve also decided to use digital transistors as mentioned in a previous post. Using digital transistors alleviates the requirement of a base resistor saving a whole 1 component! They also feature base emitter resistors internally helping reduce accidental switching due to noise. While RTL inverters suffice for slow signals, its blatantly apparent that high frequencies get distorted. This manifests itself as a pulse width change for a square wave input limiting the maximum operating frequency to <1MHz. The maximum frequency can be increased by increasing the collector resistor but eventually the power dissipation becomes so large that it isn’t worth using this method anymore. At 12V with 1k pullup resistors, average dissipation is 72mW per RTL inverter! You can see now why they got replaced by CMOS logic…
Scoping the transistor output for different clock frequencies
As can be seen above, using an RTL inverter for a 500kHz clock produces (the oscilloscope was wrong) hardly noticeable clock pulses. While this still produced the correct output at the shift registers, it would increase power dissipation due to the inputs operating in the linear region along with decreasing reliability. For the 250kHz clock however, while the pulse width isn’t ideal (50%), the rising edges still line up with the required data sampling points. For this application, 250kHz would be the fastest clock I’d be happy to use. At this clock frequency, the shift registers can be updated at a maximum rate of 10.6kHz (250k/24bits). From my previous post on feedback linear actuators however, I had decided upon using 125Hz 5bit PWM requiring a write rate of 4kHz. Therefore, I could realistically use a minimum clock of 96kHz.
One main advantage of these shift registers is their output enable input. Once again, this required a level shifter but this time, the input of the RTL inverter is pulled high. This means at power up, the outputs will be in High Z mode. With the inclusion of pullup resistors on the outputs, this allows the power MOSFETs to be powered up in a safe defined condition regardless of previous values in the shift register. The microcontroller will then shift in the same values as idle and enable the output. This should help alleviate any of the weird behaviour I was getting on the previous board.
Another advantage of using shift registers is that it alleviates the need for a high pin count microcontroller at the disadvantage of slower update rates. This reduced the total board cost as shift registers plus the STM32F030F4 still came to less than an LQFP64 STM32F0!
This time, I decided to use array resistors to further keep the component count down. I’ve never used these so thought why not! The ones I used were equivalent to a standard 1206 resistor but instead contained 4x identical 0603(ish) sized resistors. While it was harder to solder, it made for much faster assembly. The resistors (1k) were used for the RTL inverters along with the MOSFET pullup and gate resistors. This however was a mistake as using 1k resistors for the pullups meant the shift registers were sinking 12mA per output during low periods! This caused them to heat up massively (especially since driving 8 meant a total sink of 96mA – more than the 50mA maximum) and caused one of them to burn out (ugh). I have instead since ordered some 0402s which I’ll solder in place of these – with 18k resistors for the pullups! Still, resistor arrays are pretty cool.
Gate resistor arrays, they’re tiny compared to that SOIC8!
The board not yet populated fully.
Once the 0402s arrive, I can test out the H bridge MOSFETs that I purchased.