Logicator for PIC Micros Help Click a link below: |
Logicator Commands Click on a command below to see more information about the command:
Start |
A Start cell marks a point where a flowsheet will start
running.
When you select Run from the system menu, the flowsheet will
start running at the Start cell
If you have highlighted the start of a procedure, the flowsheet will run this procedure only and then stop.
You can usually only have one Start
command in a flowsheet.
However, the new PICAXE M2 chips support parallel multitasking. When these are used, up to 4 parallel flowcharts can be created which can be made to run in parallel. Each flowchart will start with a Start command. |

|
Stop |
A flowsheet will stop running when a Stop cell is
reached.
You can only have one Stop command in a flowsheet, except when a chip that supports parallel progranmming is used. All outputs are set
to off when a Stop command is processed. |

|
Outputs |
The Outputs command allows you to switch the output pins on
your chip on and off.
It requires an
output bit pattern to be set. Click on the output bits for the output you wish to set.
Type your own label in the text box
to remind you what the cell does.
If
you do not type in a label of your own, the cell will be labelled
"Outputs".
|
 |
Each one of the 8 bits in the output bit pattern represents
one of the output pins on your chip.
Each bit can be clicked to set it to one of three different
states:
means
"Switch this output off".
means
"Switch this output on".
means
"Ignore this output. Do not change
the output state of this pin".
Test Button - Click and hold down the Test button to check
that the output bit pattern you have set shows on the digital panel. Depending on the
chip type you have selected, some of the outputs may not be visible or you may
not be able to click on them. In the example above, only the first three bits 0,1 and 2 are selectable. |

|
High |
The High command will switch the selected pin high. |
|

|
Low |
The Low command will switch the selected pin low. |
 |

|
Motor |
Motor command allows the control of pairs of outputs, where
Motor A uses outputs 0 and 1, Motor B uses outputs 2 and 3, and so on. Motors can be switched to go forwards (>>) or backwards (<<).
For example; selecting Motor A forwards will switch ON
output 0 and switch OFF output 1.
Because the motor command works on the entire output port,
be careful not to accidentally switch off outputs that you are using.
Note:
Always un-check any motors that you are not using to save memory in the PICAXE chip.
Depending on your settings, the motor command can be heavy
on memory in the PICAXE chips.
The
Outputs command should be used for more efficient use of memory.
|
 |
If the select tick box is NOT ticked, then that Motor setting will
be ignored.
Optional cell label: Type a label in this text box to
remind you what the cell does.
If you
do not type in a label of your own, the cell will be labelled
"MOTOR". |

|
Wait |
A running flowsheet will pause
at a WAIT command for the number of seconds specified.
Choose the time you wish to Wait for from the drop down
box. |
 |
You can also enter one of the variables (A to H) in the box.
The shortest wait time possible is 0.001 seconds (1ms),
anything less than this will be rounded up to 1ms |

|
Analogue |
Analogue is a decision command that branches in the 'Yes' or 'No' directions depending on the value of the selected sensor reading. In the example below, the decision will be 'Yes' if the value of A1 is greater than 60 and less than the value of the variable A. Both numbers and variables can be used in this decision. |
 |

|
Comment |
Comment cells allows you to add short explanatory notes to a
flowsheet.
|
 |
Comments have no effect on the operation of a flowsheet and
are not downloaded to the PIC, neither are they converted into BASIC. |

|
BASIC |
This command is used as an extension to a flowchart. PICAXE BASIC code can be typed into the command cell window. When program flow arrives at this command the BASIC code within the command will be interpreted as if it were a procedure.
The code you add in the BASIC command will be downloaded to the PIC without error checking, simulation or memory
estimates. Be
careful to ensure that the code is checked before downloading. You can use the Programming
Editor software from www.picaxe.co.uk to check
the BASIC code.
From the PIC menu choose 'Convert flowsheet to BASIC' to see
the complete flowsheet code, including the code entered directly in this
command.
|
 |
If your BASIC code is already stored in a file, you can add
this directly to the command by clicking the ‘Add from file…’ button.
This
option will overwrite any existing code in the textbox. You can edit the code in the textbox using normal Windows
editing.
Right click on the text area to access the copy and paste menu.
Optionally, you can change the cell label to a name of your
choice. |

|
Compare |
Compare is another type of Decision command. Decisions form branches in the flowsheet.
When flow reaches a Decision cell, it
continues in either the "Y" or "N" direction depending on
the result of the decision test.
|
 |
Compare: Text is entered into the cell which requires
the decision to check whether the test of an expression is true or false.
The expression can use variables or the reading from an analogue
sensor.
Flow will continue in the "Yes"
direction if the current value matches the one that has been set. Otherwise flow will continue in the 'No' direction. |

