• Welcome to 009 Society Members Forum.

A digital PWM controller with H-bridge output

Started by Hugh Norwood, August 21, 2015, 13:05

Previous topic - Next topic

Hugh Norwood

This is a "proof of concept" controller; I just wanted to see if it would work!

The idea was to see if the microcontroller that I used in my pic-based train controller could be used to control the direction as well as the speed of the locos. To do this requires what is called an "H-bridge" driver; basically four power devices with the motor between pairs of them. The current through the motor (and hence its direction) is controlled by which two of the power devices are on at any one time.

This is the circuit diagram for the working device:


The 8-pin version of the picAXE controller has just enough input/output pins to do the job. I chose a rotary encoder that has an integral push-switch, and three different-coloured LEDs in it. This meant there would be a nice "minimalist" look to the enclosure I put the device into - only one control! (Not without some head-scratching, as it turned out)

The aforementioned switch and LEDs are all commoned to the +5V line, so I had to use an inverter chip (74HC04) to reverse the logic from the picAXE to drive the three LEDs (red and green for direction, blue for speed).

As with the other controller, the software governs how the thing works. With this one:
Turning the encoder shaft clockwise increases the speed
Turning the shaft anti-clockwise decreases the speed - all the way to stop.
Pressing the shaft in - to activate the push-switch does one of two things:

If the loco is underway, it is stopped (but the direction is saved)
If the loco is stopped, the direction is reversed.

The red and green LEDs indicate the direction.
As the speed increases, the blue LED get brighter, so the colour seen through the translucent knob changes either from green to cyan or from red to magenta.


Full description on the web site below - under Electronics
Hugh Norwood
Angst-Lesspork

Jeff Schumaker

Very interesting, Hugh. I'm looking forward to seeing how this progresses.

Jeff S.

Hugh Norwood

Hugh Norwood
Angst-Lesspork

Jeff Schumaker


Hugh Norwood

I went through the design process over on the other place. Took me about 17 days in total, including waiting for the parts to arrive.
Hugh Norwood
Angst-Lesspork

Hugh Norwood

It's been brought to my notice that the SN754410 may not be a completely slot-in replacement for the L293; It apparently may not have internal clamp diodes to protect the driver stages. I'll post an updated circuit diagram when I get round to redrawing it.
Hugh Norwood
Angst-Lesspork

Graeme Dunbar

#6
Not sure about the lack of clamping diodes. See figure 5 of the datasheet:
http://www.ti.com/lit/ds/symlink/sn754410.pdf

Edit - or did you mean it the other way round? The L293 doesn't apparently, but the L293D does (page 3 and 4):
http://users.ece.utexas.edu/~valvano/Datasheets/L293d.pdf
Graeme Dunbar - 4441

Hugh Norwood

Yers... That's a more up to date data sheet that the one I have, which, although it shows internal diodes, indicates they are for ESD protection, and the diagram for driving a stepper motor shows external diodes....

I guess TI have updated the internals of the chip; but when?
Hugh Norwood
Angst-Lesspork

Hugh Norwood

Pleased to report that the controller behaved very well at the Manchester Show on 5 and 6 December. It coped with all the locos I was using on the weekend.
Hugh Norwood
Angst-Lesspork