This Instructable shows you how to interface a PC and microcontroller. This demo will sense the value of a pot or any analog input and also control a servo. Total cost is under $40 including the servo. The servo turns on a microswitch and then the microswitch turns on a lamp. In a practical application the pot could be a temperature sensor and the servo could be turning on a heater. The servo could be replaced with a relay or other power controller. The picaxe is programmed in a simplified version of basic and the interface uses VB.Net. All software is available for free.

A related Instructable shows how to link two microcontrollers via the internet http://www.instructables.com/id/Worldwide-microcontroller-link-for-under-20/

Step 1: Gather the parts

Parts list:

Picaxe 08M chip available from many sources including Rev Ed http://www.rev-ed.co.uk/picaxe/ (UK), PH Anderson http://www.phanderson.com/ (USA) and Microzed http://www.microzed.com.au/ (Australia)

Protoboard, servo, microswitch, 9V battery, 4xAA batteries and holder, tag strip, 10k resistor, 22k resistor, 33uF 16V capacitor, 0.1uF capacitor, 7805L low power 5V regulator, 10k pot, wires (solid core telephone/data wire eg Cat5/6), 6V lightbulb, D9 female socket and cover, 2 metres of 3 (or 4) core data wire, battery clips

The above companies also sell USB to serial devices which are useful for laptops which don't have a serial port. It is worth noting that some USB to serial devices don't work as well as others and it is worth getting one from one of the above suppliers as they have been tested for use with picaxe chips. The one that is known to work is http://www.rev-ed.co.uk/docs/axe027.pdf Of course, if your computer has a serial port (or an old serial port card) then this won't be an issue.
hmm. Getting fairly lost with the servo business... It'd be really helpful to have a scaled down version of this tutorial so that a button comes on screen, you press it... an led illuminates. <br> <br>So damn simple, that when constructed by an idiot like me... I'd actually learn from it's simplicity... <br> <br>Thanks though :)
Will this work with a PICAXE 28x1 chip and using Visual Basic 2010?
1st of all:<br>thanks for this interesting tutorial !<br><br>unfortunately (on this tutorial's behalf) <br>i am a macintosh user ....<br>i managed to rebuild the visual basic part via word<br>(via &quot;tool/macro/visual basic editor&quot;)<br>but<br> receive the message &quot;invalid outside procedure&quot;<br>when running the script.<br><br>dioes anyone know how to translate<br>the visual basic part into &quot;mac-able&quot; code<br>or <br>use an alternative way to handle the <br>internet connection?
Why is no rs232 level converter necessary here?
Almost all computers now support TTL. The adapter sold by rev-ed does as far as I'm aware.
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; <a href="http://www.instructables.com/id/Make-a-remote-controlled-camera-from-a-cellphone!/">http://www.instructables.com/id/Make-a-remote-controlled-camera-from-a-cellphone!/</a><br> <br> The problem is interfacing&nbsp;them with a matrix..<br> Any help is welcome :)<br> <br>
Everyone can agree on the benefits <a href="http://www.cheap-uggs-boots.com/ultra-tall/" rel="nofollow"><strong>UGG Ultra Tall</strong></a> of music lessons for kids. In particular, piano lessons <a href="http://www.cheap-uggs-boots.com/ultra-tall/" rel="nofollow"><strong>Ultra Tall Boots</strong></a> have the most advantages. But, for the young student, music lessons can be a long, difficult undertaking. Parents thus need to do whatever they can to <a href="http://www.cheap-uggs-boots.com/ultra-tall/" rel="nofollow"><strong>Ultra Tall uggs</strong></a> encourage the student and make the experience pleasant. There are a <a href="http://www.cheap-uggs-boots.com/ultra-tall/" rel="nofollow"><strong>ugg 5245</strong></a> variety of things you can do, but one good strategy to start with is to make the student feel important. Create a mental picture <a href="http://www.cheap-uggs-boots.com/ultra-tall/" rel="nofollow"><strong>ugg 5245</strong></a> of their potential musicianship.
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
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 &quot;up to date&quot; ones than the BUK555. I do kind of like the BUK555 though - it can switch a car headlamp 60W and only get slightly warm.
Wow, thanks for the really quick reply! I'm guessing that's the &quot;gate threshold voltage&quot; 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
That looks ok - give it a try.
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 &quot;sending a serial input to input 0 (pin 17) in the form of three bytes: The first is a qualifier &ndash; 85 uniquely identifies this stepper motor &ndash; the second is the number of steps &ndash; 0-255, and the third is the speed &ndash; 0-127 is backwards, 128-255 is forwards&quot;. Can you tell me how to use the serout command to do this please. Thanks loads
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.
Thanks for early reply James. All the code will sit in a picaxe 28 and outputs will be sent to the L293D. Here&rsquo;s the full comment attached to the code I&rsquo;ve downloaded ( and successfully loaded): &ldquo;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 &ndash; 85 uniquely identifies this stepper motor &ndash; the second is the number of steps &ndash; 0-255, and the third is the speed &ndash; 0-127 is backwards, 128-255 is forwards&rdquo; 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&rsquo;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
Take a look at step 5 - for serin the bracket goes round the &quot;data&quot; 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.
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.
BTW is there any simular mosfets to the BUK555 because you can't get them here in the UK.<br />
Looking at the picaxe circuits, they use the IRF530 and picaxe is from the UK so see if that one is available?<br /> <br /> 69p from Radio Spares. Threshold voltage for the gate of about 3V. http://docs-europe.origin.electrocomponents.com/webdocs/0791/0900766b807910f8.pdf&nbsp;&nbsp; Looks like an even better substitute as it is much cheaper than the BUK555.<br />
Is there any way of separating out the pot readings from the line and put it in a seprate label by itself ?<br /> Thanks<br /> p.s.Great project !!!!!!!<br />
<p>current squared x resistance = volts x amps<br /> <br /> &nbsp;- Because volts = amps x resistance.<br /> Therefore watts = amps x resistance x amps<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = amps squared x resistance</p>
hello, can i integrate it on mplab IDE compiler? using your codes?<br />
&nbsp;Um, blue arrow? Where?
Yes, the latest version of the picaxe software has changed the screen layout. There is still a download button but the screen looks different. Or select download from the program menus.&nbsp;
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!
I don't know anything about AT commands. But the picaxe can certainly send simple strings of serial data with the SEROUT command. Baud rate up to 2400 baud. If you can supply the serial strings you want, I can translate that into SEROUT code that the picaxe uses.
Great! Thanks.<br/><br/>Here they are. In front of the relevant AT commands I have typed here serout -&gt; or serin -&gt; to show you what goes out and comes in as answer from the modem<br/><br/>serout -&gt; AT+CREG=2<br/>serin -&gt; OK<br/>serout -&gt; AT+CREG?<br/>serin-&gt; +CREG: 2,0<br/><br/>serout -&gt;AT+CPIN=2004<br/>serin -&gt; OK<br/><br/>serin -&gt; +CREG: 2<br/><br/>serin -&gt; +CREG: 5<br/><br/>serin -&gt; +CREG: 5,&quot;11BA&quot;,&quot;2F00&quot;<br/><br/>Above were relevant AT commands to register the modem to the GSM network. Below are 2 types of sending an alarm phone call:<br/><br/>1. with number:<br/><br/>serout -&gt; ATD 0592170185<br/>serin -&gt; NO CARRIER<br/><br/>2. with number from first postion of SIM's phonebook:<br/><br/>serout -&gt; ATD&gt;1<br/>serin -&gt; NO CARRIER<br/><br/>The 'NO CARRIER' is good here, because it shows that the person who was called did not pick up the phone.<br/>
Well, for serout you need either True or Inverted polarity. If you are driving a max232 for proper RS232 output (ie idle is minus 12V and active is +12V) then use T polarity. Then choose a picaxe pin. Let's say pin 1. And a baud rate, say 1200.<br/><br/>serout 1,T1200,(&quot;AT+CREG=2&quot;)<br/>serin 1, T1200,(&quot;OK&quot;)<br/>serout 1,T1200,(&quot;AT+CREG?&quot;)<br/>etc<br/><br/>Only catch is that the exact data has to be received by serin. If it isn't the expected bytes, then it just hangs till the right bytes come through. Unless you use one of the newer picaxes (20x2) that have a timeout on serin.<br/><br/>and to read in, <br/>
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. :)
You can choose any pins for serin or serout. The only exception is some pins on the smaller picaxes, like the 08M, where ones like pin 3 are input only. Yes, send me any eagle files moxhamj at internode.on.net
Thanks! That is very helpful :)
does anyone know how to interface this thing with matlab?
You can send the pot status to Twitter by adding this vb.net function(see below). Just call this function and key in your username, password and your wanted message. (Message = Pot Status) <br/><br/>I have no idea how to use Twitter to send output to PICAXE yet...<br/><br/>Public Sub PostonTwitter(ByVal userName As String, ByVal password As String, ByVal updateMessage As String)<br/> Dim wc As Net.WebClient = New Net.WebClient()<br/> wc.Credentials = New Net.NetworkCredential(userName, password)<br/> Net.ServicePointManager.Expect100Continue = False<br/> Dim updateMessageBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(&quot;status=&quot; + updateMessage)<br/> 'Use UTF8 to get it properly encoded if you use characters like &ccedil; &atilde; etc...<br/> wc.UploadData(&quot;http://twitter.com/statuses/update.xml&quot;, updateMessageBytes)<br/> End Sub<br/>
Hi every1 and Dr Aucla i am going to write up a way to this this but insteed of using windows it will be for linux.
hi everyone i recently posted a instructable on how to program a picaxe automaticly from a bas file on an ftp server heres a link if your interested<br/><a rel="nofollow" href="http://www.instructables.com/id/Setting-up-to-program-a-picaxe-via-shell-scriptli/">http://www.instructables.com/id/Setting-up-to-program-a-picaxe-via-shell-scriptli/</a><br/>
ok im having problems i have the chip its all on but it just keeps timing out. i stright copy and pasted both codes i don't have anything to give the pixaxe a reading like a pot but im sure that shouldnt matter. how i have it set up is that i've put leads into the proto broad pin soctets to bring it all onto my bread board. please help me
If it doesn't work, break it down into component parts and test each part. First little test, can you program a picaxe to flash a led?
Ohh i should of included this in the first post yea i got it to blink i auctlly made it blink 3 legs in a squence.
Ok, the tricky bit is programming the picaxe then changing the circuit as per step 6. Essentially, the wire that went to physical leg 2 now goes to physical leg 4. But first, a very simple program main:serin 3,N2400,("Data"),b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 high 1 pause 100 low 1 serout 0,N2400,("Data", b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13) goto main Try downloading this. You will need the circuit as per step 3. Put a led on physical pin 6 (pin1 in code). Now reconfigure as per step 6, ie you are now talking to the chip. Send it a packet and see if the led flashes.
ok i will try this later but i think this is the smoking gun p.s have to go down and get some resistors then.
hey thanks it worked. This is how i have it setup just for anyone who wants to know i have a devlopment/proto board i don't wanna solder on it so i put breadboard jumper leads into the slots of the proto board were the pic pins would normally go then i trafer them onto the breadboard. so i can save the proto broad for a more periment thing
Great! I see on this reply panel there is a "add images" option. If you could take a photo of your setup that would be fantastic.
Hahah sorry for taking so long to respond the curcuit stoped working reread the instructable. I noticed that when the cucuit is used as a serial interface make sure that physical leg 2 is grounded or else it won't work as wanted here is the pics of my setup. I took away the unneeded wires just to show how the serial connects and its its not the best quatly but just a proof of concecpt you dont need to add any resisitors to the serial line as their imbedded in the photo board. If anyone has questions to this i will be glad to answer i got the stuff from surpluseletronics in new zealand i got the photoboard(with microcontroller) but without the software) , another micro a big jumper lead package 10x led all for $35. A word of advise if you are buying a phroto board ask if you can get a discount if they don't include the software cd. i got $13.30 off the price and funny thing is the software is a free download off the internet. (yea my spelling sucks)
Hey every1 notice the above post. The pic that is communicating to the micro should have physical pin 2 grounded like this picture shows. If you don't do that it won't commuicate to the micro. The wires in the pic is a load of mess sorry.
Hi This Instructable and your other one using the internet are alsome im gonna try both i've put in the order(Well not realy im gonna go to a store) then im gna build it. But can some one point me in the direction of software for linux that would convert the vb.net to a program runnable on linux. I dual boot on my normal computer but on my 24/7 server comp its linux cheers
I don't know much about linux. But some of this software is a rewrite of some software written in vb 6, and that is a rewrite of something from quick basic. At the simplest level, you need to be able to send a byte out of the serial port and read a byte in. I'm sure linux can do that (indeed, probably it can do it more easily than windows). As an aside, I'm playing with some Lantronix MSS100 units I got off ebay for a good price. These go directly from an ethernet cable to a serial port and only use 4 watts, so you don't need to leave your PC on all the time.
After hours of painfull downloading in the last minute the installer gives me an error! And undoes EVERYTHING! I tried 5 times allready and it just keeps telling me""Installer name" Has encountered a problem and needs to close" You don't understand how mad i am about this thing
You mean vb.net installer? If so, yes, well, that is a Microsoft problem. I've got three machines that it runs fine on and one (a 700Mhz machine running XP) that gives the same error you have just got. This might be a question for .net forums. I'd be really annoyed if I'd paid for software and it did this. But if it is free, I guess they don't have an incentive to fix things, or at least give meaningful error messages.
Thank you very much for answering... I continue to try and understand what is going on... As I might have mentioned, I am comparing the results with 2 other processes - hyperterminal and another vb program. Both of those give me consistent data - no garbling or missing information. For thing about this vb program is that i have had to adjust the sleep parameter to (700)... Now when I get back data, the results to the screen are very inconsistent: 49 52 52 0 ... 59 50 0 ... 49 52 52 0 ... 49 52 52 0 ... 0 0 0 0 0 248 ... 50 0 ...... 49 52 52 0 50 0 .... I am concerned about all of the various timeouts / pauses that are being initiated on multiple sides, the picaxe side, the timer, the sleep parameter, the timer interval... Is there perhaps a more scaled down version on the vb side that uses less timers? I'm just throwing this up in the air - not knowing what else I can do...
If you get out the ascii table it is possible to translate that eg 49 52 52 is "144" The reason it displays the actual binary number is because most ascii characters will not display eg anything under 32 and anything over 128. But you can translate them to text if you like with the strings.chr instruction. I must confess I don't understand the question. First, have you copied the code and the instructable as it is and got that working? If so, then you can build on that. Next, do you want picaxe to vb or vb to picaxe? Then, do you want to send your data in binary or ascii, ie if you have a number 223 in b0 on a picaxe - are you going to send 223 as a single byte or as 3 ascii bytes ie 50 50 51? Next, do you know exactly when data is going to be coming in? If yes that makes code easy. If no, you are going to have to do some string manipulation on the input stream.
I believe the whole problem lies in the streaming / packet construct... The program is arbitrarily grabbing whatever is in the steam at a particular instant, but that doesn't necessarily mean it has maintained the total integrity of the stream sent by the microcontroller. In other words, there is gaps in the data. I think data should be picked off the stream as it comes in, make a large buffer, and have it appended to the text box holding the previous extract. Does that make sense? Of course, I don't yet know how to read the stream and write from it...

About This Instructable


333 favorites


More by Dr_Acula: Wireless Mesh with Graphics LCD Simple Arduino Wireless Mesh Worldwide microcontroller link for under $20
Add instructable to: