background image

ICP DAS                                                                                                                                                                                                                                             

 

                                                 

  LinPAC-52xx Series XV-Board API User Manual

                                            27   

4.1.2 DIO 

 

Â

 Location 

 

First, install the LP-52xx SDK from the LinPAC CD or from the ICP DAS FTP site, and follow the 

steps described below to implement the demonstration. Refer to the 

setxvdo.c

getxvdo.c

, and 

getmodbus.c

 files in the path 

C:\cygwin\LinPAC_AM335x_SDK\examples\xvboard\ 

folder for 

more details. 

 

Â

 

Wiring Connections

 

 

The following is an example of communication between the XV310 module and the M-7000 

series module. To read the M-7002 module values from an LP-52xx module, we need to connect 

an M-7002 module via the RS-485 serial bus, as illustrated below: 

 

LP-5231

M-7002 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

For more information related to the M-7002 module, refer to: 

http://www.icpdas.com/root/product/solutions/remote_io/rs-485/i-7000_m-7000/m-7002.html

 

Note:

 The default base address for M-7000 series modules is 

0

(Base 0)

 

 

 

Содержание LinPAC-22 Series

Страница 1: ...ICP DAS assume no liability for damages consequent to the use of this product ICP DAS reserves the right to change this manual at any time without notice The information furnished by ICP DAS is believ...

Страница 2: ...ogram 3 1 3 Specifications 4 2 XV Board API functions 5 2 1 modbusRequest 5 2 2 modbusRequestXV 8 2 3 getXVBitBack 11 2 4 getXVBit 13 2 5 getXVRegBack 15 2 6 getXVReg 17 2 7 setXVBit 19 2 8 setXVReg 2...

Страница 3: ...er I O functions However only one XV Board can be inserted into each PAC at a time For more information related to the XV Board series refer to http www icpdas com root product solutions hmi_touch_mon...

Страница 4: ...r Manual 4 1 3 Specifications For more detailed specifications related to specific XV Boards and the Modbus register table refer to http ftp icpdas com tw pub cd linpac napdos lp 5000 lp 52xx lp 5231...

Страница 5: ...COM1 dev ttyO1 cNetID Input The NetID for the device The default slave address for the XV Board is 1 cFunction Input The Modbus RTU protocol function code wAddr Input The channel address Note Input t...

Страница 6: ...ar szBuf 80 DWORD baudrate 115200 WORD wT Open the device file RetValue Open_Com comport baudrate Data8Bit NonParity OneStopBit if RetValue 0 printf open COM d failed n comport return FAILURE RetValue...

Страница 7: ...or COM4 RS 232 RxD TxD and GND Non isolated 9600 ttyO2 dev ttyO2 or COM2 RS 485 Data Data Non isolated 9600 ttyO5 dev ttyO5 or COM5 RS 485 Data Data 2500 VDC isolated 9600 2 Modbus RTU protocol funct...

Страница 8: ...mber of the COM port for the XV Board 1 COM1 dev ttyO1 cFunction Input The Modbus RTU protocol function code wAddr Input The channel address Note Input the channel address mapping in decimal format wC...

Страница 9: ...orceSingleCoil case FC15ForceMultipleCoil szBuf 0 wValue 0xff break case FC06PresetSingleRegister case FC16PresetMultipleRegister szBuf 0 wValue 8 0xff szBuf 1 wValue 0xff break default return FAILURE...

Страница 10: ...r COM4 RS 232 RxD TxD and GND Non isolated 9600 ttyO2 dev ttyO2 or COM2 RS 485 Data Data Non isolated 9600 ttyO5 dev ttyO5 or COM5 RS 485 Data Data 2500 VDC isolated 9600 2 Modbus RTU protocol functio...

Страница 11: ...t char szBuf WORD wBufLen Parameters cPort Input The number of the COM port for the XV Board 1 COM1 dev ttyO1 wAddr Input The channel address Note Input the channel address mapping in decimal format w...

Страница 12: ...szBuf RetValue getXVBitBack comport addr count szBuf sizeof szBuf Close_Com comport if RetValue 0 if count 8 printf d szBuf 0 else if count 16 dwValue szBuf 1 8 szBuf 0 printf u dwValue else dwValue s...

Страница 13: ...r szBuf WORD wBufLen Parameters cPort Input The number of the COM port for the XV Board 1 COM1 dev ttyO1 wAddr Input The channel address Note Input the channel address mapping in decimal format wCount...

Страница 14: ...f szBuf RetValue getXVBit comport addr count szBuf sizeof szBuf Close_Com comport if RetValue 0 if count 8 printf d szBuf 0 else if count 16 dwValue szBuf 1 8 szBuf 0 printf u dwValue else dwValue szB...

Страница 15: ...t char szBuf WORD wBufLen Parameters cPort Input The number of the COM port for the XV Board 1 COM1 dev ttyO1 wAddr Input The channel address Note Input the channel address mapping in decimal format w...

Страница 16: ...M d failed n comport return FAILURE memset szBuf 0 sizeof szBuf RetValue getXVRegBack comport addr count szBuf sizeof szBuf Close_Com comport if RetValue 0 dwValue szBuf 0 8 szBuf 1 printf u dwValue R...

Страница 17: ...ount char szBuf WORD wBufLen Parameters cPort Input The number of the COM port for the XV Board 1 COM1 dev ttyO1 wAddr Input The channel address Note Input the channel address mapping in decimal forma...

Страница 18: ...COM d failed n comport return FAILURE memset szBuf 0 sizeof szBuf RetValue getXVReg comport addr count szBuf sizeof szBuf Close_Com comport if RetValue 0 dwValue szBuf 0 8 szBuf 1 printf u dwValue Rem...

Страница 19: ...D wBufLen Parameters cPort Input The number of the COM port for the XV Board 1 COM1 dev ttyO1 wAddr Input The channel address Note Input the channel address mapping in decimal format wCount Input The...

Страница 20: ...n comport return FAILURE memset szBuf 0 sizeof szBuf szBuf 0 dwValue 0xff szBuf 1 dwValue 8 0xff szBuf 2 dwValue 16 0xff szBuf 3 dwValue 24 0xff RetValue setXVBit comport addr count szBuf sizeof szBu...

Страница 21: ...ar szBuf WORD wBufLen Parameters cPort Input The number of the COM port for the XV Board 1 COM1 dev ttyO1 wAddr Input The channel address Note Input the channel address mapping in decimal format wCoun...

Страница 22: ...0 printf open COM d failed n comport return FAILURE memset szBuf 0 sizeof szBuf szBuf 0 dwValue 8 0xff szBuf 1 dwValue 0xff RetValue setXVReg comport addr count szBuf sizeof szBuf Close_Com comport Re...

Страница 23: ...rror Set stop Bits error 6 ParityError Set parity Bits error 7 CheckSumError Checksum error 8 ComPortNotOpen The specified COM port is not open 10 SendCmdError Send command error 11 ReadComStatusError...

Страница 24: ...setxvao c getxvao c and getxvai c files in the path C cygwin LinPAC_AM335x_SDK examples xvboard folder for details Wiring Connections Run Set and read back the Analog Output value for a single channe...

Страница 25: ...ter 1 3 Specifications for details of other specifications for the XV Board together with the Modbus register table AO0 AO1 2 In this example we set the type code for the AO range to 02 which denotes...

Страница 26: ...table for the XV310 module for more details The table below provides the valid range for register addresses Refer to Chapter 1 3 Specifications for details of other specifications for the XV Board to...

Страница 27: ...es xvboard folder for more details Wiring Connections The following is an example of communication between the XV310 module and the M 7000 series module To read the M 7002 module values from an LP 52x...

Страница 28: ...dule Step2 Change the permissions for the files as shown below chmod 755 setxvdo exe chmod 755 getxvdo exe Step3 Execute the program Write to the DO0 channel setxvdo 0 1 1 Write to the DO1 channel set...

Страница 29: ...format is as follows Single channel DO Channel Address Count Channel Status Data Format Value DO0 00000 DO1 00001 DO2 00002 DO3 00003 1 ON or OFF 0 OFF 1 ON All channels Start Address Count Channel S...

Страница 30: ...s 2 115200 1 2 34 1 100 Read the DI3 channel on the M 7002 module getmodbus 2 115200 1 2 35 1 100 Read the DI4 channel on the M 7002 module getmodbus 2 115200 1 2 36 1 100 Read all DI channels on the...

Страница 31: ...ard API User Manual 31 Appendix A Revision History This chapter provides information related to the revision history of this document The table below shows the revision history Revision Date Descripti...

Отзывы: