009 Society Members Forum

Modelling => Electrics and Control => Topic started by: Hugh Norwood on April 18, 2013, 13:59

Title: A new PWM controller
Post by: Hugh Norwood on April 18, 2013, 13:59
A PWM controller.

My fellow LAMPOONS know that I dabble in the dark arts (of electronics). Well, I recently started to think again about the subject of pulse-width modulation for motor control. One problem is to find a simple circuit that can offer as full a range of mark:space ratio as possible - ideally from fully off to fully on.

My previous idea had used two integrated circuits and a lot of faffing around finding the right resistors.

This time, my thoughts fell on the following circuit, which is the standard way of getting a 1:1 mark-space ratio from the ubiquitous 555 timer.
(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fwww.hnorwood.co.uk%2Ffiles%2Fimages%2F555cct.gif&hash=e8b914187bd5a41929d8680bfa288722c0d993fd)

The device output (at pin 3) is used to both charge and discharge the capacitor through the resistor. What, I thought, would happen if I replaced the resistor with a potentiometer (variable resistor), where the device output is connected to the pot's wiper, and the pot's two ends connected to the capacitor through two diodes connected the opposite way round (see figure 2)

In this case the capacitor is charged through one side of the pot, and discharged through the other side; this would change  the mark:space ratio of the signal as the pot's shaft is rotated.

(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fwww.hnorwood.co.uk%2Ffiles%2Fimages%2Fpwm2b.gif&hash=9b4b08632c5f15de191cb9827c111ae9ab891f7d)
I made up a test circuit and was pleasantly surprised to see that not only did it indeed work, but the mark:space ratio could be changed from almost fully off to almost fully on. Eureka - to coin a phrase.

Figure 2 shows the complete controller. The 7812 12volt power stabiliser is an optional extra and serves to provide a nice 12V supply limited to 1amp. Since the timer I.C. works at low voltage, this could be changed for a 7805 to run at 5V for low-voltage motors. I have used the low-power 7555 timer IC. The circuit does not show the d.p.d.t. centre-off switch that controls the motor direction.

The circuit oscillates at around 20kHz - which changes remarkably little over the full range of the pot's travel. this frequency should be high enough not to cause heating in low-inductance motors.
Title: Re: A new PWM controller
Post by: Isle of Stoner on April 18, 2013, 16:49
Crikey...

John W
Title: Re: A new PWM controller
Post by: Krizzy on April 18, 2013, 17:01
.................and some say soldering a kit together is a dark art.

Hugh, are you going to bring your creation along to the AGM. i'm sure it will create a lot of interest.

Roger
Title: Re: A new PWM controller
Post by: Graeme Dunbar on April 18, 2013, 17:29
Excellent! Good to see another dabbler in the art of Electrickery.

I've been trying something similar:
http://www.youtube.com/watch?v=kw8SCKRFH_U (http://www.youtube.com/watch?v=kw8SCKRFH_U)

It was an experimental circuit and I took a different approach. My primary concern was for slow speed running (T gauge trains race around). Also, the load that engines pull is very low, so I hoped to get away with slow pulses rather than what you have which is "true" PWM or DC chopper control. (You can hear the train buzzing.) At 20 kHz the motors should "see" an "averaged" DC but low frequencies give pulses of full voltage that can burn out coreless motors.

For me to take it further needs a more sophisticated controller I think. Perhaps a combination of pulses and high frequency PWM
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 18, 2013, 23:19
Quote from: Krizzy on April 18, 2013, 17:01

Hugh, are you going to bring your creation along to the AGM. i'm sure it will create a lot of interest.

Roger

