Very simple timer circuit

TCLynx

Member
I just got my first picaxe 08M chip with a USB cable and the programing project board. Didn't come with much of anything else.

I managed to program it to the very simple timer sequence I want.

Now I just need to sort out what other parts I need to finish making the timer circuit I want.

I think I can find all the parts for the power supply side of things.

Challenge I'm having is finding the transistors for the output side of things since radio shack here in the USA apparently doesn't carry the BCX38B like listed in the manual.

I will be using a 12 volt relay to switch the mains power (unless I come across something that would operate on a lower voltage closer to what the control circuit needs but still be able to handle switching up to 3-4 amps of 120 volt mains power.)

Can anyone share with me tips for figuring out what alternative components would be appropriate in this situation.

As I said, I'm starting out very very simple. I'll be turning on and off a small pump on a 5 minute schedule (as in 5 minutes on, 5 minutes off, repeating.)
I've gotten the chip on the programing board to turn the red led on and off according to the schedule I want.

I've got some power supplies and I picked up a voltage regulator and I think I have the rest of the parts (caps) to handle the power input side of things.

I've got an assortment of relays and can easily find more.

I have diodes and resistors

I just don't know much about transistors. (my earliest tinkering with electronics has been with 555 timers which can handle enough power not to need the transistors between it and the relay.

There are some transistors in the junk box. What do I need to know to figure out if any of the ones I have on had will suite my purposes?

I've got some TIP102G and TIP107, are they of any use to me or should I save them for the original project they are meant for? I can go to Skycraft to find more parts but I need to have some options since they are a surplus place and don't always have "everything" but they generally have lots of different things.

Thanks
TCLynx

Be gentle, I'm not all that well versed in electronics lingo (I'm a stagehand/audio engineer for corporate meetings by profession which means I probably won't kill my self when handling electricity but I don't want to fry the chip I'm playing with either.)
 

eclectic

Moderator
@TCLynx

This section is for finished projects.
You'll get a better response posting in
the Main / Active Forum

And welcome to the Picaxe Forum. :)

e
 

BeanieBots

Moderator
Welcome to the forum.
I've moved your thread to the active forum where it will get more attention.

For your transistor you will be spoiled for choice.
You need to know what current the relay coil pulls when energised.
That will define the required current handling of the transistor.
To make a transistor 'sink' an amount of current, you need to put current into the transistor base. There is a characteristic of transistors called "hfe". The collector current is hfe*base current.

Most (small signal) transistors have an hfe of about 100 and a typical relay coil current will be about 30mA so you would need about 300uA of base current. From a PICAXE at 5v that means you would need a base resistor of about 15k to give the right current. (a 10k would be a safe bet).

If you are using a bigger transistor from an old junk box, the hfe is likely to be a lot lower (maybe only 30 or so) and you would need much more base current for the same collector current. Also, if your relay is a big mains switching device it might need much more than 30mA to pull in.

Hopefully, that is enough info for you to work out if what you have will work together OK. If not, let us know relay coil resistance and I'm sure some kind sole will look up your transistor specs and do the calcs for you.
 

TCLynx

Member
Thanks for moving to the appropriate place, I'm new here and was kinda in a rush as I posted earlier.

So now I'm trying to figure out the current requirements for the different relays I have on hand.
 

BeanieBots

Moderator
As i didn't recognised either of the transistor numbers you mentioned, I looked them up. They are both darlingtons with a gain of ~1000.
They are also both TO220 package and capabale of driving ~8A so there would be no problem driving them from a PICAXE and no problem with them driving the current for a relay coil. However, the TIP102G is NPN and the TIP107 is its PNP complement.

As you want to run your relays from 12v, only the TIP102G will be suitable and should be used open collector with the relay between 12v and collector.
I'd use a 10k base resisistor between PICAXE OP and base.
It's a bit of overkill for a simple relay but if you have one to hand... what the heck.
Don't forget to add a catch diode on the coil to avoid over-volting the transistor.
 

TCLynx

Member
I'm having trouble finding the info on this one Relay.
SRU-12VDC-SD-C

listed on the part is has
15A 125VAC / 10A 240VDC
10A 28VDC / 10A 28VDC

It's a relay from an adjustable interval timer kit that required a power supply of 12-15 VDC / 100mA The kit used a resistors and capacitors along with a 555 timer.

