# Noob seeking circuit advice - if 0v then 2.5v otherwise 0-5v

Discussion in 'Microcontrollers, Programming and IoT' started by glyndavidson, Jul 25, 2018.

1. ### glyndavidson

6
0
Jul 25, 2018
Hi all,

I have a 0-5v variable signal. I'm looking for a device that can perform some logic operations. Basically, I want to create a circuit that passes the variable signal without modifying it, except when 0v is received I want to output 2.5v instead.

To give you some background info...

In simple terms, I'm using a potentiometer to control a motor via a controller.
2.6-5v turns the motor in one direction.
0-2.4v turns the motor in the opposite direction.
At 2.5v the motor stops.
This is being operated via radio control.

The problem is that when you turn off the radio control, the motor controller receives 0v which makes the motor go full speed in reverse (and has caused a number of "accidents"). Instead, when the remote is switched off, I want the motor to stop too.

In my mind, it's a simple logic gate that says:

If inputA == 0v Then
output 2.5v
Else
output inputA
End

But I don't know how to achieve this with electronic components.

2. ### WHONOES

1,115
310
May 20, 2017
Why don't you simply turn the motor circuit on and off from the transmitter then it is safe.

3. ### glyndavidson

6
0
Jul 25, 2018
That is essentially what I'm trying to achieve. Except that instead of having a switch on the transmitter, I want it to be automatic, i.e. as soon as no input is being received from the transmitter then turn off the circuit.

Actually, I think I could achieve that with a simple AND gate?

Circuit on/off switch is 48v (low amps)
"Throttle" is 0-5v

Is there an AND gate that I could add as a switch to the existing circuit on/off switch?

If Circuit==48v AND Throttle>0v Then
Output 48v
Else
Output 0v
End

6
0
Jul 25, 2018

1,115
310
May 20, 2017

6. ### glyndavidson

6
0
Jul 25, 2018
Very simplified version of the circuit:

7. ### glyndavidson

6
0
Jul 25, 2018
What I think the solution should be (addition of AND gate):

8. ### Bluejets

4,652
982
Oct 5, 2014
Many transmitters have a fail safe option where the receiver will go to a pre-set setting ( almost anything you want) once signal is lost.
As an example in modern gear is the return-to-home feature.
Might get you started on the right track with that in mind.

I'll include a link to a video where this was done using a \$60 transmitter.
Might be a cheapie but I've used a couple of them now with good results.

9. ### WHONOES

1,115
310
May 20, 2017
You could use an analogue switch such as the DG419 which is 2 switches with a common output. The enabled switch depends on the state of a logic input. You could then use one switch for normal operation and the second to supply 2.5V to the motor controller when the input is 0V. You may need some extra circuitry to achieve the logic switching. The 2.5V could be just a potential divider on+5V supply.

http://www.farnell.com/datasheets/2...363.36129247.1532527292-1348248471.1485605443

10. ### Kabelsalat

154
28
Jul 5, 2011
The problem you have is doable using opamps, logic gates and discrete components. The problem with "0 volts" is that it is hard to detect excactly 0 volts (*). But if you have access to a negative voltage supply, then you can easilly make a opamp scmith-trigger to detect a voltage close to 0V.

If you want to save space on pcb maybe an analog muxer is way to go. Othervise, voltage follovers with a couple of serie resistor in feedback loop may be "disabled" simply by adding a bjt betwen the serie resistors - just remember to select enough voltage because when one such stage is disabled, it still have output impedance.

* You probably don't want it anyway since you're using a potmeter as input source.

11. ### WHONOES

1,115
310
May 20, 2017
Having had a further think, the problem is not as simple as at first seems. Every time your motor control goes to 0V in normal circumstance, what ever method you use to prevent the motor running when no signal is received from the transmitter, will be invoked.
How are you receiving the transmitter output?

12. ### Alec_t

2,940
799
Jul 7, 2015
Does that mean the closer to zero the faster the motor? If so, as Whonoes says, the problem ain't simple to solve.

13. ### Bluejets

4,652
982
Oct 5, 2014
No one likemy suggestion or is the op talking about some strange rc unit from planet Zork?

14. ### glyndavidson

6
0
Jul 25, 2018
Thanks all for your advice. Have solved the problem with an Arduino and DAC breakout board.
Your idea does sound like the easiest though Bluejets and I've ordered the USB cable so that I can see if I can program a failsafe. In the meantime, the Arduino seems to be working fine though and will give me more options in the future. Thanks again everybody.