relay control

I'm a noob here to everything that's electronics and programming, I'm a mechanical engineer and a little used to plcs, so you get the point, electronics is not my forte.

So I have this little project driving me insane at work, I need a vacuum loader to open a valve 4 times, close, then open another one and run a motor for x amount of seconds (last valve and motor must run together)

Valves are 24vdc and motor is 120vac

The maintenance guy already had an arduino he doesnt need (arduino uno r3) so i went ahead and bought the components i need (or think i need) to make the small relay board. Im planning on running everything off of the 5 vdc so i went ahead and got 2 x 5vdc, 24vdc relays and 1x 5vdc, 120vac and their diodes (1N4004), 1k ohm resistors and transistors (2n2222).

Right after I assemble the board I'll fiddle with the program.
this being said, can I plug the base of each transistor to any three digital pin I want? keep in mind that the last 2 relays I want to control at the same time so I'm not sure if those 2 should be plugged into the same digital pin.

I know I have to use the 5v power pin to supply the relay board but, how do I power all 3 of them? just plug all three to that same power pin???

Please bear with me, I've run the very basic 1 relay circuit to power LEDs and big light bulbs, so I don't really know how to handle 2 or 3

Thanks,

the project does not sound complicated.

programming the unit uses the same concepts of all programming.

it only does what you tell it, and in the order you tell it.

open valve 4 times

open other valve and run motor for x seconds

very simple. but I figure you did not describe how or when to start, if there is an emergency stop. and such.

for hardware.
120VAC power
5 volt power supply.
24vdc power supply
and another power supply for the arduino

you need all three power supplies, you cannot use the arduino as a power supply for the relays.
you should not power the arduino from the 5v power supply that will power the relays.

the relays have to parts. the load side. the load side does not know voltage, only amps. too high and it burns up. no other limitations.
the coil side is very particular. since you said you have 24vdc relays, you need to have 24vdc power in order for them to turn on and off.

the last piece of the puzzel is the signal. many people get the coil voltage and the load voltages mixed up.

if you were asking where to start, we would say to get one power suppy, 12 volts.
get all relays in 12 volts. the reason is that you can power your arduino from the 12 volt power supply.

Please post a link to the relay boards. if they are the ones we encounter with an opto on them then we can tell you how to control them.

if they are just ordinary ice cube relays, you can control them just as easily, but need a bit larger transistors.

since you have 5v relays, start there. check the data sheet on the PN2222 and make sure you connect the correct pins. some data sheets show the pins as if looking up at the bottom of the chip, others as if looking down on the PCB.

when looking at the sketch, the arduino and the base (and only the base) of the transistor must be 5 volts.
the center section, the coil section must be rated for the coil voltage of the relay. the only selection criteria is for the coil, this selection has nothing to do with the load, solenoids or pumps. the right section is the contacts. they ONLY ever see the motor voltage, could be 1 volt or 1,000 volts if the relay is rated for that voltage.

the proper power supply is to supply 5 volts to each relay board. you can connect them all to the power supply.
power the arduino with it’s own power supply
connect the grounds.

as for the pin connections, we typically suggest you do not use pins 0 or 1 on the digital side, but rather start with pin 2. 0 and 1 are used RX and TX.

since all your work appears to be for relays, start with 2, 3, 4, 5, 6, 7, etc…
it is very easy to have two pins be driven at the same time.

digialWrite(pin3, HIGH);
digitalWrite(pin4,HIGH);

these will be executed in sequence faster than the relay will respond. for all purposes, it will be at the same time.

here is a suggestion. write your program, connect an LED to each pin. test it. if you are happy that the LED’s light in the correct pattern, then connect your relays.

you did not mention how you want to signal the program to start, or if you need to have an emergency stop.

also, read “blink without delay” you should not be using delay in the program if you have an emergency stop.

relay.jpg

Lost me, the photo attached is what i was planning. the second one is supposed to be the cycle i need it to run.

I know its simple, that’s why i want to make it so i can learn from it :slight_smile:
the whole thing should start when a lever (up where the material bin is) closes. i don’t remember well what voltage the signal is, i know we relayed it to the 120vac to power the whole vacuum loader. how do i make this a simple signal for the arduino?
where do i plug it? guess i need to know the signals voltage first, right?

I’m not thinking about the emergency stop, figured the operators can just unplug the power supply in case somethings needed.

