Introduction: Setting Up to Program a Picaxe Via Shell Script(linux)

Simple walk through that shows how to make a shell script that will down load a program from a ftp site then compile it then download it to the picaxe.

(This is also my first instructable)

Step 1: What I Used

This is what i used

1x ubuntu
1x picaxe 08m
1x breadboard
2x led
jumper leads
some way to program the picaxe i use the PICAXE021 prototyping board with jumper leads to the breadboard

You can pretty much use any picaxe micro as long as you adjust and use the correct complier

Step 2: Setting Up

Now we need a place for the script to be ran from for this instructable I decided to place it in ~/picaxe-ftp (~ means your home folder by the way). Now we want to get the complier, http://www.rev-ed.co.uk/software/picaxe.tgz that their contains all the compliers for all the different versions of picaxe. Now I am using the 08m so i get complier 'picaxe08m' and place it in the directory but you could just as easily substitute that for your version. Ok so now you should have your directory with the complier in it thats all.

Step 3: Code

Now open your text editor or what ever you use and paste this code in.

#!/bin/sh
HOST='0catch.com'
USER='picaxeprogramer.0catch.com'
PASSWD='picaxetest'
FILE='test.bas' #Enter the name of the bas script here

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
get $FILE
quit
END_SCRIPT
# That was the ftp part that logs in gets the file and quits
./picaxe08m -c/dev/ttyS0 $FILE # that downloads the file to the picaxe change this to suit

Save this as picaxeprogramer.sh in the same folder you put the complier in. Now you can use the settings their the code is the simple flashing led you can check for yourself if you want. You can also use that ftp site if you want just be respectful and don't mess around with it.

Step 4: Running the Program

Now if you wanted to you could set this up to run every 1h, 2h 5h or what ever you want but for the sake of this instructable we will just run it.

OK connect your picaxe how you normally would(probly better if its not programed to blink on pin 1) and then add a led on pin 1 and turn it on. Now navigate to the folder where the script and complier is and run the program by typing 'sh picaxeprogramer.sh' . it should run and continue to program the picaxe.

Step 5: Last Step

Now i know this alone isn't very useful but if you expand on this you could be able to update robots controls or make sure all your robots are updated to a new commands and controls but anyway what you decide to do is completely up to you.

Here's a video of the shell running.(sorry for poor quality camera is more of a photo taking camera. Also the background noise)


If you want a script with a little added to it try this

#!/bin/sh
HOST='0catch.com'
USER='picaxeprogramer.0catch.com'
PASSWD='picaxetest'
FILE='test.bas' #Enter the name of the bas script here
NEWNAME=`date +%Y-%m-%d`'.bas'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
get $FILE $NEWNAME
quit
END_SCRIPT
# That was the ftp part basicly that logs in gets the file and quits
./picaxe08m -c/dev/ttyS0 $NEWNAME # that downloads the file to the picaxe
echo $NEWNAME

That one downloads it and changes the name to the date so you can see the previous codes.

Get the LED Out! Contest

Participated in the
Get the LED Out! Contest