Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

Using Variables

<^< Variables | Course Index | Set up the Outputs >^>

In a previous section you added a variable to your program using the variable dialogue box:

But what does this mean?

Computers work on the principles of digital logic: 0's and 1's on each wire, and groups of 8 wires, or 8 'bits', forming 'bytes' of data. This grouping of 8 bits is used for much of the internal wiring inside the PICmicro device, and for the registers that hold and process data. It is also used for memory. This means that a memory register has 8 bits and can vary from 0 to 255. A variable inside Flowcode can be allocated to use just one memory register or more than one. In Flowcode you have eight different types of variables you can use:

A 'bool' variable can either be a 1 or 0 (true or false).

A single register is know as a 'Byte' variable and can vary from 0 to 255.

A double register is known as an 'Int' variable and can vary from -32768 to +32767.

A double register can also be used unsigned this is known as a 'UInt' variable and can vary from 0 to 65535.

A quad register is known as a 'Long' variables and can vary from -2147483648 to 2147483647.

A quad register can also be used unsigned this is known as a 'ULong' variable and can vary from 0 to 4294967295.

You should use type Byte when you have simple counters and variables that will not go above the value 255. This is the most economical in terms of memory space and also the fastest: mathematical processes involving two bytes (often referred to as '16 bit arithmetic') will take longer for the PICmicro to execute.

A multiple register is known as a 'String' variable and can consist of a number of Byte variables - the default in Flowcode is 20.

Floating point numbers can also be used, although they represent a much wider range of values than an integer, it suffers a loss of accuracy over large ranges.

Finally an object handle is used to reference a more complicated piece of data (such as a file, component or block of text) whose internal format is not known.

So why is this important? The answer is that the number of registers inside the PICmicro device is limited, and in larger applications you will need to manage the variables in a program carefully to get them to fit inside the device.

On downloading the variables in Flowcode are implemented in the Random Access Memory (RAM) part of the PICmicro device. In the 16F1937 there are 512 Bytes of memory. This means you can have 512 Byte variables, 265 Int type variables or 25 Strings each consisting of 20 Bytes or characters.

<^< Variables | Course index | Set up the Outputs >^>

Print - Search - Login

Page last modified on July 05, 2013, at 02:40 PM