newbie: quick question (I think!)

julybride

New Member
Hi all,

I am starting out in electronics and i have written a programme for the school axe092 experimenter board picaxe-08m. The programme runs fine on a simulation but i haven't ordered the board yet. is the following programme too long? am i going to need a larger memory chip? is there anyway i can find out?

Your help is much appreciated.



main: let b1 = 0

start:

if pin3 = 1 then goto steph
goto start

steph:
high 2
pause 5000
low 2
high 1
pause 5000
low 1
inc b1

if pin3 = 0 and b1 >600 then goto contraction_break_morethan10
if pin3 = 0 and b1 >36 then goto contraction_break_lessthan10
if pin3 = 0 and b1 <36 then goto contraction_break_lessthan6
goto start

contraction_break_morethan10:
do
high 2 ‘ green LED on
pause 5000
low 2 ‘ green LED off
loop until pin3 =1
goto main

contraction_break_lessthan10:
do
high 1 ‘yellow LED on
pause 5000
low 1 'yellow LED off

loop until pin3 =1
goto main

contraction_break_lessthan6:
do
high 0 'red LED on
pause 5000
low 0 'red LED off


loop until pin3 =1
goto main
 

Technical

Technical Support
Staff member
If you can simulate it, it will also work on the real chip! You will get a 'program too long' error message when it gets too long!
 

eclectic

Moderator
Tip 1. At the top of your program, type
#Picaxe 08M

Tip 2. Use the syntax check.

Tip 3. Use the simulator. (Which you've done)
No worries, your program only takes 92 bytes :)
 
Last edited:

lbenson

Senior Member
Note that b1 can never be greater than 255 because it (and the other "b" registers) are 8-bit "byte" registers and can hold only values of 0-255 (in binary %00000000 to %11111111). "Word" registers like w0 have 16 bits and can hold values up to 65535. Each "word" register is made up of two "byte" registers. For w0, the two "byte" registers are b0 and b1.
 

julybride

New Member
Thank you everyone,

lbenson thank you I was concerned there maybe something like that. But now i am a bit lost. Does this mean I can change the programme to w0 instead of B1 to correct this problem? or is that to simple?:confused:
 

BeanieBots

Moderator
In your particular program, you can just swap "b1" for "w0".
The trap many fall into is that "w0" is made up from two bytes which are "b0" and "b1". So, if for example you had also used "b0", then it would not have been so simple.
 
Top