Calculation Icon Properties

From Flowcode Help
Jump to navigationJump to search
Btn Calculation.gif Gen Calculation Flowchart Icon 01.png Gen Calculation Icon Properties 01.png

Calculation icons allow the modification of variables. They can be used to check inputs and to create outputs.


Display Name

The name of the icon that appears on the flowchart.


Calculations

One or more lines of calculations can be entered into this box.

All calculations must consist of the name of an existing variable, and equals sign and an expression made up from numbers, variables and the following operators:

Caption text
Operator Description
( ) Parentheses
= == Equal to
<> != Not equal to
+ - * / Addition, Subtraction, Multiplication, Division
MOD % Modulus
< <= Less than, Less than or equal to
> >= Greater than, Greater than or equal to
>> << Shift right, Shift left
NOT ~ Bitwise NOT
AND & Bitwise AND
OR | Bitwise OR
XOR ^ Bitwise Exclusive OR
&& Logical AND
|| Logical OR
! Logical NOT

Flowcode generally uses the same basic operators as C, but also has English equivalents such as NOT, OR and MOD as shown in the table above. The other difference is a single '=' or a double '==' can be used to compare two values, whereas C always uses double '=='.


Numeric values can be in decimal (unmarked) or in HEX format (preceded by 0x) or in Binary format (preceded by 0b) e.g. 85 or 0x55 or 0b01010101.


Examples

Assuming that the variables have been previously defined, all the following are valid calculation lines.


DELAY = DELAY + 1

DELAY = (MYVAR + 3) * 3

NEXTBIT = LASTBIT >> 2 & MASK

AANDB = PORT_A AND PORT_B

INVX = NOT X

$PORTA = $PORTA + 1

$pin39 = $A2

$pin2 = 1

The $ donates a pin or a port that can now be used within calculations.

If any of the variables don't exist, then Flowcode will ask if you would like to create the missing variable.

Gen Calculation Flowchart Icon 02.png

Variable and Function Box

This section is used to either select a variable or access a list of the available functions. You can reference ports directly or select from a list of available Global or Local variables. You can also view the list of available functions for mathematical and string functions.


IO Ports

Allows you to drirectly drag a poin or port for assigning a value or wihtin calulations. For example:

$PORTA = 10
$PORTC.2 = 1
$C1 = 1
$PORTA.3 = $PORTB.1

From Flowcode V10 With Arduino that uses different pin references the following can be used:

$pin3 = 1

Globals

Globals will allow you to create and drag global constants or variables into the calculation window.

As the variables are global, they can be seen within any user macro's

Locals

Locals will allow you to create and drag local constants or variables into the calculation window.

As the variables are local, they will only be seen within the user macro it was created in.

Outside the user macro, any local variables get destroyed.

Macros

Allows you to drag any user macro into the calculation icon so they can be accessed from within it.

Components

Allows you to drag a component function to control it within a calculation icon.

For example, if using the 2D potentiometer with a variable called ReadADC, the integer value is required, then with a calculation icon:

ReadADC = Potentiometer1 :: GetInt ()

There might be component functions that require an input parameter, then the parameter/s are entered within the brackets.

For example, required the average value after 100 samples and using a 20-microsecond delay:

ReadADC = Potentiometer1 :: GetAverageInt (100,20)

It is easier to read the potentiometer via Components of the Project Explorer rather than the Calculation icon

fx Built-in Functions

This is where all the Mathematical Functions can be found for dragging on the calculation icon.

f$ Built-in Functions

This is where all the string manipulation functions can be found for dragging on the calculation icon.

Video instructions

See the Calculation video to learn how to use Calculation icon correctly with valid syntax, variables and expressions.