3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Control real world devices with your PC

Step 15Controlling devices

Controlling devices
The picaxe help file contains a great explanation of how to control motors and lights. In addition I find there are a few circuits I use over and over.

The first is a simple transistor circuit. A picaxe chip can turn on a maximum of 20mA per pin which is good for turning on a LED but not much else. A 547 transistor increases the current to 100mA which is good for small light bulbs.

The second circuit shows a mosfet. Mosfets need virtually no current to drive them - only volts so they can be directly controlled by a picaxe. There are all sorts of mosfets available but my preference is one called the BUK555 60B http://www.ortodoxism.ro/datasheets/philips/BUK555-60A.pdf It can be directly driven from 5V (unlike some which need 10V) but the main advantage is it has an extremely low resistance when turned on - 0.045 ohms which is not much more than the resistance of the wires one would connect to it. This means it doesn't get hot when driving quite high loads which saves power and also saves on heatsink costs. As an example driving a 5amp load like a car headlamp; watts=current squared x resistance, so W=5*5*0.045=1.12 watts which would only need a heatsink like a 1inch square piece of thin aluminium.

The third circuit shows a relay. There are several parameters for all relays - the coil voltage, coil resistance and the load voltage and current. For instance a relay might have a 12V coil with a coil current of 30mA, coil resistance of 400 ohms and might be able to drive up to 240V at 1 amp. The coil current is more volts and amps than a picaxe can supply, so we use the transistor circuit to switch the coil. There is a diode included as well - this supresses the back EMF when the relay turns off. Back EMF is what creates the spark for a sparkplug so you don't want these high voltages anywhere in a circuit. The contacts will have a maximum current and volts - the current might be a few amps and the volts are often 240V so switching 12V or 24V will be well within range. If you are inexperienced with electronics don't play with mains voltages.

There are also small relays that have coil voltages of 5V or 6V. For these relays you may not need a seperate 12V supply but just watch the coil resistance as many of these have current draws of over 100mA. If so and you are using a 78L05 100mA 5V regulator you might want to change this to a 7805 regulator which can supply up to 1 amp.

Relays are particularly useful for switching AC - eg 24VAC garden sprinkler solenoids, 12VAC garden lights and in electrically noisy environments such as a car. They are also useful for controlling big loads, eg a picaxe supplying 20mA at 5V = 0.1W controlling a transistor 12V at 100mA=1.2W to a relay 24V 100mA =2.4W to a contactor driving a 3600W pump. If you want to control power like that then get an electrician to wire up a control box and give you two wires coming out (coil wires for a 12V relay) that you can control. This way the electrician can sign off on the power box and you can do all the electronics without having to worry about being electrocuted.

Another use for relays is a reverse control for a motor. Using pulse width modulation into a mosfet you can control the speed of a DC motor, and with a DPDT power relay you can change the direction. This is a simple way of controlling big motors like the ones used in 'robot wars'.

Please post a comment if you need help building something.
« Previous StepDownload PDFView All StepsNext Step »
26 comments
Sep 8, 2010. 5:50 AMtanntraad says:
Hi! Great info here! I wonder if you know the answer to my question; How do you avoid a common source when using multiple mosfet's on a picaxe? We have a good discussion here down in the comments; http://www.instructables.com/id/Make-a-remote-controlled-camera-from-a-cellphone!/

The problem is interfacing them with a matrix..
Any help is welcome :)

Aug 18, 2010. 12:46 AMdialup_prisoner says:
Thanks for the info Dr_Acula. I'm looking at the mosfet control circuit at the end of the article - am I correct in assuming that you need NO other components to drive a mosfet? I'm working on a picaxe-based home-brew heater and need to switch a 2A resistive heater at 12V. I'm not doing anything fancy like PWM control, just a simple thermostat. Thanks for your help! Nick
Aug 18, 2010. 3:37 AMJames Moxham says:
Yes, no extra components required for a mosfet, but you do need to pick the right mosfet. You need one with a gate drive of 5V. Some need 10V and will partially turn on at 5V but get very hot. The picaxe manual has some more "up to date" ones than the BUK555. I do kind of like the BUK555 though - it can switch a car headlamp 60W and only get slightly warm.
Aug 18, 2010. 4:41 AMdialup_prisoner says:
Wow, thanks for the really quick reply! I'm guessing that's the "gate threshold voltage" in the datasheets? I'm looking at the BUZ-71 from Jaycar at http://www.jaycar.com.au/products_uploaded/BUZ71.pdf This has a gate threshold voltage of 2.1 to 4V, which sounds like it'll be just right for a picaxe driven from a 7805 regulator. The picaxe manual suggests an IRF530 but none of the big .au retailers seem to carry this part. Thanks, Nick
Aug 18, 2010. 5:12 AMJames Moxham says:
That looks ok - give it a try.
Aug 17, 2010. 10:03 AMstevehutton says:
Hi this looks really useful stuff. I'm trying to control a cdrom stepper motor using a L293 d driver and picaxe. i've downloaded some code that includes "sending a serial input to input 0 (pin 17) in the form of three bytes: The first is a qualifier – 85 uniquely identifies this stepper motor – the second is the number of steps – 0-255, and the third is the speed – 0-127 is backwards, 128-255 is forwards". Can you tell me how to use the serout command to do this please. Thanks loads
Aug 17, 2010. 4:36 PMJames Moxham says:
Where is the code going from and to? If it is from the PC to the picaxe then to the stepper motor, then it will be Serin on the picaxe. The syntax will be very similar to that posted here, but I just want to check first where the data is going from and where to.
Aug 18, 2010. 2:00 AMstevehutton says:
Thanks for early reply James. All the code will sit in a picaxe 28 and outputs will be sent to the L293D. Here’s the full comment attached to the code I’ve downloaded ( and successfully loaded): “Note that this program is designed to wait until it detects a serial input on input 0 (pin 17) in the form of three bytes: The first is a qualifier – 85 uniquely identifies this stepper motor – the second is the number of steps – 0-255, and the third is the speed – 0-127 is backwards, 128-255 is forwards” So it seems straightforward(ish) I have one pin say pinX that sends this output (presumably as a serout command) to pin 17 and another pin say pin y that tells pin x when to send that command (i.e when it goes high) . Its just that the forums and picaxe manual I’ve looked out seem to assume I know what the syntax and overall meaning of the instructions is all about. The code comes from this page; http://dmt195.wordpress.com./ Thanks again for helping. Steve
Aug 18, 2010. 3:45 AMJames Moxham says:
Take a look at step 5 - for serin the bracket goes round the "data" and then the variables are outside the bracked. But for serout the bracket goes round the whole set of variables. Just one of those programming quirks I guess.
Aug 18, 2010. 3:42 AMJames Moxham says:
Sounds a pretty standard picaxe circuit. The picaxe forum has got rather prickly lately. You don't need a flameproof suit but you might need a flame retardant one. Serin and serout need the commas and the quotes in the right place.
Sep 30, 2009. 9:22 AM3dotter says:
Hi Dr_Acula (Shark in Russian?), I am new to Picaxe. I like to start a GSM modem (old, but very good Siemens M20 terminal) with a mosfet when the PICAXE senses that a magnetic reed switch has been activated. Then the PICAXE should give Hayes AT commands over the serial line to the modem (through a MAX232 level converter) to 1. register the modem on the GSM network, 2. to give the right SIM card's PIN code and 3. finally to start a phone call to 3 phone numbers listed on the number 1 - 3 positions of the SIM card's phonebook. Such AT command is simple: AT>n, where n is the position of the phone number in this phonebook. Please help me with setting up this PICAXE code. Thanks in advance!
Oct 2, 2009. 6:35 AM3dotter says:
Great! Thanks.