Certainly, if you like, but as I'm a passenger, I can't really bring along a test track...
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 18, 2013, 23:24
As I have mentioned in another place, I have tested this out on some of my locos on a section of track. (I can't easily set up Angst at home for a test run)
Title: Re: A new PWM controller
Post by: B.Meldon on April 19, 2013, 10:13
This looks interesting indeed.

I am not an electronics person myself so much of what I ask below may be nonsense but
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 19, 2013, 11:20
Q: What levels of V and A will be going through the variable resistor and as a consequence how long do you think this will last in use?

A: Nothing to worry about. Max voltage across the pot will be 12V, Current flowing through will be small considering the capacitor is only 2nF. The pot is likely to fail mechanically first, I would suggest.

Q: Have you given any thought as to short circuit protection? Or if two are used on a layout these become connected by accident when a loco runs over a section joint.

A: The 7812 provides short circuit protection. No idea what may happen if you put two together either by accident or on purpose.

Q: One issue with some pulse type controllers relates to high current levels over the pulse cycle at low speeds for long periods. In other words a loco running very slowly for a few minutes. This does not show up on a normal amp meter but can be seen using an oscilloscope.

A: I have no idea what you mean by this statement.

Q: From what I understand the heat generated is a result of the physical design of the motor and its relative impedance to the frequency used. Some motors are fine where others will overheat.

A: Yes indeed. This runs at 20kHz

Title: Re: A new PWM controller
Post by: Tigger on April 19, 2013, 15:00
Hugh -very simply - I'm bloomin' impressed!!  Well done and many thanks for sharing!!
:)
Title: Re: A new PWM controller
Post by: B.Meldon on April 21, 2013, 00:43
Quote from: hughn on April 19, 2013, 11:20

Q: Have you given any thought as to short circuit protection? Or if two are used on a layout these become connected by accident when a loco runs over a section joint.

A: The 7812 provides short circuit protection. No idea what may happen if you put two together either by accident or on purpose.

Even with the best intentions this will happen on a sectional layout with more than one controller so it is probably important to know if it will damage the controlers.

Quote from: hughn on April 19, 2013, 11:20

Q: One issue with some pulse type controllers relates to high current levels over the pulse cycle at low speeds for long periods. In other words a loco running very slowly for a few minutes. This does not show up on a normal amp meter but can be seen using an oscilloscope.

A: I have no idea what you mean by this statement.


As I said this is not my field at all so perhaps I have got it all wrong or I am describing it in the wrong terms. However I think with some controllers the time of the pulse is longer at slower speeds. In other words there are fewer pulses but the pulses that there are last for longer. This obviously the loco will run slower. But if you work out the total power in the motor over the pulse cycle it can be quite high, but it is dependant on the impedance of the motor as to how much of this will be dissipated as heat in the motor. Basically the motor will see more of the pulse or less depending on its physical design and the frequency of the pulse.

Some examples are the Arnold motors and the plastic Bachmann motors (as used in the 0-4-0) that get very worm, yet the motors used in Roco locos do not get hot at all.

As I said this is not my subject so I could have this all wrong, but what I have seen is that some motors get hot on pulse controllers and some do not.

Brian Meldon
Title: Re: A new PWM controller
Post by: gtmspyder on April 21, 2013, 10:08
Thirty years or so ago, I was invited to take a 4x2ft 009 rabbit layout I had made my daughter, (Or at least, that was my excuse for the exercise) to the York exhibition by Mike Cook.

The layout did not have it's own controller as I was using the controller from my then EM gauge layout of Ballquider junction on the Callendar and Oban layout, so I decided to experiment with the then newish lighting dimmers.

I fitted a fused 240/12v transformer and rectifier into a box with the supply controlled with a Crabtree lighting dimmer.

The loco stock I was using was the Lilliput 060's, and under this control, the motors literally ticked over and barely perceptively moved. I was able to run four locos tail chasing round the layout with only an occasional section off switch being used off scene to stop a faster running loco from catching it's predecessor.

Regards,

BrianT.
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 21, 2013, 14:53
Quote from: gtmspyder on April 21, 2013, 10:08
I fitted a fused 240/12v transformer and rectifier into a box with the supply controlled with a Crabtree lighting dimmer.

BrianT.

