Using a BCX38C to control a reed relay

FIREMANJIM

New Member
I am using a BCX38C to control the Reed Relay. When the pin on the Picaxe 20m2 is low is there any current draw from the picaxe circuit? I tied a 10k resistor to ground to make sure when the pin goes low the transistor should close all the way. I need all the battery life I can save so I dont want any current draw from the reed relay when the pin is low....Hope this makes sense....I tried to upload a image but it keeps failing to upload for some reason....
 

westaust55

Moderator
See page 8 in the PICAXE manual part 3:
http://www.picaxe.com/docs/picaxe_manual3.pdf#page8

In reality with a BJT type transistor the 10 kOhm pulldown resistor is not required when the PICAXE pin is driven low.
However, to cover the time from circuit energisation until the PICAXE pin is set as an output, that is when the pin is an input, the transistor base is floating so the 10 kOhm resistor ensures the transistor is held in the Off state until the PICAXE program has control.

I trust that you also have a resistor between the PICAXE pin and the transistor base - 1 kOhm is a fair starting point.
Also a free wheeling diode across the relay coil as show on the above mentioned manual page.
 

FIREMANJIM

New Member
Thanks for the replies. Yes I have the diode in place. Yes I have the 1k resistor between the transistor base and the picaxe pin. My concern is will it pull any voltage when the pin is pulled low and the relay is open?
 

premelec

Senior Member
Thanks for the replies. Yes I have the diode in place. Yes I have the 1k resistor between the transistor base and the picaxe pin. My concern is will it pull any voltage when the pin is pulled low and the relay is open?
When the PICAXE pin is LOW no current should come from that pin being connected... [assumes NO relay]
 

rq3

Senior Member
I am using a BCX38C to control the Reed Relay. When the pin on the Picaxe 20m2 is low is there any current draw from the picaxe circuit? I tied a 10k resistor to ground to make sure when the pin goes low the transistor should close all the way. I need all the battery life I can save so I dont want any current draw from the reed relay when the pin is low....Hope this makes sense....I tried to upload a image but it keeps failing to upload for some reason....
No transistor is a perfect switch, but for your application the one you have selected is probably as close as you can get. Worst case, the low Picaxe pin MIGHT leak 100 nanoamp from the transistor base in the transistor off condition. The data sheet is a bit squirrely on this, as are most.

If you really, really, really want to make sure the transistor isn't drawing current from the Picaxe pin, use a Mosfet. They are voltage driven at the gate, rather than current driven at the base. In other words, unless they are driven quickly, they draw almost unmeasurable leakage current at the gate (picoamps). In other, other words, the moisture on the surface of your circuit may conduct more current than is required to turn the Mosfet on or off.

Search on "logic level Mosfets".

For perspective, a 1 amp hour battery will drive 100 nA for about 10 million hours, or about 1200 years. Back of the napkin calculations.
 

inglewoodpete

Senior Member
No transistor is a perfect switch, but for your application the one you have selected is probably as close as you can get. Worst case, the low Picaxe pin MIGHT leak 100 nanoamp from the transistor base in the transistor off condition. The data sheet is a bit squirrely on this, as are most.
Very true. Since BJTs are current driven devices and the BCX38C is a darlington transistor, you will need around 1 volt on its base to start to turn it on. This is not going to happen when the PICAXE's pin, set as an output, is low. Also, if the PICAXE pin is set as an input will not develop anywhere near enough current to leak through the base of the darlington and affect the life of your battery.

A 10k resistor to ground is a waste: you only need the 1k series resistor to limit the base current when the PICAXE's output is high.
 

FIREMANJIM

New Member
Thank you Inglewood Pete... Can you recommend a suitable Mosfet for the job with a TO-92 pattern? I have already ordered my PCBs
 

inglewoodpete

Senior Member
Perhaps my waffle above was interpreted as negative? My suggestion would be to stick with the BCX38C - rated at 800mA maximum, just don't include the 10k resistor to ground. The 2N7000 is rated at 200mA maximum but why change if you already have the darlingtons?
 

AllyCat

Senior Member
Hi,

IMHO 1k in series with the base is far too low, that's around 4 mA of "unnecessary" drain when the relay is on. Presumably the relay needs a few tens of mA, so 100 uA (say 33k) should be sufficient to drive a darlington (unless it has its own internal base pull-down resistors)? If you need a low "saturation voltage" then you shouldn't be using a darlington at all, because the extra Vbe "loses" 500 mV or so across C-E. In that case use either a single bipolar (eg BC548/337) or a logic-level FET (eg 2N7000).

As already said, if the base is held below a few hundred mV (whether by the PICaxe or a pull-down resistor) then the leakage current will be negligible, so you only need to consider the current drain by the PICaxe itself (and any other peripheral components).

