009 Society Members Forum

Modelling => Electrics and Control => Topic started by: Hugh Norwood on August 21, 2015, 13:05

Title: A digital PWM controller with H-bridge output
Post by: Hugh Norwood on August 21, 2015, 13:05
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:
(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fhnorwood.co.uk%2Ffiles%2Fimages%2Fcontroller%2Fhbridgef.jpg&hash=abf69b2fbbc276c2b6814ea61a0682a0591b81f0)

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
Title: Re: A digital PWM controller with H-bridge output
Post by: Jeff Schumaker on August 21, 2015, 15:01
Very interesting, Hugh. I'm looking forward to seeing how this progresses.

Jeff S.
Title: Re: A digital PWM controller with H-bridge output
Post by: Hugh Norwood on August 21, 2015, 16:37
Oh ye of little faith...
(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fhnorwood.co.uk%2Ffiles%2Fimages%2Fcontroller%2Ftdirbgo.jpg&hash=d3dba532824bde9f184dbbcf5a0ca39cd26eddcb)(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fhnorwood.co.uk%2Ffiles%2Fimages%2Fcontroller%2Ftdirbstp.jpg&hash=30a9c44862c15ec77eca61e9ac469266d4910de0)
(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fhnorwood.co.uk%2Ffiles%2Fimages%2Fcontroller%2Ftstp.jpg&hash=aa40c24ab9e03a1fff0697d7c92316aa3461031b)
(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fhnorwood.co.uk%2Ffiles%2Fimages%2Fcontroller%2Ftdirastp.jpg&hash=bb2fafa817d21f801170ddf81b0a3959fa0cda09)(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fhnorwood.co.uk%2Ffiles%2Fimages%2Fcontroller%2Ftdirago.jpg&hash=54ce6371ccd150a6b642a728b2cb0b2d2af4241f)
Title: Re: A digital PWM controller with H-bridge output
Post by: Jeff Schumaker on August 21, 2015, 19:25
That was quick!

Jeff S
Title: Re: A digital PWM controller with H-bridge output
Post by: Hugh Norwood on August 21, 2015, 20:52
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.
Title: Re: A digital PWM controller with H-bridge output
Post by: Hugh Norwood on October 05, 2015, 21:28
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.
Title: Re: A digital PWM controller with H-bridge output
Post by: Graeme Dunbar on October 06, 2015, 08:51
Not sure about the lack of clamping diodes. See figure 5 of the datasheet:
http://www.ti.com/lit/ds/symlink/sn754410.pdf (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 (http://users.ece.utexas.edu/~valvano/Datasheets/L293d.pdf)
Title: Re: A digital PWM controller with H-bridge output
Post by: Hugh Norwood on October 06, 2015, 09:04
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?
Title: Re: A digital PWM controller with H-bridge output
Post by: Hugh Norwood on December 16, 2015, 15:35
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.