Well! That's an interesting way to do it. Wouldn't recommend recommend it...
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 21, 2013, 14:59
Brian M,
I'm still not quiet sure what you mean. My unit keeps the pulse repitition frequency pretty constant over the entire range. Because it operates at 20kHz (50 microsecond repititon time), it should be OK with small motors and corelss ones (i.e. those with low inductance)

Before pronouncing on older commercial PWM units, I would prefer to investigate how they operate, so if anyone wishes to lend me one, I could have a look. Generally speaking, those that operat at 100Hz (i.e. tiwce mains frequeny would, I suspect, be unsuitable for low-inudctnace motors.
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 21, 2013, 15:04
I took my controllers to the Rainford meeting (Excellent day, chaps - well done)

The PWM uint worked fine, except that I found it drove Roger's Graham Farish chassis slowly along even when at "zero". I don't myself have one of these new chassis to playwith, so I can olny guess that it has a very good motor in it that is sensitive to the tiny pulses the PWM controller puts out at zero (it can't switch off entirely)

What was very ecouraging was that my feedback controller ran this same chassis very smoothly. - Apparently "commercial" feedback controllers cause this type of chassis to go erractically! I'l create a new thread about this controller.
Title: Re: A new PWM controller
Post by: Graeme Dunbar on April 21, 2013, 15:50
To the best of my knowledge what you say is correct Hugh (edit: last message but one). Some time ago a member of MERG (Model Electronic Railway Group) did the analysis that showed how low frequency PWM cause heating problems in low inductance motors (e.g. coreless motors) where dc and high frequency PWM (e.g. 20 kHz as you use) do not.

With low frequency pulses, it is operation at slow to moderate speeds that causes problems (short ON to OFF time ratio). At very low speeds (very short ON pulses and long gaps) the average power and heating is low. At high speeds (long ON to OFF ratio) the motor is spinning and generating a sizable back emf that limits the motor current.

Of course if you stall the motor (lock the shaft) and apply full voltage the motor will probably burn out no matter whether you use high frequency PWM, low frequency PWM or dc, unless you limit the current. However if the current limit cuts in too quickly then it prevents the controller giving the initial "kick" to get the motor turning which negates part of the reason for using PWM in the first place**.

I have considered, but not yet tried using a "polyfuse", a positive temperature coefficient thermistor or other system to act as a thermal cutout to take effect after short delay.

** Edit: if using low frequency pwm.  At high frequency the motor inductance limits the time the current has to build up and decay, smoothing it to a ripply dc.

Title: Re: A new PWM controller
Post by: Krizzy on April 21, 2013, 16:37
An aside to the controllers Hugh was showing us at Rainford AGM show Frank Allen showed us his radio controlled GVT tram loco. Frank uses model aeroplane technology to control his KATO tram powered loco by way of a small battery in the loco and control chip. He has also incorporated a switch that enables the loco to operate conventionally on dc from the track. He is going to try further development using a Narrowplanet diesel he bought off Steve and Tom at the show.

Frank let me have a go at using his radio controlled loco and it's performance is very impressive, especially for hands off uncoupling.

Roger
Title: Re: A new PWM controller
Post by: gtmspyder on April 21, 2013, 16:44

(Well! That's an interesting way to do it. Wouldn't recommend recommend it...)





Hello Hugh.

Re my post about dimmer controller:- :)

I did fit a 1/2 amp trip in the 12v output after the transformer/rectifier with a pilot light across it to show when or if it had tripped, the whole assembly was earthed.   I just did not want to go into a blow by blow account of what I did.

Regards,

BrianT.
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 22, 2013, 09:03
I don't want to create thread-drift in my own thread, but if I recall correctly, standard dimmers are designed for resistive loads - such as lamps, heaters etc. Using one to drive a tramsformer, which is more of an inductive load, could cause problems...
Title: Re: A new PWM controller
Post by: B.Meldon on April 22, 2013, 11:24
Inductive dimmers are available for use with transformers on low voltage lighting systems.
But as Hugh said the normal standard resistive dimmer switches are designed for use directly with light bulbs and may well fail when used with a transformer.
There is not much difference in price between the two but the resistive type are far more common.

Brian Meldon
Title: Re: A new PWM controller
Post by: Malcolm on April 22, 2013, 20:24
Quote from: Krizzy on April 21, 2013, 16:37
An aside to the controllers Hugh was showing us at Rainford AGM show Frank Allen showed us his radio controlled GVT tram loco. Frank uses model aeroplane technology to control his KATO tram powered loco by way of a small battery in the loco and control chip. He has also incorporated a switch that enables the loco to operate conventionally on dc from the track. He is going to try further development using a Narrowplanet diesel he bought off Steve and Tom at the show.
Frank let me have a go at using his radio controlled loco and it's performance is very impressive, especially for hands off uncoupling.
Roger
Apologies for going a bit off thread here but there was an article in MRJ 218 by Don Rowland entitled 'The Way Ahead - Radio Control Arrives'.  Don is so confident with the current radio control equipment that at 82 he is bulding a new P4 layout without any wiring.  Someone also suggested that if the current big commercial model firms had not put so much investment into DCC then some serious work on developing a standard radio control system would now be in hand.  Do we need to start another thread to discuss radio control?
My eyes may glaze over when people start talking about electric circuits and controller inards but in the meantime until there is a readily available radio control system I greatly appreciate your work Hugh in developing a controller that will improve the running qualities of 009.  
Malcolm
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 22, 2013, 23:16
The RC thread is here
http://www.009society.com/forum/index.php?topic=1106.0 (http://www.009society.com/forum/index.php?topic=1106.0)
;)
I agree with Roger - it was pretty impressive
Title: Re: A new PWM controller
Post by: Malcolm on April 23, 2013, 18:10
Quote from: hughn on April 22, 2013, 23:16
The RC thread is here
http://www.009society.com/forum/index.php?topic=1106.0 (http://www.009society.com/forum/index.php?topic=1106.0)
;)
I agree with Roger - it was pretty impressive
Hugh
I have definately been asleep  :-[.  Not only with the discussion on here but also the ongoing discussion at that other place!
Malcolm
Title: Re: A new PWM controller
Post by: Graeme Dunbar on April 23, 2013, 18:53
I've taken a look around to see what I can find on motor heating with PWM. It is easy to get stuck with a lot of maths, but a clear description is given here (and from what I understand is a reputable source - they make electric wheel chair drives and so on):
http://www.4qdtec.com/pwm-01.html#heat (http://www.4qdtec.com/pwm-01.html#heat)

There is a discussion relating to model railways part the way down the page here:
http://keller-tuberg.homeip.net/~stefan/train/article2.html (http://keller-tuberg.homeip.net/~stefan/train/article2.html)
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 24, 2013, 08:59
I came across the 4qdtec site a few years ago when I was researching PWM control. A lot of the published stuff relates to high-power systems like motorised golf caddies, or (back then) the sort of robots used in "robot wars"... Still, it has a bearing on our discipline.
Title: Re: A new PWM controller
Post by: gtmspyder on April 24, 2013, 10:56
Hello Hugh,

I used a 4QD controller when I built my Grandsons Toylander Land Rover, they are very good.


And the information on his site is very comprehensive, but if you contact him, he does not suffer fools gladly. ;)

