Download TelePACE C Tools User Manual

Transcript
ioRead4Ain
Read 4 Analog Inputs into I/O Database
Syntax
#include <ctools.h>
unsigned ioRead4Ain(unsigned moduleAddress, unsigned startInputRegister);
Description
The ioRead4Ain function reads any 4 point Analog Input Module at the specified
moduleAddress. Data is read from all 4 analog inputs and copied to 4 consecutive input
registers beginning at startInputRegister.
The function returns FALSE if the moduleAddress or startInputRegister is invalid or if an I/O
error has occurred; otherwise TRUE is returned.
The valid range for moduleAddress is 0 to 15. startInputRegister is any valid Modbus input
register between 30001 and (30000 + NUMINPUT - 3).
Notes
Data is not copied to the I/O database for registers that are currently forced.
To read data from an I/O Module continuously, add the module to the Register Assignment.
Refer to the section I/O Database and Register Assignment for details.
This function is contained in the ctools.lib library. Load this library in you linker command
(.cmd) file as shown in the sample file appram.cmd in your ctools directory.
The IO_SYSTEM resource must be requested before calling this function.
See Also
ioRead8Ain
Example
This program displays the values of the 4 analog inputs read from a 4 point Analog Input
Module at module address 0.
#include <ctools.h>
void main(void)
{
unsigned reg;
request_resource(IO_SYSTEM);
/* Read data from digital input module and write it to I/O database
*/
ioRead4Ain(0, 30001);
/* Print data from I/O database */
fprintf(com1, "Register
Value\n\r");
for(reg = 30001; reg <= 30004; reg++)
{
fprintf(com1, "%d
%d\n\r", reg,
}
dbase(MODBUS, reg));
release_resource(IO_SYSTEM);
TelePACE C Tools User and Reference Manual
May 9, 2007
260