I want to detect when a physical switch for a high voltage supply is on or off. I realise that a DPDT switch would solve this but I don't have one.
I have a feeling that connecting a digital pin to arduino ground through the same switch legs would be a bad idea even though the circuits would otherwise be isolated.
The correct way is to connect and measure the voltage across the output terminals, not the switch. You can't just use the switch alone, regardless of the presence/absence of battery power because any sensing circuit conducts some current and thus isn't safe because it powers the load with a trickle of current. You also need to know, if the output circuit and the Arduino can share a common ground. If not you need an optoisolator circuit.
The circuit as shown would explode the Arduino.
Another approach is to have the Arduino control the output circuit via a relay, and then connect a controlling switch to the Arduino.
Also, you didn't provide enough details generally... it's just a hypothetical stripped down circuit and you're forcing us to guess what it really is.
Consider the example of a light bulb connected in parallel with the output circuit. It's on when the switch is on, off when the switch is off. That senses the switch position.
The circuit is not to measure voltage. I just need to know when the switch is open or closed so it would be the same as a button or switch input pulled high on the Arduino.
Ideally I would have a double pole switch so when it closed it would open the output on the high voltage circuit and close the switch on the arduino at the same time.
Great. Now please respond to my other points. By measuring voltage you can detect thresholds like on/off. You don't necessarily need the value. That is not what I meant.
Also you're floating a DPST solution without telling us whether it's acceptable to you or not.
I would suggest you use an opto Isolator across the load. You will need a resistor in series with the opto isolator. The output would go into a digital input.
You should put the opto across the output and not the switch. The reason is when the switch is open there is an expectation that the load is not connected to anything. Adding a load across the switch will still provide a path to the load when the switch is open. I agree the path is lower current but it is still a path that should not be there.
Yes, I need the microprocessor to know if the switch is on or off, that is all. The issue is whether connecting it to the same switch legs which would carry the high voltage and current would blow the arduino pins
That would not affect a parallel voltage sensing circuit. It would still reliably detect the switch position.
You need to look at some tutorials about series and parallel circuits.
A "suitable" opto for this application would be 99.9999% of them. One small catch - it will draw some current when the switch is on, regardless of whether there is a load connected.
You may not need an opto if you can use a common ground, you never replied about that... in fact that configuration would use less battery current if you're worried about it.
No worries, if the opto is connected across the "output" and the switch is open, no current will flow through the input of the opto and it will indicate "OFF".
Where would you purchase your opto? A US distributor, UK distributor or ebay?
The concept is opaque without knowing how it operates.
Some minutae - If you need the Arduino to provide the setpoint control voltage, you will need to share a ground with the "control circuit" and since it is grounded, also with the output GND.
It has been explained, that a sense circuit would pass a leakage current - we are at a loss until you answer whether that is okay. Your diagram certainly differs from the suggestions that have been offered, which detect the output voltage.
Come on, this discussion will be 1000% more productive if you explain what this thing is supposed to do. We're already on post 14 and not making much progress.
However, I can see this much, that voltage detection won't work since the MOSFET can turn off the 50V supply to the output.
This issue seems like an "XY problem" where someone asks about how to do X, when it is really Y that provides a solution. The fixation on X prevents them from achieving a solution.
You still haven't answered the question that I asked you about the switch, back in reply #4.
The crux of it is this - if the switch is open circuit, why would any change to the control circuit be necessary? In that case, the entire circuit is idle, since the MOSFET is not driving anything at all. That is what would befuddle and consternate any sane engineer. Thus it's obvious that you are either not telling us important information, or you are seriously deluded.
Apologies for not being very clear, and thank you for your patience.
I was just trying to distill down to the actual crux of the issue, but I can see I have only introduced ambiguity without context.
So, the whole circuit is actually a two channel variable supply. The two channels are identical so the issue is the same for both.
the input comes from rectified 50V 6A DC on each channel.
The control circuit is an analog circuit measuring high side current and voltage through sense circuits. OPAMPs pull the MOSFET gate low to allow for current limiting and voltage control to assert dominance as required. The setpoint for both current and voltage is provided from the Arduino through an ADC at 2.048V with gain set accordingly.
A DAC also measures voltage and current but only for UI LCD display purposes.
The only other control the Arduino has is a temp sense circuit for the MOSFETs which use a transistor to pull the gat low if exceeded as a safety feature.
What I want to be able to do is sense when I have used the physical switch to turn the output on for possible future upgrades for data collection
Under those conditions, I would suggest the DPST switch. This assumes that your data collection doesn't care whether the unit is powered from 50V or not.
If, on the other hand, 50V is always applied to the circuit and you are only collecting data under those conditions, you could use the voltage monitoring method because the output voltage is always on when the switch is on.
Thank you, I think buying new switches may be easier in this instance. No the data collection would only be initiated by the switch, reading would come from the DAC still.
I had a feeling that I may need some kind of opto-isolation, but previously I have only used them for logic level to PLC switching.
I am considering optocouplers between the ADC / DAC and Arduino as well
Here as I only want to measure switch state I wasn't sure it would work.
Well the DAC would still read 0-50V if a load is connected but the switch isn't on. my thinking is that I recording of data could start automatically when the switch is on and power delivered to the load.
Maybe I am really overcomplicating it.....
I think I will go with the DPST option, but out of interest could an optocoupler work in this instance?
You still need to put the sense on the output. You seem to have an aversion to moving the sense, is there a reason you seem to be stuck on sensing the switch?