Here they are. In front of the relevant AT commands I have typed here serout -> or serin -> to show you what goes out and comes in as answer from the modem

serout -> AT+CREG=2
serin -> OK
serout -> AT+CREG?
serin-> +CREG: 2,0

serout ->AT+CPIN=2004
serin -> OK

serin -> +CREG: 2

serin -> +CREG: 5

serin -> +CREG: 5,"11BA","2F00"

Above were relevant AT commands to register the modem to the GSM network. Below are 2 types of sending an alarm phone call:

1. with number:

serout -> ATD 0592170185
serin -> NO CARRIER

2. with number from first postion of SIM's phonebook:

serout -> ATD>1
serin -> NO CARRIER

The 'NO CARRIER' is good here, because it shows that the person who was called did not pick up the phone.
Oct 4, 2009. 11:40 AM3dotter says:
Hi Dr_Acula, Few more questions. To which pins of the PICAXE can the serin and serout commands be given? Is there a need to use the same pins which are used for programming the picaxe or not? Can I show to you my eagle PCB design files for review? That would be great. :)
Oct 2, 2009. 8:09 AM3dotter says:
Thanks! That is very helpful :)
Aug 9, 2008. 3:51 AMcpaynebarnes says:
Great info. I am interested in building a differential temperature pump controller for a solar hot water system. Basically it turns on a 1/6 hp pump when the temp of the solar panels exceeds the temp of the water in a storage tank. Any thoughts?
Oct 5, 2008. 6:10 PMsunworks says:
Any update or notes / pictures / details you can share on building adifferential temperature pump controller for a solar hot water system? I've been looking for a long time for instructions on how to do this or get enough help / details where a couple of us can get this accomplished. Has this project accomplished what you want? Are you looking at adding features? What proto board did you use? Actually, I'd like to start by making a differential control for a hot-air solar system, but understand these are nearly identical apps. Thanks for any additional info.
Oct 6, 2008. 10:58 PMcpaynebarnes says:
I have not moved forward on my differential temp controller but I am considering using the Arduino or Freeduino platform. I would like to integrate a woodstove in the water heating process so more pumps and more temps means more inputs and outputs. I may use this hot water for space heating too so room to expand would be nice. Building the system I describe would need at least 3 off the shelf DTC's to do the job when a home built one could do it more elegantly and, more importantly, cheaply.
Oct 4, 2008. 12:08 PMUnit042 says:
"watts=current squared x resistance"
Huh? I was taught that watts = volts x amps.

Suggestion: Excellent instructible. Pictures where appropriate, and step-by-step instruction. I've been wanting to make things move with a click of the mouse, but wasn't sure how. I have a few picaxes "fresh outta the box", so this is perfect for them. Perhaps a line-by-line explanation as to what the VB code does. If you could do that, then those familiar to programming can translate it to their favorite language or simply add on to the code provided.
Oct 4, 2008. 5:33 PMUnit042 says:
Quite an answer! I suppose you get that question a lot. Now, how does I get squared all of a sudden?
Oct 4, 2008. 5:37 PMUnit042 says:
Oh, wait...
V=I*R
W=V*I
substitute V's equivalent (I*R) for:
W=(I*R)*I

Now I get it! Oh, my brain, MY BRAIN!!!!

Is it just me, or is thinking harder on Saturdays?
Oct 5, 2008. 6:36 PMUnit042 says:
Stumbled across a tidbit... some guy uses PHP to control his serial port success fully:
http://www.communitymx.com/content/article.cfm?page=2&cid=8658A

I don't know a lick of PHP, and this application of it makes this language worth taking a look at.
...After looking at the following link, the language looks much more complicated and hard to learn. Maybe I should look up a few books from my library.
http://en.wikipedia.org/wiki/Php


Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
29
Followers
3
Author:Dr_Acula