# Switching relays but having power feedback from 5v transformer

I have attached images for reference to hopefully make it easier to understand. First image is zoomed out to give overall perspective of panel. Second is zoomed in with boxes drawn around the areas of interest.

Problem and my solution:
I need to convert a 6 bit parallel signal (bock E) into a number to use in custom written software so I have decided to use relays (block A) to switch 5v (block D) and use that as input (block B) on an Arduino and then convert the 6 bit parallel bus into a number and send it over serial to the PC (not connected in the attached image) i.e. the values range from 0-63 (000000 to 111111). I have used the internal pull-up resistor of the Arduino so that I don’t have to create an additional circuit with pull-down resistors. WHich means my output is inverted, but of course I can just handle that in code in the Arduino. Because I am using the internal pull-up resistor I have connected the ground from the 5v power supply (block C) to each relay on the 5v side and then to the ground of the Arduino. The power supply on the 5v side is a transformer that brings 220v AC down to 5v DC to use as input on the Arduino.

Specific problem/question
The relays switch fine when the signals switch on the 24v side and they can be triggered up to 12 times per second). I have noticed that when they switch the 5v side it doesn’t drop the voltage fast enough to trigger the input. When I switch the power off the transformer power led still stays lit for about 3-4 seconds, which is expected. My thought process is that the voltage doesn’t drop fast enough on the 5v side because it’s drawing feedback power from the transformer when the relay opens. Does this sound correct? I have seen others use ‘one-way valves’ for a lack of a better description which stops power being sucked back (wow, great technical talk there aye! :().

My questions are: 1. Could this be the problem? 2. how would I build a circuit to stop this? I have seen people use transistors to achieve this, but I’m not entirely sure how to start on this one. I’m more of a software guy with SOME electrical knowledge (as in I know what a resistor is and I know watts = voltage x amps :P) and I can fake my way around an electrical diagram pretty well enough to not be detected,but I can’t design circuits (yet).

We/I really need a schematic drawing in order to visualize the circuit.

LarryD:
We/I really need a schematic drawing in order to visualize the circuit.

And of course the (whole) code, and the specification (weblink) of the "relays". I note it is a commercial model so it no doubt is appropriate - it rather looks like "solid state relays" which would of course, be the better option for this task.

I am not sure what your problem actually is - you refer to "dropping fast enough to trigger the input" which is not meaningful - the Arduino inputs are level triggered, either the input is low or it is not.

If you can supply all that information and the code and explain just what is happening that you do not like, we could be "in business".

Thank you for the quick response guys! I wired it all up based on the design in my head. When I now drew up the schematics I see where I went wrong. DOH!! I didn’t even need the external power source, the arduino uses the power source from the USB connection so I can wire the INPUT directly from the 5V power source on the arduino via the relay. I’ve attached the fritzing schematic.

I’ve just used the 24v source to indicate the 24 volt pulse. So the end result I need? A 5v input whenever the 24v goes high. Does this seem good?

I’ve just drawn up the schematic for a single relay, but it will be multiplied 6 times of course. Here is my Arduino code:

``````/*This sketch has takes 6 digital inputs that represents a binary value
and converts it to a text value to send over serial*/

// constants won't change. They're used here to set pin numbers:
const int ledPin = 13;
const int pin1 =  2;
const int pin2 =  3;
const int pin3 =  4;
const int pin4 =  5;
const int pin5 =  6;
const int pin6 =  7;

//variables
int binary1 = 0;
int binary2 = 0;
int binary3 = 0;
int binary4 = 0;
int binary5 = 0;
int binary6 = 0;

String s = "";

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pins as an inputs:
pinMode(pin1, INPUT_PULLUP);
pinMode(pin2, INPUT_PULLUP);
pinMode(pin3, INPUT_PULLUP);
pinMode(pin4, INPUT_PULLUP);
pinMode(pin5, INPUT_PULLUP);
pinMode(pin6, INPUT_PULLUP);

Serial.begin(9600);
}

void loop(){

// read the state of the inputs
//send serial output as binary string with line break as end char
//ie output will be something line '000101'
Serial.print(binary1);
Serial.print(binary2);
Serial.print(binary3);
Serial.print(binary4);
Serial.print(binary5);
Serial.print(binary6);
Serial.println();

delay(250);

}
``````

Hi, question, how fast are you turning those relays on and off.
Why not use an optocoupler, noiseless, not mechanical so it will not wear out and also reliable switching characteristics.

Tom.....

There's something seriously wrong with your circuit diagram

jackrae:
There’s something seriously wrong with your circuit diagram

There’s more than one thing seriously wrong with your circuit diagram and I invite you to supply the third detail I requested as well.

Hi,
I think you will have to do a better diagram than that.
I’m surprised that you are doing such a level of control circuitry, yet do not have a proper circuit diagram.

