Using Event task with PLC Twido

Using Event task with PLC Twido
Description:

- Description and example how to use Event task subroutine in PLC Twido with example of event task triggered by an input with description of the syntax.

Hardware
Twido PLC SV:3.2
Software
MS Windows XP SP1
TwidoSoft V3.2

1) Introduction:


- An event task is part of program which is executed with higher priority then the main program and it is executed only when a conditon is met. It guarantees a rapid response time.
- The event could be triggered by software or hardware condition (VFC counting, physical inputs, periodic event).
- The events are queued till they are executed, higher priority could be set.

2) Example of configuring an event caused by input interruption (rising edge).
a) In menu Hardware/Input configuration set up which input, which edge should be detected and number of subroutine to be executed. In this example it will be %I0.2, event caused by rising edge, low priority and event subroutine number 0.

Note: Only inputs %I0.2-%I0.5 could be event source.
 

b) The program to be executed when a rising edge is detected on input %I0.2 must be called as case subroutine SR 0. To call a subroutine the main program must be finished by a rung with END statement. The subroutine must be finished by RET statement then.



c) The event subroutine must have rung header stated as subroutine with the right number (please see below). To get Rung header menu double click on the rung header when editing the rung.



d) the syntax result should be as below:



All information provided in this document is correct to the best knowledge of the author. This approach was designed and tested in laboratory conditions. The environment influences behaviour of electronic devices and therefore the user takes full responsibility for applying presented solutions.

Twido PLC - How to use 0-20mA Analog card with 4-20mA device or sensor

Twido PLC - How to use 0-20mA Analog input card with 4-20mA sensors or devices


Description:
The following describes conversion using 0-20mA Twido analogue input modules with sensors or devices working in 4-20mA range.
ANY Hardware Twido controller supporting floating point data type:
TWDLMDA20DRT
TWDL●●● 40D●●
Analogue input modules:
TWDAMI8HT  8 Input Analog channels 10bit resolution
TWDAMI4LT  4 Input Analog channels 12bit resolution
Twidosoft & firmaware 3.5
Windows XP SP2

1. Line Theory - Conversion background
The conversion of input current to value is linear. Characteristics can be described using linear equation
f(x)=m*x+c. Where m=slope and c=y intercept (y intercept , where the line cross the y axis)
Conversion consists of changing the slope m, and y-intercept c.

Figure 1 Characteristics of 0-20mA and 4-20mA analog I/O modules with 10bit resolution

Conversion for 4-20mA device connected to 0-20mA input
TWDAMI8HT - 10bit, normal range and TWDAMI4LT – 12bit,

Where :
Value(scaled) = The rescaled value at 0-20mA 
Value(meas) = The measured value
RangeXmax = 1024 for TWDAMI8HT & 4096 for TWDAMI4LT
RangeXmin = 0

Twido Analog Configuration and Program :

We Select TWDLCAA40DRF CPU and the Analog module TWDAMI8HT










Figure 2 Twidosoft application - Conversion for 4-20mA device connected to 0-20mA input with 10bit resolution and error (Sensor Fault) check

In case %MW100 is negative, it’s set to 0. This prevents %MW100 from reaching negative value when the measured current is lower than 4mA.
If the wire to the 4-20mA device is broken, current drops to 0. This state is detected in the application. The threshold for detection of the error can be altered; value 100 is used as an example.

The above approach is not neccessary for Micro TSX37 Analog cards as they could be configured to be used as 4-20mA or 0-20mA inputs
(TSXAEZ802 - TSXAEZ414 - TSXAMZ600)

3. Summary

Using this algorithm will allow to connect devices with 4-20mA analogue output to TWDAMI8HT and TWDAMI4LT 0-20mA analogue inputs. However, it will lower effective resolution of analog input by 20% since only 4-20mA from 0-20mA range is used effectively. Maximum error caused by conversion from float to integer is lower than 0.1% from the full scale

NOTE : It's your rensponsibility to use this example properly in your applications

Silo Material Weight Calculation

This Block (S7300 CPU Simatic) calculate the weight of the material in the Silo using a sonar level meter properly connected in an analog input (16bit type analog card recommended)
(or maybe something else but analog meter), given the dimensions of the SILO (constant values)
and the specific weight of the material  "global".Cntr_Specific_Weigth_S11
The input is the level measurment in cm "view".level_silo11
The output calculated in kg (REAL)  "global".view_silo11_weight

Here we use DBs to store and change the values and the results. Of course you could use a memory type value but MUST be the same type as the program indicate. It is reccomended to use your own DB.



It is your responsibility to use the block properly in your applications

You could REQUEST for download