Anyone think that relay might work in my project? As in do you think I can find the appropriate transistors to operate it using the picaxe chip?

I have several TIP 102 and TIP 107 Transistors would they be appropriate?

I'm sorry I am trying to wrap my head around some of the math and figuring involved but I think my poor brain is frying (The Air Conditioning has quit and here in central Florida it's been getting up around 100 F the past several days. Repair crew should be in replacing AC tomorrow.) I think the future picaxe projects I might move on to next might be temperature sensors and loggers.)
 

TCLynx

Member
Thanks BeanieBots
I missed your post when I did my last one but looks like you have answered some of my questions.

Thanks
 

BeanieBots

Moderator
If you have an "unknown" relay coil, then simply measure the coil resistance using a DVM or similar.
Based on the assumption that they were happily driven by a 555 direct, then your TIP102G will be more than up to the job.

For your temperature/sensor logger, might I suggest the 18X powered AXE110 with a DS18B20 sensor and AXE033 LCD display for the readout.
 

jaka

Member
Don't use any old relay. A motor rated at 3 amps would quickly fry the relay contacts, because the motor starting current could be as high as 20 Amps. You should consider using a contactor.
 

TCLynx

Member
Jaka,
Your warning is appreciated. I would hope that using a relay with contacts that say they are rated for 15 Amps at 125VAC would be ok for starting a small pump (Seeing as I'm probably using a fairly small relay on it right now anyway since I'm using a store bought timer on it that is rated for 15 amps right now.)

But as I say, your warning is well taken and please tell me some more about using a contactor. Got any parts in mind to recommend or as an example? I'm all about learning about additional ways of doing things.

If I can figure out an easy way to run the whole control circuit on say 5 VDC and have it still able to control a switch of some sort for mains AC I would love that too. I'm aiming for simple compact and reliable at the moment.
 

jaka

Member
I don't know about the US but here in the UK, I would go to an electrical wholesaler and get a mini contactor.

All control equipment manufacturers produce them, Shneider (Square D), Cuttler Hammer etc. Smallest you will find will be rated at 9A. That means it is rated for a motor that has a running current of 9A max. Plenty big enough for you. Probably set you back about $US 40.

Smallest coil voltage will be 24V ac or dc. So you have 2 choices, dc and drive it with a hefty transistor or ac and drive it from a small relay at 110 V.
 

TCLynx

Member
Yea, I'm looking at running something that probably has a peak start up current of less than 3.5 amps, running current will be less. I'm not talking a big pump, I'm talking something too small to bother giving it a horse power rating and really energy efficient to boot.

Actually that bigger pump that spikes over 3 amps at start up I am only running for testing. The real pump that I normally run uses less than 50 watts once running and might spike .7 or .9 amps on start up but probably not even that much.
 

jaka

Member
ok. Then forget all the crap I have waffled on about. Have you considerd using a triac. Not my pet subject. Someone else will probably help you there, but from what I know, you could drive a triac directly from the picaxe, ie 5V.
 

TCLynx

Member
Triac those sound interesting.

Ok, anyone suggest how I should go about using one of these for using an 08M based timer to control mains 120 VAC that for a circuit that I'd like to figure could handle a 10-15 amp resistive load and a much smaller inductive load.
 

BeanieBots

Moderator
In a nutshell, DON'T.
A triac would be a nice simple solution but your PICAXE circuit would no longer be isolated from mains.
You could use opto isolators to drive it but your very question suggests that you are not 100% confident about how to do that so DON'T.

Another simple of-the-shelf option would be a solid-state relay.
These are readily available and offer isolation as well as zero volt power switching which helps with switching noise which can be a problem with any microprocessor, not just PICAXE.
 

TCLynx

Member
So here I am trying to figure out how to draw some basic circuit diagrams so people can check what I hope to do before I fry any chips.

I'm used to using pencil and graph paper but that is hard to view online.
 

Dippy

Moderator
Absolutely - as long as they're neat and not drawn by the pet chimp :)

Brace yourself for a list of freebie CAD drawing apps....
 

westaust55

Moderator
Triac those sound interesting.

Ok, anyone suggest how I should go about using one of these for using an 08M based timer to control mains 120 VAC that for a circuit that I'd like to figure could handle a 10-15 amp resistive load and a much smaller inductive load.
50 watts at 120 V ==> ~ 400 mA

so consider a MOC3061 or similar Opto-Triac.


