some of my PICAXE 08M projects

william47316

New Member
hey there i am william and i have made some quite interesting projects using the PICAXE 08M
some of them have videos on my youtube channel
http://www.youtube.com/user/williefleete
and now for a run down of one of my projects

the main project is an 8 digit LED display which controls 64 LED display segments using shift registers, 4 outputs, almost the whole code space of the PICAXE 08M, 8 bytes of 4800 baud serial input and can process 32 ASCII characters; the 10 numbers, colons, ~20 letters of the alphabet and the "bell" character, so you can just send it standard numbers and capital letters (and the bell character) to the display to control it. if you want to select a decimal point the first display can be used to select one of the other 7 displays decimal point, each digit is assigned a ram location, setting the first digit to that ram location (ASCII 81 thru 87, 80 is the first digit on the display) will turn on that digit's decimal point (coincidently Q,R,S,T,U are characters in my "ROM")

there is a video on my channel which shows this character set
plus there's a debug mode which will bypass the "character ROM" and display everything in binary.

of this i have made 3 versions, a red mini version using standard red LED displays a large green version using full size LEDs and "kiwipatch" boards IE making my own LED displays, and another using blue dot LEDs (which is quite bright) the large displays are at the moment slave units for my PICAXE clock receiving 4800 baud serial from the mini display which has the master unit in it

below is the running code for the display 08M with comments
the picaxe receives 8 bytes of serial, buffers them and figures out what to do with them and updates the shift registers, the shift registers for driving the LED displays are UCN5841's which are basically 595's with internal Darlington drivers and back emf diodes and will drive common anode LED displays, relays or anything under 500mA per line. all the shift register clock and data lines are connected common and the UCN5841's strobe lines are connected to an output of a 74hc595 used for addressing so they are essentially multiplexed but because the 5841's hold their data the display doesnt flicker and sometimes if powered down and re-powered may still hold their contents

this method does take a little bit of time to update the digits so you do need a small delay between 8 byte serial input bursts of at least 315mS which means the display can handle at least three "frames (8 bytes)" per second, if the bell character is used it does take it longer (because of the beep)
Code:
setfreq m8 'clock speed 8Mhz
'pin assignments on the 08M
'out 0 clock
'out 1 data
'out 2 strobe
'input 3 serial and debug button
'out 4 output enable

high 4 'set output enable high (outputs disabled)
symbol sclk = 0 ' clock (output pin)
symbol sdata = 1 ' data (output pin for shiftout)
symbol counter = b3 ' variable used during loop
symbol mask = b2 ' bit masking variable
symbol var_out = b1 ' data variable used during shiftout
symbol bits = 8 ' number of bits

if input3 = 1 then 'if the serial line is high on reboot
b0 = 1 'enter the debug mode
end if
'in debug mode the digit masks will not be in effect and hence display as binary, useful for debugging 


'addressing register codes
'code for use with the new display units with 74HC595 registers for addressing
reverse with (now obsolete by my standards) ucn5841 addressing register
poke 90, 128
poke 91, 64
poke 92, 32
poke 93, 16
poke 94, 8
poke 95, 4
poke 96, 2
poke 97, 1
'display data
eeprom 0,(231,132,211,214,180,118,119,196,247,244,16)'numbers 0 thru 9 and colon
eeprom 15,(245,55,99,151,115,113,103,181,132,135,240,35,18,229,23,241,182,225,118,51,167)
'^letters A through U

'6 use 119 for "fancy" 6 or 55 for plain
'7 use 228 for "fancy" 7 or 196 for plain
'9 use 246 for "fancy" 9 or 244 for plain 9
'colon (:) displays as "-" on display

mainloop: 

 serin 3, n2400, b4,b5,b6,b7,b8,b9,b12,b13 'receive 8 characters
'buffer them
poke 80,b4
poke 81,b5
poke 82,b6
poke 83,b7
poke 84,b8
poke 85,b9
poke 86,b12
poke 87,b13

