General-purpose I/O – TML Programming Details (Firmware version FAxx) |
In TML you can access up to 40 digital I/O lines, numbered: #0 to #39. Each intelligent drive/motor has a specific number of inputs and outputs, therefore only a part of the 40 I/Os is used. The I/O numbering is common for all the products; hence each product has its own list of available I/Os. This is not an ordered list. For example, a product with 4 inputs and 4 outputs can use the inputs: #36, #37, #38 and #39 and the outputs #28, #29, #30 and #31. Remark: Read carefully the drive/motor user manual to find which I/O lines are available. Do not attempt to use the other I/Os. This may harm your drive/motor. Some drives/motors include I/O lines that may be used either as inputs or as outputs. In these cases, the same I/O number occurs both in the list of available inputs and in the list of available outputs. Before using these lines, you need to specify how you want to use them, with the TML commands: SETIO#n OUT; //Set the I/O line #n as an output SETIO#n IN; //Set the I/O line #n as an input Remarks:
You can read and save the status of an input with the TML command: user_var = IN#n; // read input #n in the user variable user_var where user_var is a 16-bit integer variable and n is the input number. If the input line is low (0 logic), user_var is set to 0, else user_var is set to a non-zero value. You can set an output high (1 logic) or low (0 logic) with the following commands: ROUT#n; // Set low the output line #n SOUT#n; // Set high the output line #n Remark: Check the drive/motor user manual to find if the I/O lines you are using are passed directly or are inverted inside the drive/motor. If an I/O line is inverted, you need to switch high with low in the examples above, which refer to the I/O line status at the drive/motor connector level. Using TML command: user_var = INPORT, 0xE00F; // read inputs in variable user_var you can read simultaneously and save in a 16-bit integer variable the status of the following inputs:
The bits corresponding to these inputs are set as follows: 0 if the input is low and 1 if the input is high. The other bits of the variable are set to 0. Remark: Each drive/motor contains in the TML parameter DIGIN_INVERSION_MASK an inversion mask for these inputs. A bit set to 1 in this mask, means that the corresponding input is inverted. The value set in user_var is obtained after a logical XOR between the inputs status and the inversion mask. As result, the bits in user_var always show correctly the inputs status at connectors level (0 if the input is low and 1 if the input is high) even when the inputs are inverted. Using TML command: OUTPORT user_var; // Send variable user_var to external output port you can set simultaneously with the command value specified by a 16-bit integer variable, the following outputs:
The outputs are set as follows: low if the corresponding bit in the variable is 0 and high if the corresponding bit in the variable is 1. The other bits of the variable are not used. Remark: Each drive/motor contains in the TML parameter DIGOUT_INVERSION_MASK an inversion mask for these outputs. A bit set to 1 in this mask, means that the corresponding output is inverted. The commands effectively sent to the outputs are obtained after a logical XOR between the user_var value and the inversion mask. As result, the outputs at connectors level always correspond to the user_var command values (low if the bit is 0 and high if the bit is 1), even when the outputs are inverted. |