Logicator for PIC Micros Help             Click a link below: 

Logicator Commands

Logicator Toolbar and Menus

Building and Editing Flowsheets


Logicator Commands  
    Click on a command below to see more information about the command:
Common Start StopOutputsHighLowMotorWaitAnalogue Variables Procedures Sound Output Serial In/Out Other In/Out Advanced

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.

Return to Top

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.

Return to Top

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.

Return to Top

High

The High command will switch the selected pin high.
                      High

Return to Top

Low

The Low command will switch the selected pin low.
                      Low

Return to Top

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".

Return to Top

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

Return to Top

Decision

Decisions form branches in the flowsheet.  When flow reaches a Decision cell, it continues in either the "Yes" or "No" direction, depending on the result of the decision test.
                   
An input bit pattern is set in the cell, and flow will continue in the 'Yes' direction if the input bit pattern on the interface matches the value that has been set, otherwise, the 'No' route will be followed.
Enter a label or decision text - Type a label in this text box.  If you do not type in a label of your own, the cell will be labelled 'Decision'.  Set the input port:
Each bit in the input port represents one of the Digital inputs on your interface.
Each bit can be clicked to set it to one of three different states:
               means "Is this sensor off"?.
               means "Is this sensor on"?.
               means "Ignore this sensor"

In the example above the test will be whether input bit 3 is on. The value of input bit 4 is iignored.
Note that there are only the two inputs 3 and 4 on the chip being used here.
Test Button - Click the Test button and a dialog will appear showing whether the input pattern that you have set is true or false.

Return to Top

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.
                   Analogue

Return to Top

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.

Return to Top

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.

Return to Top

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.

Return to Top

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.

                      

Return to Top

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
                    Inc

Return to Top

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
                    Dec

Return to Top

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
                   Random

Return to Top

Out

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

Return to Top

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
                    In

Return to Top

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.

Return to Top

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.

Return to Top

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.
                      

Return to Top

Write

When a flowsheet run is started, all variable values are automatically reset to zero.
So, when the PIC microcontroller is reset or powered up, all variable values are reset to zero.
If you want to retain variable values when the PIC microcontroller is powered up or reset,
you can use the WRITE command to store values in the chip’s EEPROM memory.
The PIC microcontroller’s EEPROM memory has 16 separate addresses. Each one can store a number between 0 and 255.
The EEPROM window displays the contents of the memory when you test run a flowsheet.
               Write      

Return to Top

Procedure

The Procedure command defines the start of a procedure or subroutine.
The dotted line shows that this command starts a subroutine, ended by a Return command which also has a dotted line. See the example of the procedure command 'Flash' in the next example.
     flash    Procedure

Return to Top

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 to Top

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.

Return to Top

Interrupt

An Interrupt is like a procedure or subroutine, but it can be triggered instantly, and not just when program flow meets a Decision command.
An interrupt instantly captures the flow of control whenever a preset digital input condition occurs to trigger it
e.g. when a switch is pressed. When the interrupt is triggered flow jumps immediately to the Interrupt command  and then carries out any commands which follow until it reaches a Return command. It then returns to the point which it was at when the Interrupt occurred.
In order to use an Interrupt, the PIC must be told to look for the input condition. This is done through the Interrupt Setup command.
There are two options in the command – Enable or Disable.
To prevent the Interrupt retriggering itself, the Interrupt is automatically disabled once it is triggered.
To re-enable it, another Interrupt Setup command is required.
                    
In the example above the program will enable the interrupt before looping endlessly.
During the lopping, if the input condition defined by the Interrupt command arises (e.g. a switch is pressed),
program flow will jump to the Interrupt command and in this case create a sound.
Note that the Interupt is re-enabled before the subroutine returns to looping. Now, every time the switch is pressed, a sound will be made.

Return to Top

InterruptSetup

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

Return to Top

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.
            Repeat

Return to Top

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.

Return to Top

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.

Return to Top

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.

Return to Top

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.

Return to Top

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.
                       PlayMP3

Return to Top

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.
                      Play iPod

Return to Top

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.
                           SerIn
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.

Return to Top

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'.
                     SerRxd

Return to Top

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.
                              SerOut

Return to Top

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
                       Sertxd

Return to Top

Debug

To read analogue values ‘live’ from a PICAXE chip we can use the Debug command in a loop like in the flowchart below. The debug command is enabled by default but we can set it to be disabled onced we have tested the program. We then open the Debug window from the Menu PIC > Debug.
When we download the above flowsheet into the PIC chip we need to keep the lead connected to the PIC chip in order for the analogue values to be read and displayed in the Debug window.
    Debug  

Return to Top

LCD

This command can be used to display a message on an LCD screen attached to a PICAXE-driven circuit board.
In the cell details window a message can be written over two lines if required and an output pin is assigned.
                          
This command will be simulated if the flowsheet is run from Simulate > Run.
A small window will pop up during the run to display the LCD message.
The window can be enabled by choosing View > LCD panel

Return to Top

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.

                 Touch

Return to Top

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.
                            

Return to Top

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.
                            

Return to Top

Toggle

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

Return to Top

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.
                            

Return to Top

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.
                     

Return to Top

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.
                            

Return to Top

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.
                            

Return to Top

ReadTemp

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

Return to Top

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
                            

Return to Top

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.
                            

Return to Top

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.
                            

Return to Top

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.
                            

Return to Top

Reset

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

Return to Top

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.
                            

Return to Top

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.
                       Suspend

Return to Top

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.
                       Resume

Return to Top

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.
                       Peek

Return to Top

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.
                      Poke

Return to Top

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.
 

Return to Top

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.
 

Return to Top

 

 

Compare Expression Inc Dec Random In Out Time on Write Interrupt ProcedureGosubReturn Interrupt Setup Repeat Loop

 

 

 

 

 

 

 

 

 

 


Sound PlayTune PlayUserTune Play MP3Play Ipod SerIn SerRxd SerOut Sertxd Debug LCD Touch PulseIn PulseOut Toggle Servo Count InfraIn InfraOut ReadTemp ReadADC Ultra PWM PWMout Reset Sleep Suspend Resume Peek Poke Disconnect reconnect