'process them
for b10 = 80 to 87
peek b10 ,b11



if b0 = 0 then 'if its not in debug mode continue otherwise skip the rest of this

            if b11 = 7 then 'if b11 is 7 (bel) character
            sound 2,(75,50) 'beep
            b11 = 0 'show a blank display when updated
            end if

     if b11 >= 48 and b11 <= 58 then 'if the current variable is between
                      ' 48 and 58
     b13 = b11 - 48 'take off 48
     read b13, b11 'read from eeprom
     end if


         if b11 >= 65 and b11 <= 85 then 'if the current variable is between
                      ' 65 and 85
         b13 = b11 - 50 'take off 50
         read b13, b11' read from eeprom
         end if
        'if none of them are recognised it defaults to raw binary
 
'decimal point selection code
             if b4 > 80 then         'if the first digit more than 80 (ASCII QRSTUV or W)
               if b10 = b4 then        'if the current loop is equal to above

               b11 = b11 + 8 ;turn on the decimal point on the first digit ASCII value above 80
'eg 81 turns on second 82 third etc up to 87 for the end display decimal point ON

                end if
end if
end if
           poke b10, b11 'poke the ram with updated (if any) changes
next

gosub shiftout_lsbfirst 'update the displays
goto randomloop


shiftout_LSBFirst:
for b11 = 90 to 97

peek b11, var_out
'update the address register first
for counter = 1 to bits
mask = var_out & 1
low sdata &#8216; 'data low
if mask = 0 then skipLSB2
high sdata' , 10 &#8216;; data high
skipLSB2: pulsout sclk,1 
var_out = var_out / 2
next counter
pulsout 2 , 1 'update
'pause 10
b10 = b11 - 10
peek b10, var_out
'broadcast the data to the display registers 
for counter = 1 to bits
mask = var_out & 1
low sdata &#8216; 'data low
if mask = 0 then skipLSB
high sdata' , 10 &#8216;; data high
skipLSB: pulsout sclk,1 
var_out = var_out / 2
next counter
'pause 10
pulsout 4 , 1 'update the addressed register 
'by pulsing output enable on the address register low 
next
return

heres some various pictures of each of the units in some form of displaying mode

http://img832.imageshack.us/img832/6043/aut4779.jpg
http://img831.imageshack.us/img831/6327/aut4905.jpg
http://img80.imageshack.us/img80/6113/aut4904.jpg
http://img338.imageshack.us/img338/5922/aut4846.jpg
http://img715.imageshack.us/img715/7048/aut4828.jpg
http://img264.imageshack.us/img264/4071/aut4822.jpg
http://img152.imageshack.us/img152/7884/aut4810.jpg
 
Last edited:

william47316

New Member
after having a play with a hall effect sensor i have made myself a magnet meter and polarity tester using the 08M and 8 digit display

the sensor i have used operates with an output of 50% supply with no magnet and goes up or down 1.3 mV per gauss, as the 08M (and possibly others) have a resolution of 5mV (at 5 volts) i have calibrated it to go in 5 gauss steps
the voltage swings down if the magnet pole is north and up when its south so it makes an effective magnet polarity tester

video of the unit in operation
http://www.youtube.com/watch?v=YtKbkMz92Ek
pictures
http://img708.imageshack.us/img708/5484/aut4956.jpg
http://img804.imageshack.us/img804/494/aut4954.jpg




Code:
eeprom 0,("NON","NTH","STH") 'text for the magnet polarity
symbol magstate = b4 'variable for the 'rom reading routine
symbol maglevel = w3 'main variable for the magnet level
symbol nullval = w4 ' the value read when at 0 gauss is writen here