so according to what you said i need to get a 12Vdc power supply for the arduino,
24Vdc power supply for the valves
120Vac power supply for the motor (already there)
and a separate power supply for the 5vdc???
I don’t have that many power outlets on that wall

can’t I just get a 24vdc power supply and attach a couple of voltage regulators so i can achieve 5 and 12 vdc? (which creates another circuitry issue for me)

i have 5vdc relays, the valves are 24vdc actually… aaaaaand i dont have the relay board cause i went ahead and assembled it myself (see circuit)

Are you saying that the in puts on the relay is ( 2 / 24 / 120) or that the out puts are? We could use some pics. If you have all the same input voltage relays you just hook the base to a current limiting resistor then to your digital out put pin. Emitter goes to ground collector goes to load and load goes to voltage (whatever it may be). Be sure that the power all shares a common ground. DO NOT USE A 120 anything with this stuff with out proper understanding of whats going on and ALWAYS use total galvanic separation between the high and low voltages.

The input voltage is 5 volt. If you use 5 volt to trigger it you need a pull-down. If Ground is your ON you can use the internal pull-up.
You can use an opti-coupler to make this signal even from 120 volt.

galvanic separation?

i have 5v relays, the coils are 5v. two of them are to handle 24vdc and 1 of them 120vac
valves are 24v and motor 120vac.

cant i wire it the way its shown in the previous picture?

odv135:
cant i wire it the way its shown in the previous picture?

That looks OK to me with one caution - what is the total current of all the coils of all the relays? I think if it is more than about 200mA I would give the relays a separate power supply rather than power them from the Arduino 5v pin.

Of course if the relays have a separate power supply there is no need for them to have 5v coils.

One of the nice things about the Arduino system is that it is so easy to learn by doing.

...R

It may work but as pointed out watch total current. Galvanic separation is to not have any metal connections between two things (use an opti-coupler a relay a transformer something like that). Since you are using a relay to switch it you are fine just something to keep in mind.

its these relays
http://www.ryston.cz/pdf/fujitsu-takamisawa/vb.pdf

just read a little about the galvanic isolation aaaaaand its saying something about isolation transformers... this is getting complicated...

i doubt it'll be less than 200mA... say i use the arduino only for the transistor's base signal, and give it an independent power supply... i have to build a separate circuit with voltage regulators so i power each thing needed? i don't really want more than one or two power plugs used in this.

cant we go step by step? idk, basic shape, then safety, etc? feel like im getting lost in details...

  1. can the relay circuit go as shown? i just need to figure out a way to power it separately independently.
  2. all i need to plug onto the arduino are the digital pins and its 12v power supply. is there more with the arduino?
  3. figure out (most likely buy) a voltage regulator that lowers a 24v to 12v and also 5v so i can power the relays, both valves and the arduino with it? that sounds like a lot for one power supply... how would you guys handle this? i could try and switch relays, but i dunno if the circuitry would have to change.

typical computer power supply outputs 5v and 12v. you can buy these from e-bay.

looks like that relay is only available in DC. they do make 12V relays, either AC or DC as well as 24VAC relays.

odv135:
cant we go step by step? idk, basic shape, then safety, etc? feel like im getting lost in details...

Well, what have you tried so far? And what have you discovered?

...R

dave-in-nj:
typical computer power supply outputs 5v and 12v. you can buy these from e-bay.

looks like that relay is only available in DC. they do make 12V relays, either AC or DC as well as 24VAC relays.

i have the 5vdc ones.
on the power supply, you mean they come both ways?

Robin2:
Well, what have you tried so far? And what have you discovered?

...R

i made a simple test program for 2 of them (with an independent supply) and i can hear the relays clicking.
so complete wiring is just waiting for a the power supply (which i have no idea what to do with it) still think the best way to go is having the voltage either turned to dc and lowered for each need or switch relays (which would mean switching the circuit and still would only remove 1 supply)

on the program side, how do i get to start 2 signals simultaneously instead of it going on a step by step sequence?

ps. soz if i sound harsh or anything on that last post... i didn't mean to.

It will be much easier to help if you post your code (within code tags, please).

You probably understand this, but I'm afraid I don't. Can you explain in more detail?

still think the best way to go is having the voltage either turned to dc and lowered for each need or switch relays (which would mean switching the circuit and still would only remove 1 supply)