|
Expression |
The Expression command is used to give a value to a variable as a flowsheet runs. The variable is given its value as flow passes through the command.
|
 |

|
Inc |
Each time flow passes through an INC cell, 1 is added to the
value of a specified variable.
The
variable is incremented by one. Set the variable that you want to increment by selecting it
from the drop down list box. Example Inc A |
 |

|
Dec |
Each time flow passes through a DEC cell, 1 is subtracted
from the value of a specified variable. The variable is decremented by one. Set the variable that you want to increment by selecting it
from the drop down list box. Example: Dec A |
 |

|
Random |
This command can be used to generate a pseudo random number in the range 1-255 and assign it to a variable. For greater randomness, use the command in a loop terminated by a switch press.
Example: Random A |
 |

|
Out |
The Out command sets the output port bit pattern to the value stored in the
variable.
Example: Out A. |
 |

|
In |
The In command converts the input port bit pattern to a binary number and
then stores this number in the variable chosen. Example: In A |
 |

|
TimeOn |
Some PICAXE chips have an internal clock module. The Time On command starts the clock cycle.
The elapsed time will be measured in seconds by the variable ‘Time’.
Elapsed Time can be viewed in the Time panel. |

|
TimeOff |
Some PICAXE chips have an internal clock module. The Time Off command will stop the clock.
The elapsed time will be measured in seconds by the variable ‘Time’.
Elapsed Time can be viewed in the Time panel. |

|
Read |
The READ command takes the value which is currently stored in a selected address (in this case address 0), and puts it into the selected variable (in this case variable A). Use the READ command Cell Details box (below) to enter the variable and the address from which the value is to be read. |
 |

|
Gosub |
The Gosub sends program flow to a subroutine or procedure where it carries out the commands in the subroutine. In this example the Gosub command is called 'Flash' and has a complete line on each side. |
 |
The Gosub command calls the subroutine called Flash and executes the commands that follow until the Return command is reached. On reaching Return program folw returns back to the command following the Gosub command. |

|
Return |
The Return command defines the end of a procedure or subroutine.
On meeting this command, program flow will return to the next command after the Gosub command. |

|
InterruptSetup |
The Interrupt Setup command is used to enable or disable the Interrupt. |
 |

|
Repeat |
Repeat is a flexible command that provides the ability to repeat a sequence until one of a number of defined conditions arises. In the example below the sequence will loop 10 times before continuing. Other conditions are to repeat the sequence until a defined Input pattern is read, until a defined Input pattern changes, until a defined expression becomes true, or while a defined expression is true.
The Repeat command is used with the Loop command. |
 |

|
Loop |
The Loop command is used together with the Repeat command to send program flow back to the Repeat command if the defined condition is not yet true. |

|
Sound |
A Sound command is used to send a pulsed signal to a piezo sounder connected to an output of a PIC microcontroller.
A sequence of sound commands can be used to play a simple tune.
The notes used in Logicator are true sampled wav files, but the notes played by the PIC may vary due to the limitations of the pulsing of the piezo sounder.
There are two ways to view the cell details for the Sound command.
‘Simple’ allows the setting of note, time and pin from drop down lists; whereas the ‘Advanced’ option allows the selection of note via a ‘keyboard’ style layout.
The white notes are naturals and the black notes are
sharps or flats.
|
 |
To set the note, choose a value from the drop down
list. The terminology used is the note
letter e.g. ‘C’; then the octave e.g. ‘3’, meaning third octave.
The default note is C3 which is middle C on a piano.
Click the note on the dialog that you want to play.
Set the time that you want the note to play for, in seconds.
Test Button – Click and hold test to play back the selected
sound.
Remember that, when testing this command, the sounds play through the sound device on your
computer.
You may need to turn up your speaker volume or plug in headphones to
hear the sound.
When the flowsheet is donwloaded to the PICAXE chip the sound will play through the sound device on the circuit board. |

|
Playtune |
The PlayTune command plays
an internal tune on an output pin.
The PICAXE chip is
supplied with up to 4 pre-programmed internal tunes, which can be output via the play
command.
As these tunes are included within the PICAXE bootstrap code, they
use very little program memory.
|
|
Select the Tune to play from the drop down list.
0 - Happy Birthday
1 - Jingle Bells
2 - Silent Night
3 - Rudolf the Red Nosed Reindeer
Some PICAXE chips can also be programmed to flash LEDs in time to the music. For 8 pin chips you can choose if an output light on the circuit board should flash while the
chip is playing the tune.
0 - No outputs
1 - Output 0 flashes on and off
2 - Output 4 flashes on and off
3 - Output 0 and 4 flash alternately
'Logicator for PIC micros' will simulate the playing of the tune through
the computer’s speakers, and show the outputs changing where appropriate.
When
used in a chip, the outputs flash in time to the music – changing after every note. |