main:
readadc10 4, w1
 if w1 <= 521 and w1 >= 519 then '
 magstate = 0
 maglevel = 0
 nullval = w1
 end if
  if w1 <= 518 then
  magstate = 3
  maglevel = nullval - w1 * 4
  end if
    if w1 >= 522 then
    magstate = 6
    maglevel = w1 - nullval * 4
    end if

 
          if maglevel > 10 and maglevel <99 then
          sertxd (58)
          end if

             if maglevel >=0 and maglevel < 10 then
             sertxd (58,58)
             end if

sertxd (#maglevel, "G:")

for b7 = 0 to 2 'eeprom reading routine

    b11 = magstate + b7 'read the current magstate and add the loop no. to it
        read b11,b10 'read it
        sertxd (b10) 'serial out
    next


pause 315


goto main
 
Last edited:

marks

Senior Member
Your projects do look a lot of FUN and a lot of work has gone into them too!
The Big Blue Display is mostly IMPRESSIVE i'll buy that 1 lol!

Its good yourve posted some code. I know nothing about peeks & pokes & interupts yet,I still have lots to learn.Thats what i like most about the picaxe things can be done so many different ways.It would be really good if you could post some circuits.

AnyWay THANKS for sharing !
 

william47316

New Member
i have given my picaxe clock a bit of an update with the addition of a spinning widget which changes and indicates the tens of seconds and gets replaced with a bell character on the hour making the display (or a proper "dumb" terminal) beep

the picaxe clock is one of my more advanced projects involving (multiple) interrupts and one of my first timepieces using electronics. i have got some photos of the early beginnings of the picaxe clock i shall have to dig them out

at the moment the master unit clock is inside a smaller 8 digit display which is sent to the other displays via some recycled thinnet/10base 2 cable and T connecters one of my displays is out in the garage and the other in my bedroom with the master unit next to my bed
http://www.youtube.com/watch?v=JGrUN_AU8lM

Code:
EEPROM 0,(64,128,4,2,1,32) 'data for the spinning widget display
symbol seconds = b1
symbol tenssec = b2
symbol minutes = b3
symbol tensmin = b4
symbol hours10 = b10
symbol hoursu = b11
symbol hours = b5
symbol changeflag = bit0
symbol setflag = bit3
symbol timesetF = bit4

setint 1000,1000 'pin3 is set as an interrupt which has a clock ticker attached to it
mainloop:
if input2 = 1 then
gosub timeset
end if

serdata:
if changeflag = 1 then
hours10 = hours /10
hoursu = hours //10
sertxd (#hours10,#hoursu, b8,#tensmin,#minutes, 58,#tenssec,#seconds)
changeflag = 0
end if
if timesetF = 1 then
return
end if
goto mainloop

timeset:

setint 10000,10000 'set pin 4 an interrupt for the OK button, to confirm the time setting
seconds = 0 'reset seconds and tenssec to zero when setting the time
tenssec = 0
timesetf = 1 'timeset flag on

timeset2:

gosub serdata
if input2 = 1 then
pause 250
setflag = 1
gosub minset
changeflag = 1
end if
if input1 = 1 then
pause 250
setflag = 1
gosub hrset
changeflag = 1
end if
reinit:
if timesetf = 0 then

return
end if
goto timeset2


interrupt:
if timesetf = 1 then
setflag = 0
timesetf = 0
setint 1000,1000
goto reinit
end if

if input3 = 0 then
inc seconds 


if seconds = 10 then
seconds = 0
inc tenssec
  if tenssec = 6 then
   tenssec = 0
    minset:
    inc minutes
  end if
end if
read tenssec,b8 'read the variable tenssec and set b8 to the eeprom value it read
if minutes = 10 then
minutes = 0
inc tensmin
if tensmin = 6 then
tensmin = 0
if setflag = 1 then
return
end if
b8 = 7 'on the hour change variable b8 to send a bell character
hrset:
inc hours


end if
end if
if hours = 24 then
hours = 0
end if
if setflag = 1 then
return
end if

changeflag = 1
setint 1000,1000
return
end if
goto interrupt
 
Last edited:
Top