K-WANG



Reliance Electric DCS 5000 Enhanced BASIC is a programming language suitable for industrial real-time control scenarios. Based on standard BASIC extensions, it supports 5 types of variables (single precision integer/double precision integer/real/boolean/string), multitasking concurrent execution, hardware/software event synchronization, and multi protocol I/O communication (Modbus/Allen Bradley, etc.), providing 34 built-in functions such as arithmetic/string/bit operations. It requires defining global variables and I/O mapping through configuration tasks, implementing control logic through application tasks, and supporting complete error handling mechanisms and version compatibility explanations. Its core is used for industrial equipment control and data processing in DCS 5000 systems.
Basic language characteristics
Program Structure Specification
Line format: Must start with a unique line number from 1-32767, and end the statement with a carriage return ([CR])
Multilingual sentence line: Separate multiple statements with a back slash () or colon (:), with only one line number
Multi line statement: Wrap with&at the end, indent the following lines to improve readability
Annotation method: REM (compile time discard)! (Download with program, supports multiple lines)
Variable system | Variable type | Identification suffix | Value range | Core characteristics|
|Single precision integer |% | -32768~+32767 | 16 bit storage, automatic truncation of decimals|
|Double precision integer |! |-2147483648~+2147483647 | 32-bit storage, internal calculation default dual precision|
|Real number | None | ± 5.42 × 10 ⁻² ⁰~± 9.22 × 10 ¹⁸ | 8 significant digits, supports exponential representation (* *)|
|Boolean | @ | TRUE (1)/FALSE (0) | Variable name up to 7 characters (PC task limit)|
|String | $| Maximum length of 31 characters (variable)/132 characters (expression) | Supports concatenation (+), truncation, and other operations|
|Array | None | Up to 4 dimensions, subscripts 0~32767 | String array elements fixed at 32 bytes per element|
Task and Variable Definition
Task classification and responsibilities
Configuration task: Unique global configuration, defining I/O mappings such as TASK (task type/priority/slot), COMMON/NVEMDEF (global variables), IODEF, etc., requiring priority loading
Application task: Implement specific control logic, define local variables (including arrays and adjustable variables) through LOCAL, and COMMON references global variables
Adjustable variable configuration
Format: LOCAL variable name [CURRENT=initial value, HI=maximum value, LOW=minimum value, STEP=step size]
Restriction: Readable only, cannot be used as an lvalue assignment statement, for runtime adjustable parameters
I/O Definition Statement | Statement | Purpose | Key Parameters|
|IODEF | Local/Foreign I/O | Address=Hexadecimal Address, SLOT=Slot Number|
|NETDEF | Network chassis I/O | DROP=Slave number, REGIST=Register number|
|RIODEF | Remote I/O | MASTER_SLOT=Master Station Slot, DROP=Remote Chassis Number|
|MODDEF | Modbus I/O | Register=30001-31024 (integer), 1-4096 (boolean)|
|ABDEF | Allen Bradley I/O | FILE=B0/B1 (binary), N0/N1 (integer)|

Core statement function
Control flow statement
Jump statements: GOTO (direct jump), GOSUB/RETURN (subroutine call), ON GOTO/ON GOSUB (conditional jump)
Conditional statement: IF-THEN (supports Boolean/relational expressions, can jump or execute multiple statements)
Loop statement: FOR-NEXT (supports STEP step size, unlimited nesting layers, prohibits jumping into loops)
Multi tasking and real-time statements
Event synchronization: EVENT (defining hardware/software events), SET (triggering events), WAIT ON (waiting for events)
Task communication: OPEN CHANNEL (create inter task channel), PRIMT #/INPUT # (channel data transmission)
Real time control: DELAY n TICKS/ECONDS (delay, 1TICK=5.5ms), START EVERY (periodic execution)
I/O operation statement
Device I/O: OPEN "PORTA/PORTB" (serial port configuration), PRIMT/INPUT (data read/write), GET/PUT (single character operation)
Foreign I/O: IOURITE (options, data, address), IOREAD% (options, address), supports byte/double byte/word operations
Data blocks: READ/DATA (predefined data read), ROSE (reset data pointer)
Built in function classification
Mathematical functions: SIN/COS/TAN (trigonometric function, radians), LN/EXP (logarithmic/exponential), SQRT (square root, negative prohibited), ABS (absolute value)
String functions: CHR/RIGHT
/MID
(String truncation), LEN% (length), STR $/VAL/VAL% (numeric string conversion)
Bit operation functions: BIT_SET @/BIT_CLR @ (bit detection), BITVNet @ (bit modification), SHIFTL%/SHIFTR% (logical shift), ROTATEL%/ROTATER% (cyclic shift)
Special functions: BCD_IN%/BCD_OUT% (BCD to decimal conversion), BLOCKVNet @ (block transfer, supporting 32767 registers), GATEWAY_CMD-OK @ (gateway communication)
Error handling and compatibility
Error types and handling
Error codes: Compilation error (356-561), runtime error (756-895), fatal error (31, 40-4F)
Processing mechanism: ON ERROR GOTO line number (defines error handler), RESUME (resumes execution)
Predefined variables: ERR% (error code), ERL% (error line number), VNet @ (control INPUT prompt)
Version compatibility differences
V2 → V3: Added TASK statement required, reserved characters cannot be used as variable names, added predefined variables such as ERR%
V3 → V4: Added ABDEF statement, supports hardware event timeout disable (TIMEOUT=Disabled)

KONG JIANG
Add: Jimei North Road, Jimei District, Xiamen, Fujian, China
Tell:+86-15305925923