To give you an example, I have a large 12v DC supply (from a 200AH battery) and I could use that ( A ) to power an Arduino ( B ) via a voltage regulator (7805) to drive some servos (or 5v relays) and for several other things. A key feature is that there is ample current available to meet short term requirements such as the inrush current into a relay coil. Another key feature is that things that may require a substantial momentary current are not powered through the Arduino. I would have no hesitation in replacing the battery in this scenario with a suitable mains to 12v DC adapter - probably one capable of producing 3 to 5 amps. However if my adapter was only capable of producing 1 amp or so I wouldn't expect it to power everything successfully even if the average current is below 1 amp.

Remember that an Arduino clock ticks once every 62.5 nanoseconds and the electricity supply must be stable over that tiny period.

...R

ooook so bad news, the project got a little "modified".
Instead of 2 valves and a motor its going to be 3 valves and they have to be controlled by limit switches on the bins... say bin 1 activated so valve 1 will stay open for x seconds.

this is sort of a good thing cause now i get to pick the valves (instead of using the 24v ones i can just have the usual 120vac ones we get around here) that way i can focus on 5v supply for the relays and 12v for the arduino.

i can still keep the same relay circuit since i just need 3 relays, but how do i use those limit switches on the arduino to tell him "this or that" needs to open? analog input?

I've just had a quick look back through this Thread and I think this is the first time you have mentioned bins and limit switches.

Hopefully you are a bit better informed now than when you started the Thread and I think it would be a good idea to restate the details of your whole project as it now is and taking account of your present knowledge. Otherwise we will all be tripping each other up over different details.

A very useful way to do that is to make a detailed list of all the steps that need to happen for the project to function. If you do that carefully it will give very clear pointers about how the code is to be written.

...R

Computer power supply have 5v 12v 3.3v and some more that you won't be using any time for this. These are awesome for projects like this.

You are fine running lots of relays and sensors and the arsuino or more than one and LEDs or lots of other stuff safely on one power supply.

As long as you use a modern power supply to power things and relays to switch things your good it is already sepreated. At least until things become more clear to you.

Inputs are 5v they can be done with a relay (on the load side o the relay) or an opti-coupler (basically a tiny solid state relay) or even by running a 5v or ground line to your switch and returning it to an input. If you use this last way I suggest you run the ground out to the switch (its safer on your stuff if something breaks the wire) and it allows use of the internal pull-up. If you use 5v as your (ON) you will need a pull-down resistor on each input. I like 10k ohm.

In programing you can put something like.

digitalWrite(valveX, HIGH);
digitalWrite(motor, HIGH);

And they will both turn on at the same time.

if yo ugot ur circuit working then keep going, but if you didn't I suggest a sainsmart relay board like

if you have a big amount of current that needs switching it makes things simple, just note high turns off the relays and low turns em on.

Big power relays are a little tricky and you need to think about things like freewheel diodes etc on the coils, but a board like i linked to has that built in I belive. I have an older model of ahtt myself. another ME here playing w/ electronics.

permnoob:
if yo ugot ur circuit working then keep going, but if you didn't I suggest a sainsmart relay board like
http://www.sainsmart.com/sainsmart-4-channel-signal-relay-board-for-arduino-uno-mega-2560-r3-duemilanove.html
if you have a big amount of current that needs switching it makes things simple, just note high turns off the relays and low turns em on.

Big power relays are a little tricky and you need to think about things like freewheel diodes etc on the coils, but a board like i linked to has that built in I belive. I have an older model of ahtt myself. another ME here playing w/ electronics.

not high amp relays. these are signal relays.
nice board though.

Robin2:
I've just had a quick look back through this Thread and I think this is the first time you have mentioned bins and limit switches.

Hopefully you are a bit better informed now than when you started the Thread and I think it would be a good idea to restate the details of your whole project as it now is and taking account of your present knowledge. Otherwise we will all be tripping each other up over different details.

A very useful way to do that is to make a detailed list of all the steps that need to happen for the project to function. If you do that carefully it will give very clear pointers about how the code is to be written.

...R

true, but that's cause i wasn't going to include the sensor on the top bin for anything cause i just had to control one vacuum loader for one machine, not a feeding system. They just decided to switch the loader to something more powerful and feed everything off of it, so that's why I'm going to include limit switches so the valves (new ones, not the ones that belong to the old loader) decide which machine to feed.

sorry I was rushing and causeing confusion. This is the relayboard I am using

10A perrelay. It has a jumper so the coil supply can vbbe fully optoisolated from logic power if desired, or connected together for simplicity.

Hi