Cheers, Alan.
 

AllyCat

Senior Member
Hi,

That should work fine with a 5 volt supply. However, with a 4.5 volt Alkaline (or similar) battery, I'd probably use the 4.5 volt relay coil version and/or a BC548 (or similar) driver, to be safe.

Cheers, Alan.
 

erco

Senior Member
By reed relay standards, the one you picked is a current hog at 36 mA. Most of them are delicate little things with low-current coils, ~20 mA.

The only time I use a reed relay is to drive it directly from an output pin in order to avoid using a switching transistor. Zero current draw in the off condition. Here's one with a 500-ohm coil which draws only 10 mA on 5V: https://www.mouser.com/search/ProductDetail.aspx?R=0virtualkey0virtualkeyHE751A0500 . When you go this route it's best to wire it active low, since a Picaxe pin can sink more current than it can source. Best practice would be to use a flyback diode across the coil, as with all relays. (Do as I say, not as I do...)

The very light, occasional usage you described is perfect for just such an application. Even if you COULD sink more than the rated 20 mA (would a dead short exceed 20 mA in a 5V Picaxe?), the brief 1.2 second intervals wouldn't allow any damage to happen.
 

FIREMANJIM

New Member
The board is powered by a 9v battery. Runs through a 120ma 5v LDO voltage regulator. The picaxe as well as the reed relay are powered from the 5v side of the regulator. So knowing that do you reccommend the 5v reed or the 4.5v reed?
 

AllyCat

Senior Member
Hi,

I need all the battery life I can save so I dont want any current draw ...
Which Voltage Regulator? "LDO" is NOT the same as "Low Quiescent Current" and I don't know of any regulators that have a "no load" current drain as low as a transistor leakage or even a PICaxe sleeping.

Cheers, Alan.
 

erco

Senior Member
Hi,
"LDO" is NOT the same as "Low Quiescent Current" and I don't know of any regulators that have a "no load" current drain as low as a transistor leakage or even a PICaxe sleeping.

Cheers, Alan.
+1. Go with 3xAA or 3xAAA (no regulator) instead of 9V+reg, which will have a short battery life.
 

AllyCat

Senior Member
Hi,

Yes, that regulator should be fine and your proposal certainly should "work". But for longest battery life I'd prefer, say 3 x AAA Alkalines to a single PP3, since the AAAs will probably give around 5 times more Amp-Hours. However, it rather depends whether any (other) part of your circuit really needs a stabilised 5 volts.

Cheers, Alan.
 

inglewoodpete

Senior Member
The regulator that you have selected is certainly low loss. The question I have is "Why use a (series) regulator in a battery circuit?" Which leads to the real question "Why use a 9v power supply in a battery circuit when you only need 4 to 5 volts?"

While I don't know the full details of your device, my suggestion would be to limit your design to the essential components: PICAXE, low current 4.5 volt relay with quench diode, 2 x download resistors and 3 x AA or AAA cells. The 20M2 has lots of pins: do you have a need for anything more than an 08M2?

Forgive me if my thoughts seem critical. Perhaps I don't know enough about your project but sometimes we need to step back and rethink our goal and possible solution.
 

FIREMANJIM

New Member
The pins on the 20M2 are:
CDS power
CDS read
STATUS LED
CAM POWER
CAM SHUTTER
EXCHANGER DAY LENS
EXCHANGER NIGHT LENS
LED ARRAY POWER
MIC PREAMP POWER
PIR INPUT
DIP1
DIP2
DIP3
DIP4
 

FIREMANJIM

New Member
The PIR circuit senses a animal walk by.. Turns on the camera power through a opto. I couldn't get the opto to activate the shutter so I had to use a Reed relay. The cds circuit determines if it is night or day outside. If it is night it turns on a black flash led array. The dip switches allows me to control the length of the videos 15 sec to 3 minutes and they allow me to control the delay between the videos... Hope all this makes sense.
 

premelec