|
PlayUserTune |
A RTTTL mobile phone ringtone
file can be downloaded into a PICAXE chip.
RTTTL
ringtone files are freely available on the internet and are usually downloaded
as small text files.
'Logicator for PIC micros' is
able to convert these files into the necessary code to play the ringtone tune in
the PICAXE chip.
|
 |
Click ‘Select Ringtone…’ to locate the ringtone file that
you want to play or type in the path and filename to your file. You can also specify an optional cell label for the command.
Note that the Play User Tune command downloads a large
amount of code into the PICAXE chip in order to play the tune.
If you want to play your tune more than once in a program, ensure
that the Play User Tune command is held in a Procedure to conserve memory use.
Some PICAXE chips can also be programmed to flash LEDs in time to the music.
|

|
PlayMP3 |
This command is used to play a defined MP3 file on a selected pin. There are a range of options for controlling the MP3 file, selectable from a drop-down menu.
Click the Help button for interfacing details.
|
 |

|
PlayiPod |
This command is used to play a tune on an iPod. There area range of options for controlling the iPod, selectable from a drop-down menu.
Click the Help button for interfacing details.
|
 |

|
SerIn |
The SerIn command is used to receive serial data into an input pin of the microcontroller.
The cell details box for the SerIn command has three boxes to set. |
 |
The input pin is the input on the PICAXE that the data is to be received through.
The Variable option is a variable location that the data is stored into once it is received.
The Mode option specifies the baud rate and polarity of the signal.
The Timeout box will indicate whether the selected chip supports a timeout.
When using simple resistor interface, use N (inverted) signals.
When using a MAX232 type interface use T (true) signals.
The protocol is fixed at N,8,1 (no parity, 8 data bits, 1 stop bit).
For best results do not use a baud rate higher that 2400 on 4Mhz chips.
The SerIn command forces the PICAXE chip to wait until serial data is received through the chosen input.
This data is stored in the chosen variable. |

|
SerRxd |
The SerRxd command is used to receive serial data via the download cable into a selected variable. Note that use of this command prevents new downloads until a reconnect command or 'power up hard reset'. |
 |

|
SerOut |
This command allows output information to be sent from the PIC microcontroller to a device such as a serial printer, a serial LCD screen or another PIC which is connected to an output of a PIC microcontroller.
The first box is used to select the output pin on the PIC microcontroller to send the data through.
In the Data box either type in the ASCII text you wish to send or raw data.
If sending raw data codes the ASCII box must be unchecked.
ASCII codes are useful for sending commands to LCD screens e.g. clearing the display.
Details of these control codes can normally be found with the instructions for the particular devices.
You can send a series of text characters e.g. “Hello” or a series of ASCII codes e.g. “254,1”.
In the latter case, ASCII codes must be separated by a comma.
If you wish to send the value held in a variable, type in the variable name in square brackets e.g. “[B]”. Note that you must use capital letters for the variable.
The last item to set is the serial mode. Set the mode to that specified by the device you are sending data to. |
 |

|
Sertxd |
The Sertxd command is similar to the serout command, but acts via the serial output pin rather than a general output pin. This allows data to be sent back to the computer via the programming cable.
This can be useful whilst debugging. See the PicAxe Manual for more information |
 |

|
Touch |
The Touch command sets the touch sensor range between a lower and upper limit on a range from 1-255.
The Touch sensor is assigned to one of the Analogue inputs and the limits are then selected from drop down menus.
|
 |

|
PulseIn |
The PulseIn command measures the length of a pulse through an input pin.
If no pulse occurs within the timeout period, the result will be 0. If State = 1 then a low to high transition starts the timing, if state = 0 a high to low transition starts the timing.
There are three items to set in the PulseIn command; the input pin, the State and the Variable to store the result in. The result is measured in multiples of 10ms and is in the range 1 – 255. |
 |

|
PulseOut |
The PulseOut command generates a pulse through the chosen output.
If the output is initially off, the pulse will be on, and vice versa.
There are two items to set in the cell details box for the PulseOut command below; the output pin to send the pulse through,
and the length of time that the pulse should operate for.
The time is in 10ms intervals, but for easier reading, the text area in the command converts this to milliseconds as the time is entered into the command.
PulseOut times must be in the range 1 – 65535.
Note that Logicator cannot simulate the action of the PulseOut command. |
 |

|
Toggle |
A toggle command inverts an output, switching it high if currently low or switching it low if currently high. |
 |