Max cont current seemingly from curves 800 mA
Peak surge = 1,000 mA (= 1 A)


http://www.datasheetcatalog.org/datasheet/motorola/MOC3061.pdf
 

TCLynx

Member
Some questions that I'm not finding quick answers to from the manuals.

Seeing as once I sort out this project I won't be leaving it attached to the proto board but putting it on it's own board to run.

Manual says not to leave the serial in pin floating, does that mean simply the 22 k and 10 k resistors between in 2 and 0V?

for my bare bones basic operation, I really only need one output pin. Do I need to do anything with any of the other pins for operation?
 

westaust55

Moderator
As an absolute minimum, you should have the serial input pulled low.
My recommendation is to use a 10 kOhm resistor to pull down to 0V.

If you might ever want to use or have connected (even when not programming) a programming cable of any type then also add the 22 k Ohm resistor as well.

If the serial input is allow to go high the PICAXE firmware see this as wanting to download a new program and the progrma you have previously loaded will not run.
 

Dippy

Moderator
If you get hold of a programming jack socket and follow the manual for the input circuit then you should be fine. It kills 2 birds with one stone.

Don't forget the reset pin where relevant.
A lot of people like to pull up/down unused input pins.

But you really need to do some planning if using triacs.
If using an isolated (PSU) for your board then you'll need an opto-isolator triac driver.
If transformerless supply for the board you can drive the triac using a transistor as it will follow phase naturally.
However, I would avoid the latter.
AND NEVER try and conenct a programming lead into a live circuit. BANG!
Ditto 'scoped unless isolated or you have an expensive isolated/diff probe.

Maybe do as BB suggested and get a ready-made relay. Get some advice before diving into Mains.
 

TCLynx

Member
LOL, Switching mains power is actually the part I have the most experience with doing. What I'm inexperienced with is the control of such using a chip.

I've already hooked up many relays for various applications (like switching from mains to battery backup power but that was simple, when the wall wart hooked to the coil losses power, the relay switches to the power from the inverter and battery.

and as noted before, I've managed to get a 555 timer kit working with a relay. Pretty easy since the 555 can do the 12 volt.

Where I'm a bit lost is figuring out to safely (for the chip that is) make the control voltage/current operate whatever switching mechanism is most appropriate.

So, is the LM7805C voltage regulator going to get too hot if I hook it up to a 12 VDC power supply? Do I need to use the 9 V power supply I have on hand instead? If I use the 9 V power supply, Will I still be able to operate a 12 V relay coil? Who can point me at some good resources for learning these things.
 

Dippy

Moderator
"So, is the LM7805C voltage regulator going to get too hot if I hook it up to a 12 VDC power supply? "

- Dunno.
Post your proposed circuit showing exactly the components you have chosen.
How hot it gets depends on the Vdrop and Current consumed by load (and it).


"If I use the 9 V power supply, Will I still be able to operate a 12 V relay coil?"
- Dunno.
Some 'sensitive' 12V relays may have a range down to 9V. Get the Data Sheet on the relay you're interested in. A good data sheet should have this operational information.
Remember, relays need a bit of oomph to start them off. That may also limit your options on PSU choice. Relays can be tolerant but don't push your luck if you want reliability.

So, you're not using a TRiac or SSR then?

Give us the details if you want a detailed answer.;)
 

BeanieBots

Moderator
LOL, Switching mains power is actually the part I have the most experience with doing. What I'm inexperienced with is the control of such using a chip.
But you have used a 555 to 'control' it.:confused:
Experience switching mains but you don't know how to drive a triac:confused:

Don't you mean you know how to wire a relay to act as a switch as apposed to experience of switching mains? Sorry if that sounds rude but you have me a little concerned now if you are going down the route of triac switching with NO experience of solid state switching of mains and the isolation and control issues involved.
There's nothing special about a PICAXE output. It's just the same as any other (5v) logic signal that might be used for switching mains.

As for all your other questions, what Dippy has said. Without details, can't say.
 

TCLynx

Member
Yea, my terminology is probably quite wrong. I have experience wiring up a relay.
No I probably won't use a Triac. It was something some one mentioned and it sounded interesting so I asked for more info about it.

Most likely I will wire this up with a relay.

I drew out a diagram but now my firewall won't let my computer and scanner pay together again (I don't think I'm up to re-installing the software at the moment) so I might have to use paint to do it on the computer.

