Go Down

### Topic: Is there away to get a bi-directional current to work with a arduino? (Read 739 times)previous topic - next topic

#### BoomerAUS00

##### May 26, 2019, 07:30 am
Hello all
I've got a bi-directional forward & backwards DC current can you get the Arduino to work in both ways with-out using a bridge rectifier as it needs to have different colour RGB LED setup.

#### Grumpy_Mike

#1
##### May 26, 2019, 07:39 am
What is this "bi-directional forward & backwards DC current", what size is it and where is it's reference with respect to the Arduino ground? Is it a fixed current or does it change in size?

What are you trying to do?

All these matter for a detailed circuit design.

In principle however you use a resistor to turn the current into a voltage and use that voltage to alter the central bias on an analogue pin made from two equal size pull up and pull down resistors.

#### Paul__B

#2
##### May 26, 2019, 07:58 am
Is it related to this?

#### BoomerAUS00

#3
##### May 26, 2019, 07:59 am
It's a 0 to 16V DC power it's for a HO scale railcar.
At the moment I'm just brainstorming of ways I can get the RGB LED's to work with the colours I want & not have to use 3 LED's for just 1 light, to have the 3 colours I need.

So I'm just wondering is it away to do this or not?

#### Grumpy_Mike

#4
##### May 26, 2019, 09:32 am
Quote
So I'm just wondering is it away to do this or not?
Yes it probably, but you will have to do better at saying what exactly you want.
So it seems you actually have a D.C. voltage not a current.
The simplest and safest way would be to use two opto isolators one for each voltage polarity with a protection diode on each.

#### PaulRB

#5
##### May 26, 2019, 10:36 amLast Edit: May 26, 2019, 10:51 am by PaulRB
I think the OP wants to power the Arduino from a power source that can be anything between -16V and +16V because it powers a model train through the rails. The Arduino drives some LEDs which may be signals attached elsewhere to the track, or maybe onboard the train.

My first question would be is an Arduino even needed? If the LEDs are onboard the train and indicate the direction of travel, this can probably be done simply, without an Arduino.

But if an Arduino is needed, then a diode bridge will need to be used to rectify the voltage. But the Arduino will need 5V. When the rail power is less than 5V, it will need to be boosted up to 5V. When it is over 5V, it will need to be reduced to 5V. A DC-DC converter which can boost the voltage up or down would be ideal.

This one claims 3-32V input. However, the diodes in the bridge will drop ~1.5V, so the circuit will only operate when the input voltage is above ~4.5V or below ~-4.5V.

#### Paul__B

#6
##### May 26, 2019, 10:59 am
Most serious railway controllers - short of DCC - would use PWM, so the "minimum" voltage should not be a concern.

I've got a bi-directional forward & backwards DC current can you get the Arduino to work in both ways with-out using a bridge rectifier as it needs to have different colour RGB LED setup.
Isn't that just a classic variant on an XY problem

#### BoomerAUS00

#7
##### May 26, 2019, 11:34 am
My first question would be is an Arduino even needed? If the LEDs are onboard the train and indicate the direction of travel, this can probably be done simply, without an Arduino.
Yeah if it only was a red & white marker light setup then yeah fine but i need red, white & purple & not a lot of room for 6 LED's in the front & i've not even started with the headlight & rear markerlight yet so then 8 LED's all up in the front of a HO scale Railcar.
Not going to happen so i went with a RGB 5mm LED to get all 3 colours so now i need some sort of controller to get what colour i need.

#### PaulRB

#8
##### May 26, 2019, 12:51 pm
Can you please explain in more detail how many LEDs are needed of what colours and in what conditions each led will be on. We are not all experts in model railways.

Also please post links to the controller system you are using. As already pointed out, your idea that the voltage varies between -16V and +16V may not be correct.

HO gauge are small models. How do you plan to fit an Arduino inside?

#### CallCriteria

#9
##### May 26, 2019, 01:10 pm
What do you mean by the bi-directional current?

#### BoomerAUS00

#10
##### May 26, 2019, 01:22 pm
This is what is needed one fits all setup just use a dip switch to change the colour that is needed.

#### PaulRB

#11
##### May 26, 2019, 01:29 pmLast Edit: May 26, 2019, 01:41 pm by PaulRB

So the dip switches set the pattern for each of the two lights at the front of the train: red, purple, white or off. The lights at the rear of the train are both red.

When the train reverses, the lights should swap, so that whichever direction the train moves, the red/purple/white lights point in the direction of motion and the red only lights point backwards. Correct so far?

Question: for the "route 71" pattern, how can you tell if the train is coming towards or away from you? Both lights would be red in either case.

#### Paul__B

#12
##### May 27, 2019, 12:18 am
Ah yes, Sydney trains used to have four lights (red/ white pairs) which identified their current route - but that was some time back.

You could no doubt use simple DIP switches and diodes; you have not indicated what control system you are using but it clearly is not DCC - the LEDs will vary in intensity (and colour) with voltage applied.

An alternative would be to use an Arduino and WS2812 LEDs.

#### BoomerAUS00

#13
##### May 27, 2019, 12:38 am

So the dip switches set the pattern for each of the two lights at the front of the train: red, purple, white or off. The lights at the rear of the train are both red.

When the train reverses, the lights should swap, so that whichever direction the train moves, the red/purple/white lights point in the direction of motion and the red only lights point backwards. Correct so far?

Question: for the "route 71" pattern, how can you tell if the train is coming towards or away from you? Both lights would be red in either case.
Yes you are right, that's what I 1st did setup the 3 LED's & join them together with alfoil & fibre optic to give the 1 light and using a DIP switch to change the colour, but that is way to many LED's as it would be like 8 LED's just setting at the front of the railcar, as 6 for both marker lights 1 for the headlight & the last is for the red marker lights.
For the route 71 & all other routes you have the headlight on to know what it what.

#### BoomerAUS00

#14
##### May 27, 2019, 12:55 amLast Edit: May 27, 2019, 12:59 am by BoomerAUS00
Ah yes, Sydney trains used to have four lights (red/ white pairs) which identified their current route - but that was some time back.

You could no doubt use simple DIP switches and diodes; you have not indicated what control system you are using but it clearly is not DCC - the LEDs will vary in intensity (and colour) with voltage applied.

An alternative would be to use an Arduino and WS2812 LEDs.
Yes it is 100% DC I can't give you the name of controller system as they run on more then 1 layout, as we have a group we go to every 2 to 3 weeks & also my own little testing loop.

PS why use WS2812 LED strips when i've get RGB 5mm 4pin LEDs that do the same thing.

Go Up