|
Servo |
Servos, as commonly found in radio control toys, are a very accurate motor/gearbox assembly that can be repeatedly moved to the same position due to their internal position sensor.
Generally servos require a pulse of 0.75 to 2.25ms every 20ms, and this pulse must be constantly repeated every 20ms.
Once the pulse is lost the servo will loose its position.
The Servo command starts a pin pulsing high for length of time pulse (x0.01 ms) every 20ms.
This command is different to all other commands in that the pulsing mode continues until another servo command or outputs command.
Outputs commands stop the pulsing immediately.
Servo commands adjust the pulse length to the new pulse value, hence moving the servo.
The cell details for the servo command have two settings; the output pin that the servo motor is connected to and the pulse time.
The pulse time can be a value held in a Variable.
Note that the value for the pulse time MUST be in the range 75 to 225.
The servo motor may malfunction if the pulse is outside of this range. |
 |

|
Count |
The Count command is available on certain PICAXE chips.
The Count command checks the state of the input pin and counts the number of low to high transitions within the time ‘period’.
Up to 255 transitions can be counted. |
 |

|
InfraIn |
To receive information from an Infrared source, the InfraIn command is used.
The command will wait for a new infrared signal from an infrared TV style transmitter.
It can also be used to receive an InfraOut signal from a separate PICAXE chip.
All processing stops until the new command is received.
The value of the command received is placed in the chosen Variable.
|
 |

|
InfraOut |
This command is used to transmit the infrared data to a Sony™ protocol device.
It can also be used to transmit data to another PICAXE circuit that is using the InfraIn command.
Data is transmitted via an infra-red LED (connected on output 0) using the SIRC (Sony Infra Red Control) protocol.
When using this command to transmit data to another PICAXE chip the Device ID used must be value 1 (TV).
The InfraOut command can be used to transmit any of the valid TV commands (0-127).
Note that the Sony protocol only uses 7 bits for data, and so data of value 128 to 255 is not valid.
|
 |

|
ReadTemp |
This command is used to read an analogue value from a DS18B20 temperature sensor.
|
 |

|
ReadADC |
This command is used to read an analogue value from an analogue channel and assign the value to a variable.
It is equivalent to using an Expression to set a variable equivalent to an analogue channel, as in the expression: A = A1
|
 |

|
Ultra |
The Ultra command is use to detect an object using the SRF005 ultrasonic sensor.
When the output and input pins area assigned to the sensor position the command returns the distance to an object (cm) and assigns this value to a variable. Some PICAXE chips require one input and one output, others just require one bidirectional pin. See the SRF005 datasheet for more details.
|
 |

|
PWM |
The PWM command is used to provide ‘bursts’ of PWM output to generate a pseudo analogue output on the PICAXE-08/08M (pins 1, 2, 4).
This is achieved with a resistor connected to a capacitor connected to ground; the resistor-capacitor junction being the analogue output.
PWM should be executed periodically to update/refresh the analogue voltage.
The parameters are: the Output pin used, the analogue level 0-255 (Duty) and the number of 5ms cycles that specifies the duration.
|
 |

|
PWMout |
The PWMout cmmand is used to generate a continuous pwm signal on certain PICAXE pins. Check the pinout diagram carefully for the PICAXE chip being used.
|
 |

|
Reset |
This command will cause a reset of the PICAXE chip to take place. It is equivalent to removing and reconnecting the power supply.
|

|
Sleep |
This command puts the PIC microcontroller into low power mode for a specified number of seconds.
This command can be used to save battery power in your project.
All output devices will be left in their current condition, but signals from input devices will not be responded to while the chip is in sleep mode.
The Cell Details box is used to set the number of seconds of sleep mode required (this is in the form of number of multiples of 2.3 seconds).
For example, a setting of 10 will sleep for 23 seconds.
Note that Sleep times are not as accurate as Wait times. |
 |

|
Suspend |
New PICAXE chips like the M2 series can multitask. Using this chip it is possible to define up to 4 parallel flowcharts on one flowsheet. The Suspend command controls the running of a selected flowchart by suspendng its operation. |
 |

|
Resume |
The Resume command will resume the operation of a selected flowchart. Using PICAXE chips that support multi-tasking, this command can be used with the Suspend command to control the flow of up to four flowcharts running in parallel. |
 |

|
Peek |
The Peek command reads the value from a selected memory address and stores it into a selected variable. Notice below how hovering over a choice box brings up a tool tip with further information.
|
 |

|
Poke |
The Poke command takes the value from a selected variable and stores it into a selected memory address. Notice below how hovering over a choice box brings up a tool tip with further information. |
 |

|
Disconnect |
This command will disconnect the PICAXE chip from the computer, for use with the SerRxd command.
For information about this command please see the PICAXE notes.
|
|

|
Reconnect |
This command will reconnect the PICAXE chip to the computer, for use with the SerRxd command.
For information about this command please see the PICAXE notes. |
|

|
|