User Tools

Site Tools

한국어

cubloc:cubloc_basic_language:index

Cubloc BASIC Language

Declare Device

The device being used must be declared before using BASIC or Ladder Logic. Below is an example of declaring the Cubloc CB220 module.

Const Device = CB220      ' Use CB220.

This should be the first line of a program. When this command is not used, the CB220 model will be assumed.

Const Device = CT400      ' Use CB400.
Const Device = CB280      ' Use CB280.

Cubloc BASIC Features

Cubloc BASIC supports functions and subroutines.

The user is able to create subroutines and functions to organize their programs. Using subroutines and functions allows the user to reuse code, and organize programs for better readability.

Function SUM( A As Integer, B As Integer) As Integer
Dim RES As Integer
RES = A + B
SUM = RES
End Function

Calculations can be done within conditional statements such as If, While, etc…

If ((A + 1) = 100) Then GoTo ABC
If ((A + 1) = 100) And (B / 100 = 20) OR C = 3 Then GoTo ABC

Hardware RS-232 Communication.

Cubloc uses a hardware RS-232 UART instead of software RS-232 UART allowing real-time processing to continue during RS-232 operations.

A graphic LCD library is provided.

Cubloc provides a complete graphic LCD library for the Comfile GHLCD product. Boxes, lines, circles, and other graphics commands are easily implemented in a few lines of code.

Various Communication Protocols are supported.

CUNET(I2C) : Display peripherals such as character LCDs RS232 : up to 4 channels MODBUS : built-in slave functions I2C : I2C commands supported (I2CRead I2CWrite) SPI : SPI commands supported (ShiftIn, ShiftOut) PAD: Keypad, touchpad supported.

Simple BASIC program

Below is an example of a simple BASIC program with a Do…Loop statement.

Dim A As Byte
Do
    ByteOut 0, A
    A=A+1
Loop

This program outputs the increasing binary value of A to Ports P0-P7. The next program uses a function to accomplish the same task:

Dim A As Byte
Do
    ByteOut 0, A
    A=ADD_VALUE(A)
Loop
End
 
Function ADD_VALUE(B As Byte) As Byte
    ADD_VALUE = B + 1
End Function

By placing A=A+1 in a function, the user will be able to separate one big program into small manageable pieces. As you can see here, the main program ends at the End command, and functions are added afterwards.

Go CUBLOC home

cubloc/cubloc_basic_language/index.txt · Last modified: 2016/04/14 11:07 (external edit)