About
Robotics
Old Projects
Photo Gallery
House
Motors
My other sites
Youtube
The PicAxe Microcontroller

The PicAxe is a programable PIC micro-controller made by Microchip. You can re-program it with a USB cable and a computer as many times as you want, changing it's function.

I have a PicAxe 022 development board for programming 28 or 40-pin chips. One nice thing about using the PicAxe mcu is that it comes in several varieties ranging from 8-pin to 40-pin chips. This means if you only need 4 input/outputs for a project you can choose a smaller (less expensive) chip - and if you decide to upgrade to a larger chip later (with more inputs/outputs), the original code should still work.

In addition to being versatile, the programming language (Basic) is very straightforward and easy to pick up. I am used to writing code in C to program my AVR microcontrollers and it only took about an hour to get similar code working on my PicAxe. Here is some sample code that will read 2 R/C servo signals and turn 2 LED's ON/OFF:


' Servo Decode
' PicAxe 40x
' JDW 2010

symbol T1 = w1  ' create symbols for variables
symbol T2 = w2

main:

pulsin 0,1,T1  ' pulseIn the 2 R/C channels and record values to T1 & T2
pulsin 1,1,T2  

if T1 > 155 then  ' check value 
high 4            ' if above 155, turn LED ON

else							
low 4             ' if not, turn LED OFF

endif

if T2 > 155 then  ' check value
high 5						' if above 155, turn LED ON

else
low 5							' if not, turn LED OFF

endif

SerTxD ("       ", #T1 , "        ", #T2)   ' write values to terminal for viewing on computer

goto main 


Here is a similar bit that will decode 2 R/C channels and output the corresponding PWM signals (80kHz) in either direction.

R/C signals go to input 0 and 1. PWM outputs to pwm1 and pwm2.


symbol PPM1 = w0
symbol PPM2 = w1

symbol PWM1 = w2
symbol PWM2 = w3

init:
pwmout 1, 11, 0
pwmout 2, 11, 0

main:

pulsin 0,1,PPM1  
pulsin 1,1,PPM2

if PPM1 > 155 then
        let PWM1 = PPM1 - 150	  
        low 3
        high 2
        pwmduty 1, PWM1
        low 4

elseif PPM1 < 145 then
	let PWM1 = 150 - PPM1
	low 2
	high 3
	pwmduty 1, PWM1
	low 4
	
else
	low 2
	low 3
        pwmduty 1, 0
        high 4

endif

if PPM2 > 155 then
        let PWM2 = PPM2 - 150
        low 7
        high 6	  
        pwmduty 2, PWM2
        low 5

elseif PPM2 < 145 then
	let PWM2 = 150 - PPM2
	low 6
        high 7
	pwmduty 2, PWM2
	low 5
	
else
	low 6
	low 7
        pwmduty 2, 0
        high 5

endif


'SerTxD ("       ", #PPM1 , "        ", #PPM2)

goto main