120 likes | 267 Views
BalloonSat Mini Flight Computer. Programming. label :. An address, or location for the program to jump to Must end in a colon Can be any name, but not a command No spaces allowed, use an underline in place of a space Can’t begin with a number. PAUSE time.
E N D
BalloonSat Mini Flight Computer Programming
label: • An address, or location for the program to jump to • Must end in a colon • Can be any name, but not a command • No spaces allowed, use an underline in place of a space • Can’t begin with a number
PAUSE time • Halts program execution for a number of milliseconds (1/1,000 of a second) • Used to prevent the program from finishing in a fraction of a second
HIGH C.2 and LOW C.2 • Used to trigger the camera • HIGH activates the relay which is the camera’s new shutter switch • Keep HIGH for about 1 second (PAUSE 1000) • LOW turns off the relay (camera needs you to release the shutter)
IF PINC.3 = nlabel • Monitors the Commit Pin • Conditional jump, only occurs if condition is true • Prevents flight computer from recording data until ready for launch • n can be either a 0 or a 1 • IF PINC.3 = 0 then Commit Pin is in place • IF PINC.3 = 1 then Commit Pin is removed
READADC i/o,Bx • Converts analog sensor voltage to a digital value • Linear conversion: 0V = 0 and 5V = 255 • Specifies the I/O pin (either C.1 or C.4) to digitize • Specifies the RAM memory to store the result (B0 to B27)
Write Bn, x • Writes a variable from temporary RAM into permanent Data Memory • RAM variable can be B0 to B27 • Data Memory address runs from 0 to 255
READ x,Bn • Reads data from permanent Data Memory into temporary RAM • Required to send the data via SERTXD • Data Memory address runs from 0 to 255 • RAM variable can be B0 to B27
SERTXD “text”, Bn • Writes variable from RAM to the PC • Writes text (must enclose text in quotes) • Use the PICAXE Terminal program (F8) • Set Terminal for 4800 baud
GOTO label • Jumps program execution to the label • Unconditional jump, happens as soon as command is executed
FOR Bn = x TO y • Loop control, makes program repeat itself • Saves program memory, a short program can be repeated many times without writing the program many times (maximum of 255 times) • Bn is the RAM variable that monitors how many times the loop of code has been repeated • x is the starting number • y is the finishing number
NEXT • Placed at the end of the lines of code repeated by the FOR command • Indicates the end of the repeated code • Easier to read program if the lines of code between the FOR and NEXT are indented