Shop OBEX P1 Docs P2 Docs Learn Events
can the prop control this 4ch 5volt relay using its 3.3 volt i/o pins ? — Parallax Forums

can the prop control this 4ch 5volt relay using its 3.3 volt i/o pins ?

whiteoxewhiteoxe Posts: 794
edited 2014-08-12 02:49 in Propeller 1
this is the relay unit I have http://www.ebay.com.au/itm/190866383549?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649 I think it needs 4 x 5volt i/o pins to operate it and the relays themselves can operate from 5v to 24 volt.

So if i am correct then i will need to setup a breadboard with transistors so i can use the Quickstart 3.3v pins to turn on a separate 5volt supply . Each 3.3v pin operates a relay. but the 3.3volt quickstart i/o pin most likely wont be able to switch it. so i will have a separate 5 to 5.3 battery pack that will supply the power to the relay pin by using a transistor.

Here is another look at the 4ch 5volt relay http://www.freetronics.com/pages/relay4-4-channel-relay-driver-module-quickstart-guide#.U9pjSGflpdg


am i on the right path so far please ? ive got both common npn and pnp transistors, just not sure that my conclusions are correct but would be a good excuse to use a transistor again ;) any advice much sort after. :thumb:

thanks,
Whiteoxe.

edit: is there a better way than using the transistors i propose ? i just read this thread a few threads earlier than mine which is similar but a bit different i think ..It's title is "Still Trying To Drive The Relay With A Propeller", maybe the 3.3volts will trigger the relays ?

So Arduino uno boards I/o pins put out 5 volts ? Well this board of relays said it was for the arduino but I always ignore that bit :tongue:

http://forums.parallax.com/showthread.php/156690-still-trying-to-drive-a-relay-with-the-Propeller...

