C Control The I Unit-M Advanced 5 Vdc Inputs / outputs 16 x digital I/Os / 8 x analogue or digital I/Os Program memory 2 198805 Fiche De Données
Codes de produits
198805
To avoid annoing wrong results or even crashes split your computation into small termes, what makes the
code better readable too.
Stack overflow will cause wrong results and even a crash or other unpredictable behaviour of the C-
Control
FLOATING POINT INPUT/OUTPUT
It is important to instruct the compiler that float values will have to be compiled. This is done with the
compiler instruction "OPTION FLOAT" , located the beginning of your program file. Remember that a float
takes 4 bytes, and be carefull on use of too much variables of this type. The internal assigning of variables to
the memory is done by the compiler automatically. The compiler also reserves further 16 bytes for internal
use for the FP System.
compiler instruction "OPTION FLOAT" , located the beginning of your program file. Remember that a float
takes 4 bytes, and be carefull on use of too much variables of this type. The internal assigning of variables to
the memory is done by the compiler automatically. The compiler also reserves further 16 bytes for internal
use for the FP System.
option float
define FV1 as float
define FV2 as float
define FV1 as float
define FV2 as float
ASSIGNMENTS
Now u can start to write a small program. This usually is done with assignment of variables used in the
program. The example shows the the different ways to do this.
The FPM is capable to handle 7 digits, more digits are ignored. The exponent can range +-38
program. The example shows the the different ways to do this.
The FPM is capable to handle 7 digits, more digits are ignored. The exponent can range +-38
FV1=3
FV1=2.3
FV1=0.023
FV1=2.12345678
FV1=exp(1.602,-19) corresponds to 1.602E-19
FV1=2.3
FV1=0.023
FV1=2.12345678
FV1=exp(1.602,-19) corresponds to 1.602E-19
INPUT
The FPM has an INPUT function as it is usual for WORDs and BYTEs
INPUT MyFloat ;
Terminal input of a FP Value and move to MyFloat
Because a FP value can be expressed in many different ways there are some regulations to consider:
1) The leading ZERO in front of the decimal point must be written 0.001 (not: .001)
2) The exponent must have two digits: 0.234E03 (not: E3)
3) After the decimal point one digit has to follow as a minimum 1234.0 (not:1234.)
Beside this the input format is widely flexible as the examples show:
INPUT MyFloat ;
Terminal input of a FP Value and move to MyFloat
Because a FP value can be expressed in many different ways there are some regulations to consider:
1) The leading ZERO in front of the decimal point must be written 0.001 (not: .001)
2) The exponent must have two digits: 0.234E03 (not: E3)
3) After the decimal point one digit has to follow as a minimum 1234.0 (not:1234.)
Beside this the input format is widely flexible as the examples show:
An Input is terminated if the terminal sends
CR or any other non numeric character. If your input device sends CR LF on termination u have to remove
the LF (use getMyByte). Beside this all other considerations concerning the use of the serial interface are
the LF (use getMyByte). Beside this all other considerations concerning the use of the serial interface are
0.000000000000000000000000001
1.123456789123456789
123456789123456789123456789
123456789123456789.123456789123456789
123456789123456.7891234E09
-12345678912345.123456789123456789E-12
12.3E12
0.0000000012345E13
1.123456789123456789
123456789123456789123456789
123456789123456789.123456789123456789
123456789123456.7891234E09
-12345678912345.123456789123456789E-12
12.3E12
0.0000000012345E13
30