(https://forum.009society.com/proxy.php?request=http%3A%2F%2Fi1010.photobucket.com%2Falbums%2Faf229%2Fgtmspyder%2FDSCN0175-1.jpg&hash=c928d3ee8685eaec85f6afcc0349006c92ed6867) (http://s1010.photobucket.com/user/gtmspyder/media/DSCN0175-1.jpg.html)

Regards,

BrianT.
Title: Re: A new PWM controller
Post by: B.Meldon on April 24, 2013, 11:23
Quote from: GraemeD on April 23, 2013, 18:53

There is a discussion relating to model railways part the way down the page here:
http://keller-tuberg.homeip.net/~stefan/train/article2.html (http://keller-tuberg.homeip.net/~stefan/train/article2.html)
Thanks for the link Graham.

So according to the above text a 20khz controller (i.e. 15khz or above ) will not cause any heating in the motor. So that
Title: Re: A new PWM controller
Post by: Graeme Dunbar on April 24, 2013, 12:39
It is difficult to give definitive assurances, but it is not so much a 20 kHz waveform that is likely to cause problems but the higher frequency harmonics in a "sharp edged" square wave. It is no different to DCC, electronic track cleaners and high frequency lighting or for that matter "sparking" (visible or invisible) when wheels loose contact as they will generally contain much higher frequency harmonics. If the transistor switching transients were to be found to cause interference the cure would be to "slow down" and "round off" the edges of the square wave with a filter.

As for shorts destroying the controller, it is no different to dc. It is just dc that is being turned on and off rather quickly. The way shorts are handled is generally different between dc and DCC. On this controller the 7812 should shut down when asked to supply more than about an Amp. On DCC, because the system has to supply power to many locomotives and accessories the booster can generally supply several Amps and so it uses a "switch off and try again" approach. If after a few tries the short is still present it shuts off.

I use a MERG dc block control system called "SuperBloc" which has full and adjustable short circuit protection. At exhibitions I put a coin across the track to stop trains.
Title: Re: A new PWM controller
Post by: B.Meldon on April 24, 2013, 13:19
I think the KPC DC controllers have a simple (if a little crude) thermal cut out devise in the circuit for short circuit protection.
Perhaps something like that would be an idea for Hugh
Title: Re: A new PWM controller
Post by: Hugh Norwood on April 24, 2013, 17:25
My circuit was presented as an exercise in circuit design and development, and should be considered in that light. While I myself am happy to use it on my layout, no one else is under any pressure to build it. Since I am not in the business of building them to order, no one is under any obligation to buy one!

Title: Re: A new PWM controller
Post by: Graeme Dunbar on April 24, 2013, 21:51
Precisely - just as building a locomotive doesn't imply that it is mandatory for everyone else to follow suit.  :laugh:
Title: Re: A new PWM controller
Post by: Hugh Norwood on May 22, 2013, 11:00
I'd be interested in which microcontroller you intend using, Richard. I was interested to see the Arduino has PWM outputs, but then I found the maximum repetition rate is about 490Hz, which is really too low for small motors. So I shelved that idea.

My offering could easily be changed to limit the maximum voltage by supplying the output to the MOSFET through a voltag regulator (eg a 7805)

Although, come to think of it a complete low-voltage desgin would be possible as the 7555 will run from 5V.

Actually, I've experienced no problems with running KATO chassis against the "older" chassis with this controller.
Title: Re: A new PWM controller
Post by: Graeme Dunbar on May 22, 2013, 12:48
That's partly correct. The standard Arduino rate using the built in "analogWrite" function is 490 Hz, but it is possible to bypass this. However  there is a compromise to be struck between using the Arduino environment where the hard bits are hidden and performance when controlling the hardware directly. It is possible to make the Arduino generate a TV text overlay signal so it can handle higher frequency I/O, but it ties up most of the resources. (I've used that on the ROV (underwater robot) exhibit I designed for the Aberdeen Maritime Museum.)

PICaxe might be a better bet, but at the cost of losing some of the user- or beginner-friendly elements.

Then of course you could go all fancy and use an mbed microcontroller and control it from an Android phone!
http://www.youtube.com/watch?v=rsEBQiMl7Zo (http://www.youtube.com/watch?v=rsEBQiMl7Zo)

(But the mbed controller is not aimed at the same market as the Arduino which is for real beginners.)
Title: Re: A new PWM controller
Post by: Hugh Norwood on May 22, 2013, 13:58
Things have got a lot smaller from when I used a DEC LSI-11 in my research back in the late 70's....
Ah, but the joys of assembler programming!
Title: Re: A new PWM controller
Post by: Hugh Norwood on May 22, 2013, 14:12
I would like it if you kept us posted on your progress and experience, Richard