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 Datenbogen

Produktcode
198805
Seite von 42
 
 
 
 
ABS 
ABS calculates the absolute value of a  terms or a variable 
 
  
MyFloat=ABS(FLOAT(ADC8*MyByte)*0.0196+MyFloat*MyFloat)   
MyFloat= ABS(FLOAT(MyWord-MyByte*MyWord))/ABS(MyFloat+MyFloat/5) 
 
 
 
 
 
 
COMPARES 
A compare is always related to two variables. Compares of constants or terms are not allowed. 
Valid compare operators are: <, >, =, <=, >=  
 
IF MyFloat1>MyFloat2 THEN..... 
IF FLOAT(MyWord) > MyFloat1 THEN...... 
LOOP UNTIL  MyFloat1>MyFloat2 
LOOP UNTIL FLOAT(MyWord) > MyFloat1  
IF NOT(MyFloat1=MyFloat2) THEN..... 
 
 
 
 
 
 
 
The operator <> is missing. An equivalent compare is done with: 
IF NOT(MyFloat1=MyFloat2) THEN..... 
  
 
FLOATING POINT ERRORS 
 
Though calculations have to be done in a way that no illegal operations are processed (such as division by 
zero) it may nevertheless happen that e.g a sensor malfunction leads to that. Because this can lead to 
plausible rasults by all means, even the results are totally wrong, u can check your results for this cases of 
errors.  
 
 
ON ERROR GOTO MyErrorHandler 
 
Adds an error request to the compiled program code and jumps to the error handler.  The variable 
ERR.NUMBER contains the error code. ERR.NUMBER is cleared before any floating point operation. 
 
 
 
 
 
 
 
 
 
 
 
 
 
This example at the rightdemonstrates the usage. Continued 
multiplication leads to an overflow, the errorhandler is called 
and the error code is shown. 
0  No error  
1  Overflow error  
2  Underflow error  
3  Division by Zero error  
4  Square root of negative 
number  
5  Number too large/small to 
convert to integer 
 
38
FUNCTION FPE() 
ON ERROR GOTO ER 
#x 
RESULT=1 
DO 
RESULT=RESULT*100 
LCD.POS 1,1 
LCD.PRINT RESULT & "              " 
pause 20 
LOOP 
'-------- DISPLAY AN ERROR --------------- 
#ER 
LCD.POS 2,1 
LCD.PRINT "ERROR:" & ERR.NUMBER 
BEEP 5,5,50 
LCD.POS 2,1  
LCD.PRINT "                    " 
goto x 
END FUNCTION