What level of programming, hardware and electronics experience do you have?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom…
PS still have no idea what your application is for…

I'd suggest you give us the details of the parameters of your parallel data (voltage levels and any control signals you may have). I'm sure most people that post on this forum would be able to come up with a more practical solution to your problem.

TomGeorge:
Hi, question, how fast are you turning those relays on and off.
Why not use an optocoupler, noiseless, not mechanical so it will not wear out and also reliable switching characteristics.

Tom.....

Thanks for the feedback. It just happened to be what I chosen while under pressure to deliver a workable solution. I agree that opto-couplers would be more suited for the reasons stated Hindsight is of course 20/20

jackrae:
There's something seriously wrong with your circuit diagram

Thank you. This might be the point where I admit I might be a little out of my dept with this one?

Paul__B:
There's more than one thing seriously wrong with your circuit diagram and I invite you to supply the third detail I requested as well.

Sorry Paul. Feeling like a super noob here...well justified it appears. My focus and experience is software development and I am trying to assist a customer to integrate a printer with an egg grading machine. I've got it all waxed except for this part. The manufacturer of the egg grader has no interest in helping out so I have managed to drag all the necessary electrical and technical information out of them and doing myself.

Let me try explain in better detail.

I am connecting to a board that outputs 6 x 24v signals. Each on a seperate line. Together they form a binary representation of a decimal number (so in other words if the first 3 lines go low and the last 3 high, it represents 000111, which in turn represents the decimal number 7). I need to use the number 7 in custom written software to do stuff (not relevant here). My solution is to use the Arduino purely to take the 6 parallel bits and transpose it to a decimal number my software can understand and then act on.

I can swap the relays for opto's once the solution is in place, for now, I just need to get the wiring sorted to read the signals in the Arduino so that I can send it to my software.

Do all of the 24v signals share a common ground? If so I’d be inclined to just connect that common ground to the arduino ground then pass the signals through a couple of resistors to divide the voltage. It would work a lot more effectively than a whole bunch of relays chattering about.

TomGeorge:
Hi,
I think you will have to do a better diagram than that.
I’m surprised that you are doing such a level of control circuitry, yet do not have a proper circuit diagram.

What level of programming, hardware and electronics experience do you have?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom…
PS still have no idea what your application is for…

Ok, super noob here… why not Fritz? … it prob sounds like I want to be spoonfed. I promise this is not the case! I do not want you to tell me what to do step by step. I will be happy if you just point me to somewhere that can assist me to work out the solution myself. (except going to study electronics if at all possible, for now anyway) …

KenF:
Do all of the 24v signals share a common ground? If so I'd be inclined to just connect that common ground to the arduino ground then pass the signals through a couple of resistors to divide the voltage. It would work a lot more effectively than a whole bunch of relays chattering about.

Now where is that smiley that slaps his own forehead ?!

DOH!!

Ok, thank you KenF!

KenF:
Do all of the 24v signals share a common ground? If so I'd be inclined to just connect that common ground to the arduino ground then pass the signals through a couple of resistors to divide the voltage. It would work a lot more effectively than a whole bunch of relays chattering about.

Sorry.. I didn't answer your question.. yes all the 24v signals share common ground.

I'd love to understand why I can hookup the 24v ground to the 5v arduino and it's still ok and doesnt blow anything. Where can I find more on that?

All things are relative.

Imagine the roof of your car has had the paint scrubbed off. Now place a little button battery on the roof of your car. Now attach one leg of an LED to the top of that button battery and the other leg down beside the battery so that it's touching the roof of the car. This will complete the circuit and the LED will light up. Do you think that LED gives a flying fig about the 12v battery sitting under the hood? If it did it would blow without a doubt. All it sees is the voltage given out by that little battery.

davecoates:
I'd love to understand why I can hookup the 24v ground to the 5v Arduino and it's still OK and doesn't blow anything.

It should be OK given a couple of things.

You need to use a "star" grounding arrangement with all the ground connections coming to a single point. What you are avoiding is two things, the possibility that if any ground connection became disconnected, it could cause excess voltage to be applied to any particular piece of equipment, and the likelihood that if a particular "ground" wire is carrying substantial current, other "ground" wires connected to it at different places would experience different voltages. You can have more than one "star" point given that these criteria apply strictly to the wire connecting the two hubs.

It may not be easy and you have to look closely to visualise all the permutations, but if you apply those criteria rigorously, you should be OK.

Thank you for your patience guys! I am putting a PCB together with a voltage divider for each 24v signal like KenF suggested. Much much simpler solution. Doh! I'd like to financially contribute to a project for each of you if I can to say thank you. for the time and energy spent helping.. Could you please let me know how I can do so (pm ok)