Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Parallel Port Model Railway Throttle

Status
Not open for further replies.

stevenh

Member
Howdy all,

I've been tinkering with Parallel Ports recently. I've managed to control LEDs from My PC, Amiga 1200 and Commodore 64 using the ports available. This was my first step on the project. Second was to control a 74HC595 to multiplex and get more outputs.

Third has been to integrate a 12v throttle. Now, I've previously done Arduinos and have played with L298s to send out voltage, even DCC. This time around I want a throttle with notches, displayed with LEDs. My thoughts initially were to use the 8 outputs of a 595 to control the resistance into a simple 12v throttle.

I've come unstuck with the collector pin and how to use the digital output of the 595 to control the transistor.

The throttle circuit I've tried to integrate with is: http://www.talkingelectronics.com/projects/ThrottleMkI/Throttle.html
My current circuit looks like: http://modelrail.otenko.com/electronics/shift-registers-for-the-parallel-port-interface

I was hoping if someone could help me bridge the gap. On the base of the transmitter I'm trying to replace the potentiometer wih a resister in series from the 595. I assume I'll also need a transistor in there too?

595 digital out pin would go to the base pin of a lesser transistor which would have specific resistor on either side, being one of the steps-of-eight on my throttle? I don't quite know which transistor to choose for this?

Please see my hideous drawing attached.

All help is greatly appreciated.
 

Attachments

  • trial-stepped-throttle.png
    trial-stepped-throttle.png
    19.9 KB · Views: 184
Are the eight bits to be used to generate eight throttle steps (not necessarily all equal), or are you trying to make 256 steps (2^8=256, as in a digital to analog converter)?

Can the ground of the (computer) be tied to the negative of the DC power supply that is running the train layout, or do you need some sort of isolation?

What is the full-speed track voltage?
Is it DC?
What is the full-speed locomotive motor current?
How do you ultimately control the track voltage?
 
Last edited:
MikeMI,

Thanks for the response. The N Scale enines use around 1A peak when starting, less when running. Output voltage would be max 12v DC.

I was only hoping for 8 steps. As for equal or not, I was going to experiment with resistance values between 0 and 5k to emulate the potentiometer in the original circuit.

Ground is indeed tied through. Apologies for not drawing that in the crappy diagram.

I tried to research digital to analog converters, but didn't get very far. I need the least amount of work from the controlling CPU as I expect to be busy reading inputs instead of controlling voltage and outputs. But that was regarding having to output a pwm signal. Maybe a digital to analog requirespecially less cycles to keep running.
 
Id go with pwm, using Hardware Pwm has internal circuits so only cpu usage is when you make changes, but that happens with everything else too. just make sure to use the pwm pin!

then, no shift register, yes extra transistor, maybe some resistors ...but i am bad at transistor math...
 
The more I think about it... the easier it'll be to just use an off-the-shelf motor controller (for Arduino and the like, with an L298) instead of the previously linked throttle.
I am only guessing that the 595 with a selection of resistors on the 8 output pins will be able to control the enable pin on the L298. Will tinker next week when back at the work bench.

update: Seems I might be able to plug a D2A circuit in also: **broken link removed** ?
 
Last edited:
its best to think of the l298 as the transistors, but with pnp as well as npn, and in bridge config, i feel you are complicating things with the extra circuitry past that with d2a and such, i really liked the l298 since it takes all the transistor math out of things,

using the l298 you just make input1 = 0 or 1 as your direction! then put pwm on the input2, which will give you the results you want

again using hardware pwm does not take processing time every time you go 1-0-1 , it only requires instructions when changing the pulse speeds or duty cycle
 
From the digital pins of the parallel port, I'd still need to create an analog voltage to control the enable pin(s) on the L298?
Otherwise I'd have 0 or FULL SPEED on the trains :)

Or have I missed an IC somewhere that does hardware PWM?
 
Hy stevenh,

A circuit to do what you want would be straight forward but if you are you going for a bought system please let us know so that we don't waste time finding a solution for you.

spec
 
