Board index Talking T Gauge Forum T Gauge General Discussions

The place for general discussions and requests for help on all matters relating to T gauge.

My PWM controller using a Picaxe microcontroller

Postby NeilM » Thu Nov 14, 2013 10:11 am

Having just ordered a loco chassis today I plan to press on with my PICAXE based PWM controller that I have been planning for some time.

To step back a moment, I have plans to build and test both a traditional style PWM controller (i.e. using a rheostat), and a digital one using just push buttons. I plan to build the analogue control version to be operate centre off in the manner I am used to, having been a life long user of H&M duettes. I also plan to make the digital one operate using a similar logic, so no reversing switch.

The controller covered here is the digital version. It has 3 input buttons, left, right and stop(emergency immediate stop) and a relay to switch the direction. It currently uses the smallest PICAXE chip with just 2 inputs and 2 outputs (assuming the serial in/out are not doubled up) which is sufficient, although more outputs would allow indicator lights on the hand help unit.


The way I see this working is;
Pressing the button for the current direction of travel will accelarate the loco at the predetermined rate whilst held down
Pressing the button for the opposite direction will decelarate the loco at the same rate - but will not reverse it
Releasing the button after decelerating to zero will allow the loco to be reversed next time
Finaly, pressing the stop button will effect an immediate emergency stop

The feature to prevent the loco reversing whist holding down the button is there to simplify stopping the loco without ending up shuffling back and forth trying to find the off point.

I have the software for this planned, but some values will only be found by experimentation;
Frequency of the PWM signal
Number of speed steps
Time delay in changing from one speed to the next (these last two will need to be set together)
Also, depending on the initial results, the following may need adjusting for optimum controlability
minimum speed step for the loco to actually be moving (do not want to be sat holding the button until the loco decides to go)
maximum speed step which it is feasible to use
This code is already runing in the Picaxe simulator and is looking promising.


I hope to get this ready for testing soon after my chassis arrives and will keep the thread up to date with how this is progressing.
Attachments
PWM Controller 001.JPG
Circuit diagram
PWM Controller 001.JPG (30.99 KiB) Viewed 9148 times
Neil

T gauge items in my Shapeways shop http://www.shapeways.com/shops/t450
NeilM
 
Posts: 181
Joined: Thu Nov 14, 2013 9:46 am
Location: North Yorkshire, UK

Re: My PWM controller using a Picaxe microcontroller

Postby NeilM » Wed Nov 27, 2013 5:17 pm

As an update to this thread...

I have built this circuit a on a breadboard. The difference from the diagram above is that I have not yet added the relay and I have added an LED to the output to give a quick visual indication of the level. Also the whole circuit is currently running off 3x1.5v cells, rather than a 5v regualtor.

So, did it work? Alas not quite. I could start the loco moving, but attempting to apply any speed would result in the loco stopping with the PWM output reset to zero (confirmed by the extra LED, so not a chassis problem).

There are 2 possible reasons I can think of for this. Firstly would be noise from the motor affecting the microcontroller, which could be cured by capacitors (not too large, as the whole idea is a nice square wave output), or even an opto-isolator.

The other reason however could be just that when the loco runs it is taking too much from the battery that the voltage falls below what the microcontroller can operate with and it resets itself - as this is the easier to check I will first try either new batteries or a larger voltage plus a 5v regulator.
Neil

T gauge items in my Shapeways shop http://www.shapeways.com/shops/t450
NeilM
 
Posts: 181
Joined: Thu Nov 14, 2013 9:46 am
Location: North Yorkshire, UK

Re: My PWM controller using a Picaxe microcontroller

Postby PolarExcess » Wed Dec 11, 2013 1:40 am

Cool project!

Any new developments?
User avatar
PolarExcess
 
Posts: 43
Joined: Fri Dec 06, 2013 3:09 am

Re: My PWM controller using a Picaxe microcontroller

Postby NeilM » Wed Dec 11, 2013 4:25 pm

Alas I have not even had chance to get this off the shelf since just after my last post. I have been studying for a professional exam which has been taking up all my time. I took the exam yesterday (and passed). Once I have managed to clear all the other jobs that have been backup up during this time I do hope to get back to this very soon, and hopefully get more activity on the forum, even if it is only questions to begin with.
Neil

T gauge items in my Shapeways shop http://www.shapeways.com/shops/t450
NeilM
 
Posts: 181
Joined: Thu Nov 14, 2013 9:46 am
Location: North Yorkshire, UK

Re: My PWM controller using a Picaxe microcontroller

Postby PolarExcess » Wed Dec 11, 2013 4:40 pm

Neil\M,

Well done on passing your professional exam!

The forum currently seems like a ghost town! :shock: I look forward to your forum contributions and reading about your interesting Picaxe development.

NeilM wrote:Alas I have not even had chance to get this off the shelf since just after my last post. I have been studying for a professional exam which has been taking up all my time. I took the exam yesterday (and passed). Once I have managed to clear all the other jobs that have been backup up during this time I do hope to get back to this very soon, and hopefully get more activity on the forum, even if it is only questions to begin with.
User avatar
PolarExcess
 
Posts: 43
Joined: Fri Dec 06, 2013 3:09 am

Re: My PWM controller using a Picaxe microcontroller

Postby NeilM » Fri Dec 13, 2013 2:50 pm

Good news on this controller, I finally got it working last night. All it needed was a tiny 220nf capacitor.

I had bought this at the Wakefield model railway exhibition almost two weeks ago, but had not had chance to try test it. Fortunately when I did this proved to be all that was needed.

Currently the circuit is still on a breadboard with bare wire ends to touch together rather than switches and all connected with crocodile clips. It also does not yet have the relay fitted so as yet I can not reverse the loco - which makes it tricky to test on 3 x 60mm lengths of track. However I did also buy copper clad stripboard, relay, switches, battery pack etc at the exhibition so I should now have all I need to assemble the circuit fully and permanently, and also in a box, so I can use it when I get round to ordering some more track and start building a layout (which will be after Christmas now).
Neil

T gauge items in my Shapeways shop http://www.shapeways.com/shops/t450
NeilM
 
Posts: 181
Joined: Thu Nov 14, 2013 9:46 am
Location: North Yorkshire, UK

Re: My PWM controller using a Picaxe microcontroller

Postby PolarExcess » Fri Dec 13, 2013 4:53 pm

Sounds like good progress. Your project is closer to becoming a reality.
User avatar
PolarExcess
 
Posts: 43
Joined: Fri Dec 06, 2013 3:09 am


Return to T Gauge General Discussions

Who is online

Users browsing this forum: Google [Bot] and 2 guests


cron