Please click on an example that interest you to navigate there...

Example 1 PLC to greet you "Good Morning" or "Good Evening" based on Time of the Day
Example 2 Tachometer: Measure the frequency of incoming pulses connected to a digital input and display on LCD
Example 3 Every 0.5s, measure the voltage at analog Input #1, then format it as ASCII data and transmit via RS485
Example 4 Read data from RTU Slave 1 and WRITE data to RTU Slave 2. Both slaves on the same RS485 network 

Others

Quick examples on using Stepper motor,  Real Time Clock, Pulse Width Modulation etc. etc.

Example  1

Say when you press a button, your PLC will greet you either "Good Morning", "Good Afternoon" or "Good Evening" on its LCD display depending on the time of the day.

1) Create a ladder logic circuit, with an input contact named "Greetings", and use it to trigger a custom function #10 when the button connected to this input is pressed.

Note:  Circuit #1 shown below is a standard ladder "seal" circuit which turns on the output "Run" whenever the input "Start" is closed momentarily. The "Run" output will only be turned OFF when the NC "Stop" input is energized. In Circuit #2, both the "Run" bit and  "Greetings" input must be closed to trigger the Custom Function #10. The Custom Function #10 is "differentiated" (aka "one-shot") type which means that it will execute only once when triggered

example1.gif (9224 bytes)

2) Next, edit the custom function #10 and enter the following TBASIC program code:

example2.gif (7687 bytes)

That's all ! 

Note: You only need to use the BASIC language as and when needed as demonstrated in the above case. Otherwise, the PLC will happily execute standard ladder logic circuit based on AND, OR, NOT, timers, counters only!

Example  2

Create your own Digital Tachometer: Monitor the frequency of incoming pulses and display the reading on an LCD display

This is unbelievably easy to achieve with Ladder+BASIC language! As you can see below , the whole program comprises just one ladder logic rung and one custom function:

example2a.gif (8125 bytes)

The ladder rung uses a built-in "clock pulse" to trigger the function #1 every 0.2s. The content of Fn_#1 is displayed to the right.

example2b.gif (7702 bytes)

The moment a pulse frequency measurement channel is enabled by the "PMON" command, you can use the built-in "PULSEFREQUENCY(1)" command to obtain the frequency value in Hz. The "SETLCD" command is used to display the data and text on the LCD.

Example  3

Every 0.5s, measure the signal at Analog Input #1 and then format the reading into ASCII string as "x.xx V" and send out to the RS485 port.

This is also very easily accomplished with Ladder+BASIC.  Custom Function Fn_#1 uses built-in ADC(1) command to read ADC signal, which returns a value between 0 - 4096. It  then performs math and string operations to convert the reading into ASCII string that can range from "0.00V" to "5.00V". The PRINT #3 function is then used to send the ASCII string out of its RS485 port (comm port #3).

example3a.gif (9490 bytes) example3b.gif (8963 bytes)

 

Example  4

Every 0.1s, read data from MODBUS Slave ID=05, divide the data by 3 and add 10, then write the modifed data to MODBUS slave ID = 09.

The Super PLC can be a MODBUS RTU master for as many as 247 RTU slaves. The built-in READMODBUS and WRITEMODBUS commands make it extremely simple to READ data from or WRITE data to slave devices, as follow:

example4a.gif (9297 bytes)

 

Others

The following demonstrate how easy it is to program in TBASIC language to achieve tasks that can be quite tedious or impossible in traditional Ladder PLCs.

 

1. Show Message on built-in LCD 2. Read Analog Input
SETLCD row, column, string

e.g.
SETLCD 1,1,"Hello World"
SETLCD 2,3,"Hour ="+STR$(TIME[1])

x = ADC(n)

n = 1 to 4 (the analog input channel #)
It returns a value ranging from 0 to 4096 which can be assigned to any variable x or used in expression.
e.g.     C = ADC(1)
     DM[I] = ADC(2)*1000/30

3. Set Analog Output 4. Set PWM Output
SETDAC n, x
       n
= 1 (D/A #1)
      x =
output value 0 to 4096

e.g.
      
SETDAC 1, (X+Y)/100
SETPWM n, x, freq
       n
= 1 or 2 (PWM Channel #)
       x
= output value 0-10000 (0-100%)
       freq
= frequency in Hz
e.g.
     
SETPWM 1, 2550, 10000
5. Run Stepper Motor 6. Read Real Time Clock
STEPSPEED n, pps, acc
       n
= 1 or 2 (Stepper controller channel)
     pps = Maximum pulses per second
       acc = acceleration steps to reach max pps.

STEPMOVE n, count, rly
       n = 1 or 2 (Stepper controller channel)
       count = No. of steps to move
      rly = the internal relay bit to turn ON after
               motion ended.

e.g.  STEPSPEED 1, 5000, 100
        STEPMOVE 1, 25000, 10

The PLC's Real-Time-Clock (RTC) derived date and time can be accessed via variables DATE[1] to DATE[3] and TIME[1] to TIME[3], respectively.

Year  - DATE[1]
Month- DATE[2]
Day  - DATE[3]
Day of Week - DATE[4]
Hour    - TIME[1]
Minutes  - TIME[2]
Seconds - TIME[3]

e.g.    IF DATE[4] > 5 THEN … :ENDIF

Still not convinced of the power and ease of Ladder+BASIC? Then download our TRiLOGI software with built-in simulator, create the above program and run it on your PC to verify the outcome.  This software is used by thousands of college students for learning PLC programming. Almost everything can be simulated, including the LCD display and the real time clock.