Senior Member
How low RESISTANCE will activate your shutter? [the relay is close to zero R and will bounce some - I'm wondering if an opto with MOSFET could work well... ] - an interesting project!
 

FIREMANJIM

New Member
Here is the code that runs the board:
Code:
#REM
Programming for the CritterGetterPROVIDEOv10.0 for a DXG-125v
#ENDREM
Symbol CDSPwr = B.0
Symbol CDSRead = B.1
Symbol LED = B.2
Symbol CamPwr = B.3
Symbol CamSht = B.4
Symbol ExcDay = B.5
Symbol ExcNight = B.6
Symbol Array = B.7
Symbol Mic = C.0
Symbol CamPwr2 = C.1
Symbol CamSht2 = C.2
Symbol PIRInput = PinC.3
Symbol DIP1 = PinC.4
Symbol DIP2 = PinC.5
Symbol DIP3 = PinC.6
Symbol DIP4 = PinC.7
'List Outputs as outputs and make them low
Low CDSPwr
Low LED
Low CamPwr
Low CamSht
Low ExcDay
Low ExcNight
Low Array
Low Mic
Low CamPwr2
Low CamSht2
'List Inputs as inputs
Input C.3
Input C.4
Input C.5
Input C.6
Input C.7
'List the Bit variables
Symbol DayStatus = Bit0
Symbol CameraOn = Bit1
Symbol ArrayOn = Bit2
'List the Byte variables
Symbol DaySetting = B4
Symbol NightSetting = B5
Symbol LightLevel = B6
Symbol Counter = B7
' Set Word Variables
Symbol RecordTime = W8
Symbol DelayTime = W9
Symbol ShutterDelay = W10
Symbol WalkTestTimer = W11
Symbol CheckCDSTimer = W12

Disablebod
' Set Default Variables
DayStatus = 1
ArrayOn = 0 
DaySetting = 128
NightSetting = 117
WalkTestTimer = 0  
CheckCDSTimer = 0 
ShutterDelay = 1800
Nap 5
If DIP1 = 1 And DIP2 = 1 Then                           '15 sec
   RecordTime = 7
ElseIf DIP1 = 1 And DIP2 = 0 Then                           '30 sec
   RecordTime = 14
ElseIf DIP1 = 0 And DIP2 = 1 Then                           '1 min
   RecordTime = 27
ElseIf DIP1 = 0 And DIP2 = 0 Then                           '2 min
   RecordTime = 53
EndIf
Nap 5
If DIP3 = 1 and DIP4 = 1 Then
    DelayTime = 1
ElseIf DIP3 = 1 and DIP4 = 0 Then
    DelayTime = 14
ElseIf DIP3 = 0 and DIP4 = 1 Then
    DelayTime = 27
ElseIf DIP3 = 0 and DIP4 = 0 Then
    DelayTime = 78
EndIf
Nap 2
'turn on camera and array to test
         
High LED
Pause 1000
High Array
ArrayOn = 1
Pause 1000
high CamPwr
pause 500
low CamPwr 
sleep 5
high CamPwr
pause 1000
low CamPwr
Pause 50
Low Array
ArrayOn = 0 
Pause 1000
Low LED
sleep 2
pause 1000

WalkTest:
    nap 2 ' nap for 72ms .072 seconds
         if PirInput = 1 then
            high LED
               nap 6                     ' pause low power for 1.1 seconds
            low LED
            nap 8                     ' pause low power for 4 seconds
            WalkTestTimer = 0
      endif
      if WalkTestTimer >= 416 then           ' approx 30 seconds 
           let b9 = 10
               for Counter = 1 to b9
        high LED
        pause 200
        low LED
        pause 200
        next Counter
            pause 1000
            goto CDSCheck
    endif
    WalkTestTimer = WalkTestTimer + 1
    goto WalkTest
    
CDSCheck:
      high       CdsPwr                    ' apply power to CDS sensor
         nap 5     ' allow power to settle
      readadc                CdsRead, LightLevel
      low CdsPwr
      if LightLevel < NightSetting then
              DayStatus = 0
               CheckCDSTimer = 0
    endif
    if LightLevel >= DaySetting then
        DayStatus = 1
        CheckCDSTimer = 0 
    EndIf
    Pause 1000
    SetInt %00001000,%00001000

MainProgramLoop:

CheckCDSTimer = CheckCDSTimer + 1
If CheckCDSTimer >= 4160 then             ' check time every  5 minutes
      high       CdsPwr                    ' apply power to CDS sensor
         nap 5     ' allow power to settle
      readadc                CdsRead, LightLevel
      low CdsPwr
      if LightLevel >= DaySetting then
              DayStatus = 1
               CheckCDSTimer = 0
    endif
    if LightLevel < NightSetting then
        DayStatus = 0 
        CheckCDSTimer = 0
    EndIf
endif

Nap 2
GoTo MainProgramLoop

Interrupt:
If DayStatus = 0 Then        
    High Array
    ArrayOn = 1
    Pause 500
EndIf
High Mic
Pause 500
High CamPwr
Pause 1000
Low CamPwr
Pause ShutterDelay
High CamSht
Pause 1300
Low CamSht
Sleep RecordTime
High CamSht
Pause 3000
Low CamSht
If ArrayOn = 1 Then
    Low Array
    ArrayOn = 0 
    Pause 500
EndIf
Low Mic
Pause 2000
High CamPwr
Pause 1000
Low CamPwr
Pause 1000
Sleep DelayTime
SetInt %00001000,%00001000
Nap 2
Return
 
Last edited by a moderator:
Top