The simplest, cheapest solution is to use one of these.
Take four bits of from your parallel port and hook them to four input pins of the Arduino mini. Encode 15 progressive speed values, 0001-1111) into the four parallel port bits. Use the 0000 value to represent stop.

Write simple Arduino code that converts the four port pin values into 15 different PWM duty cycles at the pwm'able port pin. Detect 0000, and use that to turn off the pwm.
 
The simplest, cheapest solution is to use one of these.
Take four bits of from your parallel port and hook them to four input pins of the Arduino mini. Encode 15 progressive speed values, 0001-1111) into the four parallel port bits. Use the 0000 value to represent stop.

Write simple Arduino code that converts the four port pin values into 15 different PWM duty cycles at the pwm'able port pin. Detect 0000, and use that to turn off the pwm.
Wow- you can get an Arduino compatible board for £1.87. :cool:

spec
 
I completely agree that going via an arduino would be the easiest... could even SPI to it and just write my own language to control it.

My goal though is to build a more simple circuit for railway control and do all the coding on the host device.

Current circuit is outputting 0-5v via an LM358. Commodore 64 and PC ports both successfully making this happen.

See here. https://modelrail.otenko.com/electronics/parallel-port-digital-to-analog

Next is to use the 5v to control an L298 module for the arduino. This is to speed up the prototyping. Final board will be integrated.

The initial point of this thread was to see if the 5v from LM358 could drive the throttle circuit from talking electronics.

From my own investigations... I think I've worked out that, with 5v in to the BD681 transistor that you'll ever only get 5v max out on the output rails. I.e. even with 12v feed into the opamp it will only help it produce a cleaner 5v and therefore my whole original idea would only produce 5v throttle.

Hence the use of the L298.

Thank you all for your help.
 
I think it would be a lot better and simpler to build your own circuit to fit between the computers and engine.

spec
 
...
My goal though is to build a more simple circuit for railway control....
If you want to roll your own, you still have three tasks: 1. build a Digital-to-Analog converter, 2. Build a circuit that converts an analog voltage to fixed frequency Pulse Width Modulation, 3. Drive the tracks (DC brushed motor) with higher voltage/high current to make the train go.

I described how to do #1 and #2 very simply/cheaply in one little board. Your linked method of doing #1 is a Kluge. Here is what it takes to do #2 (notice the parts count). The L298 module is about the worst, most inefficient way of doing #3.
 
l298 has opamp in it , i may be wrong, but i think that means on or off only, no half voltages, the trick with the pwm is that ya its on at full power , but its only on for fraction of the time , therefore only fraction of that power is converted to motor energy over time
also you want flyback diodes for L298, idk if optic isolation is good replacement, see datasheet for compliment IC's, plus in that circuit the 595 is not protected

if you have the 595 circuit in place already , multiplexing it with a r2r ladder will create 256 combinations, plus your leds will display in binary coded format...

here is another simple pwm circuit:
http://www.555-timer-circuits.com/images/MotorPWM.gif
with that you can tie in resistors in parallel, not r2r, to get 8 options, and tweak each accordingly to desired pulse length,
replace the 1k resistor in "my" circuit with alll the yellow output resistors from 595 in parallel(only drew 3 of them) and dont tie to vcc
you dont really need true pwm, so dont bother with diodes in "my" circuit, at the input side only!
replace the 5k resistor of your choice, this will effect weight of each preceding resistor and overall pulse times...
here is better details & circuit about 555 timers, along with calculator:
http://www.ohmslawcalculator.com/555-astable-calculator
you are mostly interested in duty cycle and frequency vs RC values

12798.png MotorPWM.gif
 
Ok, just to play devils advocate, the final output to the rails is more complex than just using PWM. The lower range requires a PWM signal with a higher amplitude. Once the train starts moving, the amplitude should drop down and the PWM signal should produce an average voltage level just enough to keep the train moving and which is then manipulated to accelerate the train. Then once at a certain speed, the power should be pure DC. The motors and gear train in MRR environment operate best this way. Also, are you planning on driving more than one locomotive with the PC, et.al.? I do not necessarily mean at the same time. Like run a BL3 for a while, then an SD45? Because each model engine has its own characteristics as to when the above phases should occur.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top