now that the Air conditioning has been replaced perhaps the indoor temp will start to come down and my computer won't be so uncomfortable to use. Maybe my brain will cool off enough to let me think straight soon too.


But you have used a 555 to 'control' it.:confused:
Experience switching mains but you don't know how to drive a triac:confused:

Don't you mean you know how to wire a relay to act as a switch as apposed to experience of switching mains? Sorry if that sounds rude but you have me a little concerned now if you are going down the route of triac switching with NO experience of solid state switching of mains and the isolation and control issues involved.
There's nothing special about a PICAXE output. It's just the same as any other (5v) logic signal that might be used for switching mains.

As for all your other questions, what Dippy has said. Without details, can't say.
 

TCLynx

Member
I just pulled out the meter and the relay that I couldn't find much info about.

On top it says 15A 125V so that seems to indicate that the contacts should handle the load I have planned for it.

The coil when I checked the resistance gave 322 ohms

When I hooked it to a 12VDC power supply and checked the current I got 44 mA

Will this relay work in the circuit I posted previously? Will that circuit work?

Any suggestions?
 

TCLynx

Member
Would a 2N6044 work instead of the TIP201G?

I looked up the data sheet but I don't really know what information I'm looking for to know. I'm thinking it would work and probably still be overkill but want to re-confirm with more experienced/educated people.
 

TCLynx

Member
inglewoodpete, much thanks for the suggestion, I'll have a look to see if I can get one of those. (trying to figure out what parts might work has been a challenge for me and the two parts I mention I just happen to have on hand at the moment.)

So I take it what I have will work at least until I can get something more appropriate. And a smaller part will be nice.
 

Dippy

Moderator
TC, whilst you are ordering things get yourself a plug-in breadboard then you can TRY these things out for yourself.
So MUCH quicker than posting at every stage...

I think your circuit is shown in parts in the Manual anyway so you are just about there anyway.

As IP says just about any 'signal' level NPN transistor will be fine.
Amongst these 145 examples you'll find that just about any will work.
http://uk.farnell.com/jsp/search/browse.jsp?N=500006+1004177+373620+401+567819+5114720&Ntk=gensearch_001&Ntt=transistors&Ntx=mode+matchallpartial&No=0&getResults=true&appliedparametrics=true&locale=en_UK&catalogId=&prevNValues=500006+1004177+373620+401+567819&filtersHidden=false&appliedHidden=false&originalQueryURL=%2Fjsp%2Fsearch%2Fbrowse.jsp%3FN%3D500006%2B1004177%26Ntk%3Dgensearch_001%26Ntt%3Dtransistors%26Ntx%3Dmode%2Bmatchallpartial%26No%3D0%26getResults%3Dtrue%26appliedparametrics%3Dtrue%26locale%3Den_UK%26catalogId%3D%26prevNValues%3D500006%2B1004177
... and there may be many more....
If they aren't what you want then go back and adjust the parameters - even if you don't buy from Farnell they have one of the best parametric search engines and stock ranges in the World.


On any PICAXE circuit with relays, motors or noisy things I would ALWAYS add a decoupling cap by the PICAXE as a matter of habit. 47nF Ceramic (X7R dielectric or better) is ideal. For the sake of 10 pennies it can prevent tears at bedtime.

My only extra suggestion, if it plays up, would be to add an electro cap between 12V and ground and placed at the 12V side of relay coil to ground.
This provides a little 'reservoir' for a) when the tranny switches the coil 'on' reducing surge in the 12V line, and b) When the coil switches off it'll absorb some of the back EMF.
Doing this can reduce the sparklies getting to your PICAXE.
It may be fine as it is already as the PCB layout will affect performance.
With your mains experience you will obviously know about keeping mains lines away from signal lines etc...
 
Last edited:

Jaguarjoe

Senior Member
You can use a 2N3904 available at Radio Shack (I think). Just change the 10k resistor to 4k7.
4k7 is not correct. Obviously, I didn't have enough beer when I figured this out. You will need a 1k resistor. Ic/beta= Ib. 44ma/10= 4.4 ma base current required. The voltage across Rb will be 5(picaxe output)-0.6(Vbe)=4.4 volts. R=E/I, R=4.4V/4.4ma=1000ohms. This true for the 2N3904 or the 2N2222. The 2N2222 is a much better choice than the 3904. It handles much more current and would be more useful to you. Radio Shack sells them for 79 cents each. They call them MPS2222A.
 

