Electronics-Related.com
Forums

Raspberry PI model B + and 5V relay PCB

Started by gm November 6, 2014
rickman <gnuarm@gmail.com> writes:

>On 11/6/2014 12:53 PM, gm wrote: >> On 06.11.2014 18:03, Jan Panteltje wrote: >>> On a sunny day (Thu, 06 Nov 2014 17:33:24 +0100) it happened gm >>> <notMyMail@mail.not> wrote in <m3g7sk$8pd$1@l01news1.ot.hr>: >>> >>>> On 06.11.2014 17:22, gm wrote: >>>>> On 06.11.2014 16:44, Spehro Pefhany wrote: >>>>>> On Thu, 06 Nov 2014 15:24:26 +0100, gm <notMyMail@mail.not> wrote: >>>>>> >>>>>>> Hi. >>>>>>> >>>>>>> I didnt play much with RPI but now we have finish one project >>>>>>> where we >>>>>>> are triggering GPIO. The PCB relay board should be triggered from RPI >>>>>>> GPIO and the door should be opened. Now, before i connect PCB to >>>>>>> RPI i >>>>>>> want to be sure that nothing goes wrong. This is the pcb >>>>>>> schematics that >>>>>>> we use for the relay trigger. >>>>>>> >>>>>>> http://tinypic.com/view.php?pic=10rmrsh&s=8#.VFuEUa0zdag >>>>>>> >>>>>>> What do you think . can i connect this directly to RPI GPIO, and >>>>>>> which >>>>>>> pins can i use ? >>>>>>> >>>>>>> Thank you in advance ! >>>>>> >>>>>> Yes, it should work fine. >>>>>> >>>>>> Reduce R1 to 560R to compensate for the 3.3V output of the Rpi port >>>>>> pins, and use the 5V power for the relay (and a 5V relay coil). >>>>>> >>>>>> Double check the connections before applying power. >>>>>> >>>>> ----------- >>>>> should i reduce the resistor value ? Am asking because i have made the >>>>> pcb and i have to test it today and i dont have 0,5K near me. I have to >>>>> buy it tommorow >>>> --------------- >>>> btw. what pins should i use ? >>> >>> Depends on what other things you want to use on the GPIO. >>> Some pins have special functions. >>> If all you do is drive some relais, then it makes little difference. >>> >>> As for that resistor, take current of relay, >>> divide by beta transistor, >>> multiply by 10, and that is a safe base current. >>> Then find R from (3.3 - .7) / base current. >>> The .7 is the Vbe drop. >>> It is not critical in any way. >>> >> -------------------------------------------- >> I need to drive just this relay. The relay should open a door. >> What pin number would you suggest. I newer use GPIO on PI, that's why am >> asking...
>That is a question better answered by the rPi group. So I am cross >posting your question.
Diode D1 is vital to protect the transistor from the inductive surge when the relay is turned off (without D1 the surge voltage can be surprisingly high, even hundreds of volts and often enough to give you a small shock if you touch the relay), but one thing that can sometimes happen is that with D1 in circuit the current through the relay decays quite slowly. How slowly depends on things not usually included in the specs for the relay, but if it takes too long, you can add a *small* (low value) resistor in series with D1. That will increase the voltage surge when the relay turns off, and ideally you would use an oscilloscope to see how big the spike is, making sure that it doesn't exceed the voltage rating of the transistor (usually given as Vce). Sometimes everything is fine with no resistor and sometimes the relay is too slow -- Windmill, TiltNot@NoneHome.com Use t m i l l J.R.R. Tolkien:- @ S c o t s h o m e . c o m All that is gold does not glister / Not all who wander are lost
In article <m3giep$bmm$1@l01news1.ot.hr>, gm  <notMyMail@mail.not> wrote:

>OK. I have written the sw so this part is working. At least with LED. >If i dont change anything on PCB , then i will connect this like this: > >5V to pin 2 > >GND to pin 6 > >Signal to pin 7 ( GPIO 4 ) > >Will this work ?
Yes. If you want to make life easy for yourself, then I'd suggest installing wiringPi which has a command-line utility called gpio which lets you trivially fiddle with stuff from the command-line without writing scripts/programs, etc. http://wiringpi.com/download-and-install/ To play with the relay on pin bcm-gpio pin 4, then: gpio -g mode 4 out gpio -g write 4 1 # Turn on gpio -g write 4 0 # Turn off With the disclaimer that I wrote wiringPi... Gordon
On 11/6/2014 4:55 PM, Gordon Henderson wrote:
> In article <m3giep$bmm$1@l01news1.ot.hr>, gm <notMyMail@mail.not> wrote: > >> OK. I have written the sw so this part is working. At least with LED. >> If i dont change anything on PCB , then i will connect this like this: >> >> 5V to pin 2 >> >> GND to pin 6 >> >> Signal to pin 7 ( GPIO 4 ) >> >> Will this work ? > > Yes. > > If you want to make life easy for yourself, then I'd suggest installing > wiringPi which has a command-line utility called gpio which lets you > trivially fiddle with stuff from the command-line without writing > scripts/programs, etc. > > http://wiringpi.com/download-and-install/ > > To play with the relay on pin bcm-gpio pin 4, then: > > gpio -g mode 4 out > gpio -g write 4 1 # Turn on > gpio -g write 4 0 # Turn off > > With the disclaimer that I wrote wiringPi...
Sounds like a useful program. Have you ever used Forth? This sort of capability is built into the language at a low level and if the syntax is not optimal for your use it can be easily modified. It is also good for constructing any program you might be interested in writing... all of it testable interactively. I have installed gforth on my rPi and hope to have it connected to something soon. -- Rick
On 06.11.2014 22:55, Gordon Henderson wrote:
> In article <m3giep$bmm$1@l01news1.ot.hr>, gm <notMyMail@mail.not> wrote: > >> OK. I have written the sw so this part is working. At least with LED. >> If i dont change anything on PCB , then i will connect this like this: >> >> 5V to pin 2 >> >> GND to pin 6 >> >> Signal to pin 7 ( GPIO 4 ) >> >> Will this work ? > > Yes. > > If you want to make life easy for yourself, then I'd suggest installing > wiringPi which has a command-line utility called gpio which lets you > trivially fiddle with stuff from the command-line without writing > scripts/programs, etc. > > http://wiringpi.com/download-and-install/ > > To play with the relay on pin bcm-gpio pin 4, then: > > gpio -g mode 4 out > gpio -g write 4 1 # Turn on > gpio -g write 4 0 # Turn off > > With the disclaimer that I wrote wiringPi... > > Gordon >
--------------------- I will use pin 18 instead ( GPIO 24 ). So i have connected as described but the wires are still on terminal, i didnt hook up a pcb. I have set high for GPIO 24 and its working fine. High was set for 2 seconds and in this time i have 3,3V. If everything is ok i will connect it to PCB.
In article <m3hk87$788$1@dont-email.me>, rickman  <gnuarm@gmail.com> wrote:
>On 11/6/2014 4:55 PM, Gordon Henderson wrote: >> In article <m3giep$bmm$1@l01news1.ot.hr>, gm <notMyMail@mail.not> wrote: >> >>> OK. I have written the sw so this part is working. At least with LED. >>> If i dont change anything on PCB , then i will connect this like this: >>> >>> 5V to pin 2 >>> >>> GND to pin 6 >>> >>> Signal to pin 7 ( GPIO 4 ) >>> >>> Will this work ? >> >> Yes. >> >> If you want to make life easy for yourself, then I'd suggest installing >> wiringPi which has a command-line utility called gpio which lets you >> trivially fiddle with stuff from the command-line without writing >> scripts/programs, etc. >> >> http://wiringpi.com/download-and-install/ >> >> To play with the relay on pin bcm-gpio pin 4, then: >> >> gpio -g mode 4 out >> gpio -g write 4 1 # Turn on >> gpio -g write 4 0 # Turn off >> >> With the disclaimer that I wrote wiringPi... > >Sounds like a useful program. Have you ever used Forth? This sort of >capability is built into the language at a low level and if the syntax >is not optimal for your use it can be easily modified. It is also good >for constructing any program you might be interested in writing... all >of it testable interactively. I have installed gforth on my rPi and >hope to have it connected to something soon.
Yes, and I mentioned this in your Forth thread a while back; I spent a year being paid to write Forth. I have no intentions to write anymore Forth, paid or otherwise. C is my language of choice, then a BASIC-like language (but only because I wrote my own BASIC-like language) The gpio command is just that - a command that you type in from the shell. No need to invoke any interpreter, compiler, etc. you can then incorporate it into a simple shell script too. I frequently see people writing 10-line Python programs just to turn an LED on and feel somewhat sad that they're doing that rather than just typing in a simple command to test their projects. Gordon
On 2014-11-06, Windmill <spam-no-spam@Freeola.net.invalid> wrote:
> rickman <gnuarm@gmail.com> writes: > >>On 11/6/2014 12:53 PM, gm wrote: >>> On 06.11.2014 18:03, Jan Panteltje wrote: >>>> On a sunny day (Thu, 06 Nov 2014 17:33:24 +0100) it happened gm >>>> <notMyMail@mail.not> wrote in <m3g7sk$8pd$1@l01news1.ot.hr>: >>>> >>>>> On 06.11.2014 17:22, gm wrote: >>>>>> On 06.11.2014 16:44, Spehro Pefhany wrote: >>>>>>> On Thu, 06 Nov 2014 15:24:26 +0100, gm <notMyMail@mail.not> wrote: >>>>>>> >>>>>>>> Hi. >>>>>>>> >>>>>>>> I didnt play much with RPI but now we have finish one project >>>>>>>> where we >>>>>>>> are triggering GPIO. The PCB relay board should be triggered from RPI >>>>>>>> GPIO and the door should be opened. Now, before i connect PCB to >>>>>>>> RPI i >>>>>>>> want to be sure that nothing goes wrong. This is the pcb >>>>>>>> schematics that >>>>>>>> we use for the relay trigger. >>>>>>>> >>>>>>>> http://tinypic.com/view.php?pic=10rmrsh&s=8#.VFuEUa0zdag >>>>>>>> >>>>>>>> What do you think . can i connect this directly to RPI GPIO, and >>>>>>>> which >>>>>>>> pins can i use ? >>>>>>>> >>>>>>>> Thank you in advance ! >>>>>>> >>>>>>> Yes, it should work fine. >>>>>>> >>>>>>> Reduce R1 to 560R to compensate for the 3.3V output of the Rpi port >>>>>>> pins, and use the 5V power for the relay (and a 5V relay coil). >>>>>>> >>>>>>> Double check the connections before applying power. >>>>>>> >>>>>> ----------- >>>>>> should i reduce the resistor value ? Am asking because i have made the >>>>>> pcb and i have to test it today and i dont have 0,5K near me. I have to >>>>>> buy it tommorow >>>>> --------------- >>>>> btw. what pins should i use ? >>>> >>>> Depends on what other things you want to use on the GPIO. >>>> Some pins have special functions. >>>> If all you do is drive some relais, then it makes little difference. >>>> >>>> As for that resistor, take current of relay, >>>> divide by beta transistor, >>>> multiply by 10, and that is a safe base current. >>>> Then find R from (3.3 - .7) / base current. >>>> The .7 is the Vbe drop. >>>> It is not critical in any way. >>>> >>> -------------------------------------------- >>> I need to drive just this relay. The relay should open a door. >>> What pin number would you suggest. I newer use GPIO on PI, that's why am >>> asking... > >>That is a question better answered by the rPi group. So I am cross >>posting your question. > > Diode D1 is vital to protect the transistor from the inductive surge > when the relay is turned off (without D1 the surge voltage can be surprisingly > high, even hundreds of volts and often enough to give you a small shock if > you touch the relay), but one thing that can sometimes happen is that > with D1 in circuit the current through the relay decays quite slowly.
> How slowly depends on things not usually included in the specs for the > relay, but if it takes too long, you can add a *small* (low value) > resistor in series with D1. That will increase the voltage surge when > the relay turns off, and ideally you would use an oscilloscope to see > how big the spike is, making sure that it doesn't exceed the voltage > rating of the transistor (usually given as Vce).
The maximum you'll get from adding the resistor is the resistor value divided by the relay resistance multiplied by the voltage powering the relay, plus the diode drop voltage. -- umop apisdn
Jasen Betts <jasen@xnet.co.nz> writes:

>On 2014-11-06, Windmill <spam-no-spam@Freeola.net.invalid> wrote: >> rickman <gnuarm@gmail.com> writes: >> >>>On 11/6/2014 12:53 PM, gm wrote: >>>> On 06.11.2014 18:03, Jan Panteltje wrote: >>>>> On a sunny day (Thu, 06 Nov 2014 17:33:24 +0100) it happened gm >>>>> <notMyMail@mail.not> wrote in <m3g7sk$8pd$1@l01news1.ot.hr>: >>>>> >>>>>> On 06.11.2014 17:22, gm wrote: >>>>>>> On 06.11.2014 16:44, Spehro Pefhany wrote: >>>>>>>> On Thu, 06 Nov 2014 15:24:26 +0100, gm <notMyMail@mail.not> wrote: >>>>>>>> >>>>>>>>> Hi. >>>>>>>>> >>>>>>>>> I didnt play much with RPI but now we have finish one project >>>>>>>>> where we >>>>>>>>> are triggering GPIO. The PCB relay board should be triggered from RPI >>>>>>>>> GPIO and the door should be opened. Now, before i connect PCB to >>>>>>>>> RPI i >>>>>>>>> want to be sure that nothing goes wrong. This is the pcb >>>>>>>>> schematics that >>>>>>>>> we use for the relay trigger. >>>>>>>>> >>>>>>>>> http://tinypic.com/view.php?pic=10rmrsh&s=8#.VFuEUa0zdag >>>>>>>>> >>>>>>>>> What do you think . can i connect this directly to RPI GPIO, and >>>>>>>>> which >>>>>>>>> pins can i use ? >>>>>>>>> >>>>>>>>> Thank you in advance ! >>>>>>>> >>>>>>>> Yes, it should work fine. >>>>>>>> >>>>>>>> Reduce R1 to 560R to compensate for the 3.3V output of the Rpi port >>>>>>>> pins, and use the 5V power for the relay (and a 5V relay coil). >>>>>>>> >>>>>>>> Double check the connections before applying power. >>>>>>>> >>>>>>> ----------- >>>>>>> should i reduce the resistor value ? Am asking because i have made the >>>>>>> pcb and i have to test it today and i dont have 0,5K near me. I have to >>>>>>> buy it tommorow >>>>>> --------------- >>>>>> btw. what pins should i use ? >>>>> >>>>> Depends on what other things you want to use on the GPIO. >>>>> Some pins have special functions. >>>>> If all you do is drive some relais, then it makes little difference. >>>>> >>>>> As for that resistor, take current of relay, >>>>> divide by beta transistor, >>>>> multiply by 10, and that is a safe base current. >>>>> Then find R from (3.3 - .7) / base current. >>>>> The .7 is the Vbe drop. >>>>> It is not critical in any way. >>>>> >>>> -------------------------------------------- >>>> I need to drive just this relay. The relay should open a door. >>>> What pin number would you suggest. I newer use GPIO on PI, that's why am >>>> asking... >> >>>That is a question better answered by the rPi group. So I am cross >>>posting your question. >> >> Diode D1 is vital to protect the transistor from the inductive surge >> when the relay is turned off (without D1 the surge voltage can be surprisingly >> high, even hundreds of volts and often enough to give you a small shock if >> you touch the relay), but one thing that can sometimes happen is that >> with D1 in circuit the current through the relay decays quite slowly.
>> How slowly depends on things not usually included in the specs for the >> relay, but if it takes too long, you can add a *small* (low value) >> resistor in series with D1. That will increase the voltage surge when >> the relay turns off, and ideally you would use an oscilloscope to see >> how big the spike is, making sure that it doesn't exceed the voltage >> rating of the transistor (usually given as Vce).
>The maximum you'll get from adding the resistor is the resistor >value divided by the relay resistance multiplied by the voltage >powering the relay, plus the diode drop voltage.
Yes indeed. But if you have access to a scope, it's instructive to look at what is actually happening, as opposed to what theory tells us. -- Windmill, TiltNot@NoneHome.com Use t m i l l J.R.R. Tolkien:- @ S c o t s h o m e . c o m All that is gold does not glister / Not all who wander are lost
On 2014-11-06, gm <notMyMail@mail.not> wrote:
> On 06.11.2014 16:44, Spehro Pefhany wrote: >> On Thu, 06 Nov 2014 15:24:26 +0100, gm <notMyMail@mail.not> wrote: >> >>> Hi. >>> >>> I didnt play much with RPI but now we have finish one project where we >>> are triggering GPIO. The PCB relay board should be triggered from RPI >>> GPIO and the door should be opened. Now, before i connect PCB to RPI i >>> want to be sure that nothing goes wrong. This is the pcb schematics that >>> we use for the relay trigger. >>> >>> http://tinypic.com/view.php?pic=10rmrsh&s=8#.VFuEUa0zdag >>> >>> What do you think . can i connect this directly to RPI GPIO, and which >>> pins can i use ? >>> >>> Thank you in advance ! >> >> Yes, it should work fine. >> >> Reduce R1 to 560R to compensate for the 3.3V output of the Rpi port >> pins, and use the 5V power for the relay (and a 5V relay coil). >> >> Double check the connections before applying power. >> > ----------- > should i reduce the resistor value ?
yes, the too high a resistor can cause excessive heating in the transistor, and then the transistor fails.
> Am asking because i have made the pcb and i have to test it today and > i dont have 0,5K near me. I have to buy it tommorow
Anything in the 200 Ohms to 600 Ohms range will suffice, eg: you could parallell two 1K resistors to get 500 Ohms. or use a 330 or a 470 if you have them on-hand. -- umop apisdn
On 2014-11-06, gm <notMyMail@mail.not> wrote:
> --------------- > btw. what pins should i use ?
If you already had it blinking a LED, use that pin (if you don't need to blink the the LED anymore) -- umop apisdn
On 09.11.2014 05:10, Jasen Betts wrote:
> On 2014-11-06, gm <notMyMail@mail.not> wrote: >> On 06.11.2014 16:44, Spehro Pefhany wrote: >>> On Thu, 06 Nov 2014 15:24:26 +0100, gm <notMyMail@mail.not> wrote: >>> >>>> Hi. >>>> >>>> I didnt play much with RPI but now we have finish one project where we >>>> are triggering GPIO. The PCB relay board should be triggered from RPI >>>> GPIO and the door should be opened. Now, before i connect PCB to RPI i >>>> want to be sure that nothing goes wrong. This is the pcb schematics that >>>> we use for the relay trigger. >>>> >>>> http://tinypic.com/view.php?pic=10rmrsh&s=8#.VFuEUa0zdag >>>> >>>> What do you think . can i connect this directly to RPI GPIO, and which >>>> pins can i use ? >>>> >>>> Thank you in advance ! >>> >>> Yes, it should work fine. >>> >>> Reduce R1 to 560R to compensate for the 3.3V output of the Rpi port >>> pins, and use the 5V power for the relay (and a 5V relay coil). >>> >>> Double check the connections before applying power. >>> >> ----------- >> should i reduce the resistor value ? > > yes, the too high a resistor can cause excessive heating in the > transistor, and then the transistor fails. > >> Am asking because i have made the pcb and i have to test it today and >> i dont have 0,5K near me. I have to buy it tommorow > > Anything in the 200 Ohms to 600 Ohms range will suffice, > eg: you could parallell two 1K resistors to get 500 Ohms. > or use a 330 or a 470 if you have them on-hand. >
---------------------- OK i can do that but i dont understand one thing: Dont i need to change R1 from 1 to 1,2 KOhm ? Because ih i leave it at 1K the base current will be 2,6mA instead of 2mA. If the raspbery PI port can handle and give this much or current then there is no problem. Nothing should burn out ... OR am i missing something ? /////////////// BTW. is someone of you working in Python ? ///////////////