Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

Below I have the following (simplified) circuit:

Relay Monitor

What I want is to measure (monitor) every time the relay switches on and off. The pulse is around 3V and for 32ms.

The problem is that the voltage is reversed, to switch off the relay (single coil latching), and I have no idea how to wire it correctly up with my Arduino.

One solution (not sure) I came up with is to use 3 wires. If I hookup GND with (Arduino) GND, and the A and B wires go both to its own port (with some pull-down resistors) on the Arduino.

I think it should also be possible to hook-up with only 2 wires (just A and B)? But, if I hookup A/B directly on the (Arduino) input ports, I'm basically hooking-up GND, that doesn't seem right.

share|improve this question
    
Be aware that hooking A & B to am MCU port may damage it as the back-EMF from the relay coil can be quite large, and relying on the protection diode is not a good idea. Using a cheap opto-coupler (4n25 etc.) would be better. If you're "hooking up ground" to a pin, you should add a pullup resistor (~1-10k). If S1 is really ganged as illustrated you only need to measure ONE leg (A or B) as you know that one must follow the other. –  John U Mar 18 at 10:13
    
Why are you trying to wire up through this two pole three position switch. That makes no sense, particularly in one position you would be setting the 3.3V supply shorted in forward bias across your clamp diode. Correct this conceptual problem and you'll reduce your measurement problem to a single wire with a single polarity. –  Michael Karas Mar 18 at 10:16
    
S1 is just to illustrate the 'polarity' switching. There is no manual switch. The circuit switches the motor ON or OFF. For OFF the relay is using reversed polarity. I like to measure both states ( i only need the pulse, so the MCU knows the motor is ON/OFF). Not just one. I imagine that it would be better to use a interrupt on the MCU, so it doesn't need to pull the state. I'm aware of the spikes that the relay could trigger, thank you. –  Rogier Mar 18 at 10:37
    
Can you connect an opto-isolator to the spare leg of RY1 (if it really has a spare leg) to take a 24v input, that way you know directly what the relay state is without having to keep count. –  John U Mar 18 at 10:52
    
@JohnU yes i think that could work. However, that means i need to pull the state? I rather have a interrupt setup on my MCU, so i can wake-up my MCU and just register its state. The MCU doesn't need to be idle when the engine is running, its just basically writes the time when it switches on and off. Later, i can the determine how long (and when) the engine was running. –  Rogier Mar 18 at 10:57

1 Answer 1

up vote 4 down vote accepted

You can use a bidirectional input optocoupler such as H11AA1

enter image description here

Connect the input optodiodes to points A/B with a small resistor in series and drive the AVR pin from the output transistor.

enter image description here

Using this way you have to keep track of the pulses to know the current state.


Here is an alternative, an optocoupler connected to the output of the relay. The output signal will be low when the relay is on and high when it is off.

enter image description here

share|improve this answer
    
@Rogier The use of the diode across the relay doesn't make much sense, it shorts the input in one direction. Note that unless it is removed the optocouple diode with the same polarity will nor be able to conduct since the voltage will be clamped to 0.7v –  alexan_e Mar 18 at 10:26
    
your right. The diode is in the drawing of the relay (not intentionally). I don't think its in there, the relay is a G6CU-2117P-US. –  Rogier Mar 18 at 10:32
    
thank you. How do i see if its a ON or OFF pulse? –  Rogier Mar 18 at 10:40
    
@Rogier You relay is a latching model and there is no diode across the coil datasheet. In order to know the state of the relay you have to keep track the pulses with Arduino. You'll get one pulse each time so the first one means on, the second one off , the third one on again etc. The alternative is to use a unidirectional opamp connected to the output of the relay (24v), that one will show the state of the relay directly, let me add it in the reply –  alexan_e Mar 18 at 10:46
    
Great, you made my day. You got me steered in the right direction. Chapeau! –  Rogier Mar 18 at 11:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.