Browse
 
Tools
Rss Categories

Drive digital I/Os handling

Author: AM Reference Number: AA-00494 Views: 5448 Created: 14-07-2016 17:10 Last Updated: 07-05-2021 16:13 0 Rating/ Voters

1. Digital inputs status reading

The status of one or of multiple digital inputs can be checked using a 16 bits - integer type user variable. The corresponding  TML code lines are:

- variable_name = IN(input_number); /*read one input status in an user variable*/
- variable_name  = IN(input_no, input_no, input_no .....); /*read the status of multiple inputs*/

After the code above is executed the respective user variable will contain the input(s) status: 1 for HIGH and 0 for LOW.

To be more clear let's check the example in the picture below, that uses the "var_i1" integer variable to read the status of the IN(0) digital input.

The "var_i1 = IN(0);" TML instruction is used to read the status of the IN(0) digital input inside the "var_i1" variable.
To check the "var_i1" variable value, the drive is interrogated using the "?var_i1;" command. The drive replies at the first reading with 0 (LOW) and second time with 1 (HIGH). The input status has changed between the two readings.

In EasyMotion Studio, the status of an input can be also read in an user variable through the "I/O" window..

Below is another example, in which the "var_i1" variable is used to read the status of the IN(1) and IN(10) digital inputs.

var_i1 = IN(1,10);
? var_i1

Following the first code line execution, the drive will set the correspondent bits (bits 1 and 10, in this case) of the "var_i1" variable to 1 or 0, depending on the inputs status (1 - HIGH; 0 - LOW).
The second instruction ("?var_i1;") will return the inputs status.



As is shown in the  picture above, at a first reading the returned value is 0. This means that both inputs are LOW.
At a second reading the drive returns the value 2 (0x0002). Converted to binary this became 0000 0000 0000 0010. So the bits that corresponds to IN(1) and IN(10) are 1 and respective 0. This means the status of the IN(1) input is HIGH and the status of the IN(10) input is LOW.

In EasyMotion Studio, the multiple inputs status can be also read using the "I/O" option.

If the reading of all digital inputs status is required for a drive, then the following commands can be used:

?DIGIN_STATUS;
or
?INSTATUS;

For details, lets consider the example below.



Following the "?DIGIN_STATUS;" or "?INSTATUS" commands sending, the drive answers with 960 (0x03C0). Converted to binary the answer becomes 0000 0011 1100 0000. Each bit shows to the status of the correspondent digital input (bit 0 - IN(0), bit 1 - IN(1), bit 2 -  IN(2) and so on, function on the available digital inputs on the respective drive). So, the IN(6), IN(7), IN(8) and IN(9) digital inputs are HIGH , while the rest are LOW.

2. Digital outputs handling

2.1 Digital outputs status reading

In case of the outputs, we can only read the status of all the drives digital outputs. The corresponding TML code is:

?DIGOUT_STATUS;

The example below shows the answer of a drive, that has received the command above.



The drive replies that the DIGOUT_STATUS is 23 (0x0017). Converted to binary the value become 0000 0000 0001 0111. As in case of the inputs, each bit of the DIGOUT_STATUS variable represents the status of the correspondent digital output (bit 0 - OUT(0), bit 1 - OUT(1), bit 2 -  OUT(2) and so on, function on the available digital outputs on the respective drive). So, in this case, the OUT(0), OUT(1), OUT(2) and OUT(4) are HIGH, while the rest of the outputs are LOW.

2.2. Digital outputs status setting

The following TML code can be used to change the status of one or of multiple digital outputs>

 OUT(0,1,2,....,n) = hex_value_that_has_the_correspondent_bits_set_to_0_or_1;

For example, if the OUT(1) output needs to be set to to HIGH, the following command should be sent to the drive: "OUT(1) = 0x0002;".
Write in binary, the value above is:  0000 0000 0000 0010. As was mentioned above, the bit no. 1 is set to 1 (HIGH status).

In EasyMotion Studio, an output status can be set through the "I/O" dialog.

To set the status of the OUT(2) and OUT(4), for example, to HIGH and respective to LOW, the following code will be sent to the drive: "OUT(2.4) = 0x0004;"
Write in binary the value above is:  0000 0000 0000 0010. So, the bit no. 2 was set to 1 (HIGH) and the bit no. 4 to 0 (LOW).
If both outputs needs to be set to HIGH, the sent code will change to "OUT(2,4) = 0x0014;". That means both bits (2 and 4) were set to 1 (0x0004 = 0000.0000.0001.0010).

In EasyMotion Studio the changing of multiples digital outputs status can be also done through the "I/O" option.



Rss Comments
  • There are no comments for this article.