TCLynx

Member
Again, much tanks for the suggestions.

I'm uploading another diagram. I've also added a couple LEDs so I can see that the chip has power and to show when the relay should be powered.

I wasn't sure what resistor values should be so I was kinda guessing based on what I've seen work in other circuits.

let me know if I've placed the caps correctly to provide the protection I want.

I put green boxes around the stuff that is added or changed.

Oh, and I will test it all out on a bread board before doing any soldering. Actually I have most of it already layed out but I need to get a few parts before I will be able to finish it up for testing.

Once I'm satisfied that it work, I will then see about soldering it all onto a smaller board and putting it into a project box.

Once upon a time I was really really good at soldering but that was mostly a slightly different kind of soldering. I've only done a few projects that involved attaching components to circuit boards. Will definitely need dust off those skills a bit as they have been stored in the back of the tool box since before graduation and I'm not entirely sure I wish to say how long ago that was.
 

Attachments

Last edited:

inglewoodpete

Senior Member
I've also added a couple LEDs so I can see that the chip has power and to show when the relay should be powered.

I wasn't sure what resistor values should be so I was kinda guessing based on what I've seen work in other circuits.
The resistors I would choose are:
5v to a red led (5v-2v=3v, R=E/I=3v/10mA=300 ohms, P=EI=3x10mA=30mW) Use a 330 ohms 1/4W.
12v to a red led (12v-2v=10v, R=E/I=10v/10mA=1000 ohms, P=10x10mA=100mW) Use a 1 kohm 1/4W.

The capacitors look OK on the circuit diagram, except for the 47n on leg 6. I'm not sure why you put it these but all it would do is cause a current spike on the PICAXE output pin whenever the output turned on or off. Did someone suggest you put it there?

Far more important is where the caps are physically located in the circuit (Ie the real thing). Re-read Dippy's post on the subject.
 
Last edited:

MartinM57

Moderator
I'd bin the 47n and replace it with a 100k (or 47K or 220K or something like that) resistor to hold the transistor base low during the times that the PICAXE output is floating - a bit undefined when this happens, but best to be safe than sorry...
 

TCLynx

Member
I'd bin the 47n and replace it with a 100k (or 47K or 220K or something like that) resistor to hold the transistor base low during the times that the PICAXE output is floating - a bit undefined when this happens, but best to be safe than sorry...
So get rid of the cap (I placed it there to protect the chip?) This is on the suggestion of others because I am really not well educated in circuit design on this kind of scale, and pull it low with a resistor?
I'm willing to try it out.
 

Dippy

Moderator
I agree, except I would move that 47nF from where it is and stick it across the +v/0v PICAXE pins - that is what 'decoupling' the PICAXE means.
As close to pins 1 and 8 as possible.

Decoupling essentially 'diverts' HF spikes down to ground so they don't get into the chip. Read up on capacitors and types.

It doesn't protect the chip where you currently have it. How can it?

Now you should be in a position to calculate apprx the total current draw and then calculate if your voltage regulator will get hot.

To calculate the LED resistors is basically:
ResistorR = (Vsupply- Vdroptotal) / Itarget.

Vsupply is the Supply Voltage (NSS!!)
Vdroptotal is the total volts dropped across the LED forward volts drop + anything else in line e.g. transistor.
Itarget is the desired current. For standard LEDs this may be 10mA to 30mA. For high-brightness LEDs you can have nice bright indicators at 5mA or less.
 

TCLynx

Member
I agree, except I would move that 47nF from where it is and stick it across the +v/0v PICAXE pins - that is what 'decoupling' the PICAXE means.
As close to pins 1 and 8 as possible.

Decoupling essentially 'diverts' HF spikes down to ground so they don't get into the chip. Read up on capacitors and types.

It doesn't protect the chip where you currently have it. How can it?
That is why I posted the changes, so some one would correct me:rolleyes:

So Dippy, do you agree I should put a big resistor where I currently had the 47n?

And for the cap between the +V/0V pins, is the size and type important?
I'm not finding any 47n in my trick bag (what would 47n be if labled as u, would it be .047u? I seem to have lost track of the decimal point.)
Would it be ok to use a 100n cap there or what range would be appropriate?
 
Last edited:
Top