Using existing code with different input

Hello everyone.

My first post here and a start to what may become a very exciting change of paced for me.

Let me explain what I am trying to achieve.

I have a stand alone DC controlled model rail layout which has an analogue shuttle controller which moves up to 3 trains between sidings each end. Each end has two sidings. The analogue controller has a programmed device which controls which polarity voltage is applied to the track and when.

It also controls the point (switch) motors to ensure the correct siding is selected. This all works well and with the exception of the point (switch) motors I do not want to change anything.

The switch motors however are not fantastic being basically solenoid operating on a push pull basis depending on which winding is activated. There is real room for improvement here. SG90 servos are being used in model railways a lot these days and this is the basis of the direct I would like to take.

LittleWicketRailway (LittleWicketRailway (Little Wicket Railway) · GitHub) has kindly written some code that does a lot of what I need to do, however it uses an external piece of software to operate the SG90 servos. The code is here: ServoControl/Servos.ino at master · LittleWicketRailway/ServoControl · GitHub

What I would like to do is replace the JMRI interface and use the input pins (Digital or Analogue) to control the activation of the appropriate servo.

The control module mentioned earlier uses a Capacitor Discharge unit to drive the existing motors. This is basically a pulse of positive going DC, say up to 12V. There are two lines per point motor plus a combined ground. So to move the point motor/solenoid in one direction it fires on line 1 (coil 1) and then to move the point back it fires on line 2 (coil 2).

I am not sure how to do the next bit, monitor the output from the controller module and set the SG90 to either of its two predetermined end stops. I realise that the inputs will have to have something like a 5V1 zener diode across to protect the input from excess voltage.

How do I translate those inputs into something useful?

Any pointers welcomed...I am very much a beginner and really need help here!

Thank you

Jon

To be honest your story is not very clear.
A few drawings would help. How is it wired now?
What would you want to change?
What would you like to keep?
An sg90 needs 3 wires. One plus, one gnd and one control. You will need a controller to generate a pwm signal. Will that controller have inputs? Buttons? Or a train passing by? Or a time schedule?

1 Like

Hi build_1971. Understood!

The attached picture is a screen grab from the controller pdf. Each "point motor is a dual coil solenoid. The solenoids are fired by a discharge from a capacitor circuit. To change the direction then just one of the coils are briefly energised. The trick I am trying to achieve is to take that output and use it to activate the code mentioned in the first post...

BW

Jon

What kind of arduino do you plan to use?
What kind of power supply is used to feed your board?
I guess you could feed arduino and servo from that supply.
You can use a voltage divider to go from 12v to 5v.
You could add schottky diodes to clamp the voltage to ground and 5V. You can then send the signal to an input pin. For the servo you should use a servo library. I guess such a library should be available for any board from the IDE. Take an example code from the library and see if you can make the servo move up and down. Later add the reading of input pins and then put the logic together...
Should not be too hard...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.