PS. now my imagination is running away with me... can two prop pins make 6.6 volts ? plug in a 5v regulator :frown: I bet there are 10 ways of solving this but I just want one . (1) the other 8 would be more twisted than a loose roll of barbed wire ........

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-07-31 10:23
    I'm betting that the eBay model will work from a Prop's 3.3V output. The board has driver transistors for the relay coils, so the Prop would not be driving the relays directly. At worst, you might have to change the transistor base resistors to a lower value, but I'd be surprised if even that were necessary.

    -Phil
  • whiteoxewhiteoxe Posts: 794
    edited 2014-07-31 11:06
    thx I will try it and see, but at some point im going to soon face this problem again. 3.3 volts even sounds strange but ill qualify that a little bit by saying the last time I used a transistor to switch a relay I used a cut wire from a parallel printer port cable. I think even my printer used that cable before I hacked it apart !

    There was little voltage coming from that wire not enough to switch the clear plastic relay I was using. I got it to work using transistor but I cant now remember the diff between an emitter or a base. I'm starting from first base or more like in the bunker . I could see how a person could control their house from a parallel port. I was sad to see my next computer had no option for that port but id figured out serial ports and chips were easier. Anyway looks like there is a very similar thread id missed below mine ill keep an eye on.. thx Phil.
  • whiteoxewhiteoxe Posts: 794
    edited 2014-07-31 21:35
    Sorry Phil, I got you mixed up with heater on a different thread. I am going to try it using the 3.3 volts but I think I will also try a 7404 gate. Is that made up of transistors ?

    I asked the same thing here and got you confused with Heater http://forums.parallax.com/showthread.php/156620-Need-tips-on-soldering/page4
  • Heater.Heater. Posts: 21,230
    edited 2014-07-31 23:15
    Looking at the pictures one can see that the board has 4 transistors driving the four relays. I'm pretty sure the Prop will be able to drive that with a simple direct connection. As Phil says. And yes in theory you might have to practice your new found soldering skills and change the resistors on that board to give the transistors a little more base drive current. Seems unlikely though.
    can two prop pins make 6.6 volts ?
    Yes if you add a capacitor charge pump/voltage doubler circuit to them. Lets's not go there for driving relay boards.
    3.3 volts even sounds strange...
    I would imagine that today, and since some years, the majority of the digital logic in the world requires 3.3v power supplies. Today a lot of logic requires lower voltages, like 1.2v. It's all to do with making the transistors smaller and needing to reduce their power consumption and increasing their speed. Or perhaps even stopping them breaking down at all. What do I know.

    I believe the Propeller II requires a lower voltage power supply for it's internal logic although the I/O pins still work a 3.3v
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-07-31 23:41
    whiteoxe wrote: »
    Sorry Phil, I got you mixed up with heater on a different thread. I am going to try it using the 3.3 volts but I think I will also try a 7404 gate. Is that made up of transistors ?

    I asked the same thing here and got you confused with Heater http://forums.parallax.com/showthread.php/156620-Need-tips-on-soldering/page4

    Don't even "also try a 7404 gate" as that is absolutely redundant and unnecessary, no point at all since the signal voltage is current limited by the resistors to turn on the NPN bipolar transistors, and all they need is more than 0.6V and a few milliamps, which is what the resistor already does. If worse comes to worst you only need to change the resistors as mentioned or even putting a resistor in parallel maybe (if that's easier).


    BTW, two Prop pins can't produce 6.6V really as the CMOS structure will conduct with any voltage more positive or negative than it. But mind you I have coupled the output of a pin through a cap and schottky diodes (or a dual) onto an output cap to almost double the voltage. For 3.3V this will most likely only be around 5.5V taking into account Rdson and diode drops and loading current.
  • whiteoxewhiteoxe Posts: 794
    edited 2014-07-31 23:43
    well hello, you found my relay board and thankyou for the knowledge . I was able to buy a couple of 7414 gates for $1.40 each. they haven't stocked the 7404 for 15 years !! now back to edit my last post about the shop..........

    sorry PJ , I just missed your post. Point taken.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-08-01 00:14
    whiteoxe wrote: »
    well hello, you found my relay board and thankyou for the knowledge . I was able to buy a couple of 7414 gates for $1.40 each. they haven't stocked the 7404 for 15 years !! now back to edit my last post about the shop..........

    sorry PJ , I just missed your post. Point taken.

    Wot!? you were serious about the "7404"s then and you tried to buy them too!!!!

    As mentioned before, it's all about the current which is controlled by the resistors, so forget about the voltage. NPN transistors in this grounded emitter configuration are really current amplifiers, they may have a minimum current gain of 100 meaning that you pass 1ma through the base-emitter then it will allow up to 100ma to flow between the collector and emitter, which also means anything in its path, such as the relay coil that connected to +5V and the collector. But typically this configuration is meant to work more like a switch or a relay as we want the transistor to turn on as hard as it can so we just end up pumping 3 to 10 times (roughly) the amount of current that we need into the base to get it to switch on fully (saturated switch). So that relay draws around 70ma so even at 3ma base current it will have no problem turning it on fully and I'm sure the base resistors do supply more than that at 3.3V input. If you confirm what value those input resistors are then that will certainly nail it if you yourself are in doubt (not me).


    BTW, this preoccupation with voltage instead of current is what a lot of threads are about such as *** and his obsession with the magic 5V when it's all about current through an opto LED in this case which then drives a transistor which drives the relay. It's like days of our lives.

    ( So you know that to run an LED off 12V instead of 5V at the same brightness you just increase the value of the resistor and to run it at 3.3V you would decrease, although it would still work anyway, same thing).
  • Heater.Heater. Posts: 21,230
    edited 2014-08-01 01:06
    Peter,
    ...It's like days of our lives....
    Or Groundhog Day perhaps?
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-01 01:22
    :thumb:Well Peter, Im only trying to go on what I have read today and its not clear, at least not everything. it talks a bit about sinking and sourcing milliamps from page 10 onwards.like each I/0 pin can sink 32 miliamps. and a max of 100 miliamps can be sourced by 8 I/o lines at anyone time. so that's about 12 miliamps average each for 8 pins at once. On page 13 it says the use of those gate chips is to protect the load on the pins during experiments or mistakes by puttingthe Output signals through those standard gates. There is a big advantage in the increased Power they can provide for any attached load. using a separate power supply. so I would use 4 AA BATTERIES to get somewhere between 4.8 and 5.3, because I can do that easily., ifg its 5volt give or take a little that's needed.
    the book has stated that 5volts is a common requirement, Ok, I get it crystal clear that not in this particular case of the relay board I have got. , that is good to have been made aware its the wrong approach. Im going to have to go over your posts a couple more times and google some questions I have before Im really understanding all the information posted so far. Give me a day or two !

    There seems much talk mof voltages in these chapters I have read and of using resistors with the gates for protect\ion until everything is working right then the resistors may be removed possibly. Then the book starts teaching about constants, variables pub pri methods , objects, ram, rom shared or not , starting, stopping cogs. Only 5 chapters but its quite a lot to digest. , and I am digesting it but my eyes feel bigger than my stomach , I need a little break before I can swallow the lot ! but thanks I appreciate the help I am being handed. :thumb:
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-08-01 01:34
    whiteoxe wrote: »
    :thumb:Well Peter, Im only trying to go on what I have read today and its not clear, at least not everything. it talks a bit about sinking and sourcing milliamps from page 10 onwards.like each I/0 pin can sink 32 miliamps. and a max of 100 miliamps can be sourced by 8 I/o lines at anyone time. so that's about 12 miliamps average each for 8 pins at once. On page 13 it says the use of those gate chips is to protect the load on the pins during experiments or mistakes by puttingthe Output signals through those standard gates. There is a big advantage in the increased Power they can provide for any attached load. using a separate power supply. so I would use 4 AA BATTERIES to get somewhere between 4.8 and 5.3, because I can do that easily., ifg its 5volt give or take a little that's needed.
    the book has stated that 5volts is a common requirement, Ok, I get it crystal clear that not in this particular case of the relay board I have got. , that is good to have been made aware its the wrong approach. Im going to have to go over your posts a couple more times and google some questions I have before Im really understanding all the information posted so far. Give me a day or two !

    There seems much talk mof voltages in these chapters I have read and of using resistors with the gates for protect\ion until everything is working right then the resistors may be removed possibly. Then the book starts teaching about constants, variables pub pri methods , objects, ram, rom shared or not , starting, stopping cogs. Only 5 chapters but its quite a lot to digest. , and I am digesting it but my eyes feel bigger than my stomach , I need a little break before I can swallow the lot ! but thanks I appreciate the help I am being handed. :thumb:

    Whoa up there boy, you're jumping the creek before you are anywhere near the bank, all those facts and figures. If you understand that last little bit I said about the LEDs you will clue on that although there's a minimum turn-on (and clamp) voltage for diode structure (diode or transistor = 0.6V , red LED 1.6V etc) that it is the current that needs to be controlled. A red LED will work fine off 240V or 2.4V, depending upon the resistor (but the voltage across the diode will always be 1.6V or so). The NPN transistor switch will work fine off 50V, 5V or 1.5V, depending upon the resistor. You don't need a day, just a moment, KISS.
  • Heater.Heater. Posts: 21,230
    edited 2014-08-01 01:50
    That book is kind of right. The Propeller I/O pins can probably be damaged by drawing excessive current when used as an out put, say by accidentally shorting them to ground. Or by applying too much voltage, positive or negative as an input. In that case when taking signals on and off board one might want to protect the Propeller by passing the signals though some other transistors or logic gates or even opto isolators.

    My approach to this is just to always by a couple of spare Propellers when messing with experiments on bread boards or proto boards. Ready for that day that I slip up. Seems to me that in that scenario I'm as likely to damage the Prop pins whilst implementing the protection circuit than just connecting them to what I want. Complexity increases the risk of error. One hundred ohms in series with outputs will protect from shorts, nice as long as that does not interfere with what you are trying to do.

    Up to you.

    It seems you could do with a little tutorial in the basic use of a transistor as a switch. As used on those relay boards like yours for example. For example this : http://www.electronics-tutorials.ws/transistor/tran_4.html which shows a nice typical relay driver circuit.

    Notice how the transistor is turned on by current into it's base and that there is a resistor in between the input and base to limit that current. Without that resistor the transistor will pull as much current as it can and no doubt fry itself. It only needs to be a small current, 100 times less than the load current switched through the load.

    So, as long as 3.3v from the Prop is enough to drive sufficient current through that resistor into the base the transistor will turn on an activate the relay. No need for any 3.3 to 5v conversion.

    It's fun to build just simple circuits like those in that tutorial and measure the currents through and voltages across all the components. Experiment with different resistor values and see how things change. And, importantly, when the smoke comes out:) Then you start to get a feel for what is going on here.

    In fact I would start such experiments with a resistor and a LED. As Peter is discussing. Measure the current through the LED. Measure the voltage across the LED and the resistor. Change the resistor value a bit. See how current through the LED changes. See how the brightness changes. Notice how the voltage across the LED stays almost the same all the time. Magic!

    The current and voltage through a LED does not obey Ohms Law.

    The current into and voltage on the base of a transistor behaves much like the current and voltage with a LED.

    Same for normal diodes in the conducting direction, but the experiments are more fun with LEDs that light up:)
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-01 02:22
    Peter I'd say KIVSS but then someone would cry out get off the cross we need the wood. The first thing I did ever when I thought electronics was possibly a fun hobby was do stacks ans stacks of sums for parallel, series, voltage divider , dual supply simultaneous equations to work out direction of current flow power current etc. 1400 hundred pages of Basic DC Circuits. but then I forgot most of it because none of it ever came up when I started out with picaxe chips. Ive still got that book here with me , I just never want to open it again ;) Im just going to ask you'all what the answers are. Heater before I left for town , around about 7am this morning I book marked what I think may be some really good examples of how to use pnp and npn transistor's to light a led and switch a relay. I will look at those links you have posted as well.
  • Heater.Heater. Posts: 21,230
    edited 2014-08-01 02:36
    Bah, all that book learnin', softens the brain. My grand pappy never done no book learnin' and he did just fine.

    Round these parts if you want to know how it works, take it apart!

    We do that by building simple circuits swapping out component values and "seeing inside" by measuring volts, amps etc. And blowing it up.

    It helps to have an concrete aim in mind. Like understanding your relay driver circuit.

    A little theory, ohms law and stuff, gets you a long way. And experiments fix it in the brain better than any dorky book reading.
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-01 03:11
    I think you must be right, first my brain has gone mushy and that book never did me no good anyways except have me tied up in knots and visiting forums that love that stuff when I forgot to change side change sign ...haaaaa.Damned it was a waste of time, it only had me tricked I was enjoying it because each night when I stopped it felt so good, I just didn't register that it was only the stopping that was giving me the warm happy feeling ;) and if id just used breadboards and a multimeter I think a lot more would have been gained and stuck. I would pour kerosene on that book and offer it to the monkey but I burnt my dinner so that'll have to do !
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-08-01 03:32
    whiteoxe wrote: »
    I think you must be right, first my brain has gone mushy and that book never did me no good anyways except have me tied up in knots and visiting forums that love that stuff when I forgot to change side change sign ...haaaaa.Damned it was a waste of time, it only had me tricked I was enjoying it because each night when I stopped it felt so good, I just didn't register that it was only the stopping that was giving me the warm happy feeling ;) and if id just used breadboards and a multimeter I think a lot more would have been gained and stuck. I would pour kerosene on that book and offer it to the monkey but I burnt my dinner so that'll have to do !

    You burn your dinner and you learn to take it off the stove a few minutes earlier, you didn't need no book to tell ya that, and you wouldn't have understood it really.
    Instead you burn and learn :)
    Now that's a real warm feeling right there.

    So you see get the simple things right first, read it yes, but try it out, yes, then play with it till it "burns", the smell of that smoke etches itself into your memory and never gets forgotten.

    PRAC 101 - LED + RESISTOR - what voltage do you read across the LED for various supply voltages and resistance - what does that tell you? - will it only work with 5V??? etc
    (In fact I get budding young engineers to connect an LED directly to 5V since it's a "lamp", burn and learn)
  • Heater.Heater. Posts: 21,230
    edited 2014-08-01 04:24
    Peter,

    "Burn and learn" I love it. Is that a catch phrase among chefs? It's going to be a catch phrase for me from now on.

    Many years ago I just had to torture a good old fashioned red LED by winding up the current slowly, sure it got brighter and brighter, then levelled out and then started to dim. At that point there was a big bang and the top flew off. Nearly took my eye out.

    One should be a bit careful with the burn and learn technique.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-08-01 05:29
    Heater. wrote: »
    Peter,

    "Burn and learn" I love it. Is that a catch phrase among chefs? It's going to be a catch phrase for me from now on.

    Many years ago I just had to torture a good old fashioned red LED by winding up the current slowly, sure it got brighter and brighter, then levelled out and then started to dim. At that point there was a big bang and the top flew off. Nearly took my eye out.

    One should be a bit careful with the burn and learn technique.

    Protection? That's fer wusses, most they get is a pair of glasses and if it happens that a hot bit of "led" hits em in the face and it burns, then they learn even more n better! :)

    Actually what Mike was saying about reading those kind of books, the problem is you ending up "knowing" how to do it exactly that way, but not understanding how to do it different or why. How many times have I come across engineers who absolutely insist that THIS is the way it has to be done. Oh boy, how do I tell em different from the "book", how dare I.

    But I'd have hundreds of stories to tell, quite humorous if they weren't so true. I even had one very experienced and qualified hardware design engineer diagnose a circuit and after finding "only" 0.6V on the base emitter of an NPN figured it was faulty and needed to be replaced with one that showed the full voltage. Was he for real? Yep!. Another microelectronics grad knew all about the CAD but when I was talking about RC differentiation and integration he just didn't have a clue, not a sausage, go figure. Oh, the list goes on and on....
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2014-08-01 06:19
    So Arduino uno boards I/o pins put out 5 volts ? Well this board of relays said it was for the arduino but I always ignore that bit

    Keep it simple. That board is perfect and should work fine with a propeller. There are 6 pins. Gnd to Gnd on your quickstart. Vcc on that relay board to 5V - but in this case the relay board is pretty tolerant of variation and you could use 4 AA batteries. Ballpark anything 4V to 7V. And connect propeller pins directly to the inputs on the relay board.

    That should be it - no other parts needed. Just some wires actually, and a few lines of spin. Turn the prop pins high then low once a second (use the led blinker code) and you will hear the relays clicking.
  • Heater.Heater. Posts: 21,230
    edited 2014-08-01 06:42
    Peter,

    Way back during my pre-university physics course we did a lot of practicals involving capacitors and inductors, even transistors and tubes. All part of the elecromagetism thing. One day the lecturer held up a choke and a transformer and told us how we were lucky to be doing all this practical stuff, how the majority of EE's coming out of university could tell you all about the theory of inductors but would not be able to tell you which one of these was the choke and which was the transformer.

    How we laughed. How stupid could that be? Most of us in the group had started playing with this stuff around the age of 10. Philip's Electrical Engineer Kits, building xtal radio sets, wrecking the family TV, and so on.

    Sure enough when I graduated in Physics I knew a lot of EE's graduates. What my lecturer had said that day turned out to be true. I really wondered why half of them had bothered with EE when they did not seem to have a passion for it at all.

    Winding time forward a few decades, I recently watched you tube video by an electronics lab tech in the states showing us around the labs and all the goodies in his back room store. He complained about exactly the same problem. Most of he students he had to deal with could not tell one end of a diode from another.

    Things change, things stay the same....
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-10 19:29
    Hello, I got around to the Yrobot 4ch relay board you can get for under $10 on ebay, well $2.99 to be exact . The easiest way was to just record as the web camera is always pointing to my desk. no setup required. Sorry for the microphone setting, it has a lot of background static from not checking the audio settings.

    As Im typing I have just started to think that if I connect the microcontroller and set the four pins IN1,IN2,IN3,IN4 to high then it might turn off all the relays ? I'll try that in the meantime.

    I couldnt find the Quickstart when i started the experiment but it has shown up during the video :)



    EDIT: I can't get the relays to work at all. I set all the pins high then connected the ground and they werre all off so I though that was the answer but when i then sert the pins to LOW nothing happened. So then I just went back to unplugging the arduino and unlike before when all the relays were on and the red lights lit up I get nothing. Its like the board is dead ?


    EDIT #2; Well its working. When pin on relay boartd is set to LOW it operates the relay and the red light goes on. Turn it off by setting the pin to HIGH.

    but is there something a little bit wrong with my wiring that when i disconnect the microcontroller then all relays and their lights are on ?
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-10 21:38
    It just seems a little bit wrong. Setting pins High the Relays are off, but the red LEDS can be seen to just slightly glow if you look hard. Setting pins to LOW then they are All turned on with a loud click and red LEDS glow brightly.

    I think its all working correctly. Just being Active Low, threw me for awhile.
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-11 00:02
    Just trying to understand the difference between these two relay boards. Appreciate any comments. The relay board I am using is just switches that provide no power themselves. just simple switches. Im currently just turning a motor on and off with HIGH/LOW.

    Whereas this very similar relay board has switches that also supply power from a supply connected between 5 and 24volts. Which seems to me to be slightly easier type of relay to use.

    fREETRONICS-RELAY4-pinout_large_zps587db7f0.jpg
  • jmgjmg Posts: 15,173
    edited 2014-08-11 00:42
    whiteoxe wrote: »
    It just seems a little bit wrong. Setting pins High the Relays are off, but the red LEDS can be seen to just slightly glow if you look hard. Setting pins to LOW then they are All turned on with a loud click and red LEDS glow brightly.

    I think its all working correctly. Just being Active Low, threw me for awhile.

    What are the part codes on the transistors ?
    You should always test suck unknown Boards first with a variable control voltage (eg a second power supply) to check the switching thresholds. ON and OF will be slightly different.

    If they are PNP transistors connected to 5V, that would fit your observations.

    The Prop cannot drive 5V, so the LEDs are on faintly, and then a LOW turns them on more.

    The problem here, is temperature and supply skew can move that just slightly glow effect, until a relay that turns on, can fail to release. Not a good design/use.
    Worst case test is probably 3 relays ON and an inner relay going from ON to OFF.

    The yellow overlay looks to use NPN drivers and can use higher voltage relays.
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-11 01:15
    thx jmg, I powered the relay board with a 5.1 volt power pack, I used an arduino because I temporarily lost the prop board. Im just using the arduino to set pins HIGH/LOW. iVE SORTED IT OUT. caps again sorry..... ;)

    What I am curious about in the yellow overlay is where it has the 5 to 24 volt input, is that just giving me the operating range of that board or is that also used by the switches to source power, or do I still need another power supply and the relays are only switches. I've really not used a relay before no matter how simple or old they may be ? Well a single relay on a breadboard ages ago.
  • jmgjmg Posts: 15,173
    edited 2014-08-11 12:52
    whiteoxe wrote: »

    What I am curious about in the yellow overlay is where it has the 5 to 24 volt input, is that just giving me the operating range of that board or is that also used by the switches to source power, or do I still need another power supply and the relays are only switches.

    Reverse reading the image, which shows the tracks and plane connections, that yellow board powers at the relay voltage. So you can use 5/9/12/24V relays.

    The Logic threshold is set by 2 resistors and the SOT23 device, likely a NPN - so the point where the relay turns on will change slightly with 5/9/12/24V, but not much. Expect a TTL level of 1.5V~2V, with > 2V => Relay Coil ON.

    If you can read those resistor values, you can calculate the nominal switch point, but as I've mentioned before, better to actually measure what happens, then you learn more.(and eliminate false assumptions) & confirm the board does work before you apply software.
  • whiteoxewhiteoxe Posts: 794
    edited 2014-08-12 02:49
    yes thanks, just for now i don't want to even think about calculating a thing. I just want stuff to work and it does. I have got a nice little clicking tune going with my 4 relays :)
Sign In or Register to comment.