![IDEC OpenNet series Скачать руководство пользователя страница 383](http://html.mh-extra.com/html/idec/opennet-series/opennet-series_user-manual_617384383.webp)
26: L
ON
W
ORKS
I
NTERFACE
M
ODULE
26-22
O
PEN
N
ET
C
ONTROLLER
U
SER
’
S
M
ANUAL
Reading Transmit Data from Data Registers in the L
ON
W
ORKS
Interface Module
The following diagram is a typical example of reading transmit data from the data registers in the L
ON
W
ORKS
interface
module.
Application Program Example for Data Read
The following program is an example to substitute transmit data of data register C008h for an 8-bit output network vari-
able (nv_o8). When you modify or create an application program, make sure that the application program includes the fol-
lowing codes in italics.
1.
/* Output Network Variables */
2.
network output unsigned char nv_o8;
3.
/* define */
4.
#define GA_BCTL 0xC01A
5.
#define GA_FCDR_TX 0xC008
6.
#define BCTL_NWR_REQ 0x04
7.
#define HIGH 1
8.
/* Define IO_4 RUN */
9.
IO_4 input bit PI_RUN;
10.
11. when(TRUE){
12. unsigned char *pGA;
13. unsigned char dat;
14. unsigned char tx_dat;
15. while(TRUE){
16. if (io_in(PI_RUN) == HIGH){
17. pGA = (unsigned char *)GA_BCTL; /* Preparation for data read */
18. *pGA |= BCTL_NWR_REQ;
19. dat = *pGA;
20. if (dat & BCTL_NWR_REQ){ /* Preparation for data read complete */
21. pGA = (unsigned char *)GA_FCDR_TX;
22. tx_dat = *pGA; /* Read data from register C008h */
23. pGA = (unsigned char *)GA_BCTL;
24. pGA &= ~BCTL_NWR_REQ; /* End data read */
25. nv_o8 = tx_dat; /* Substitute the value for output network variable (nv_o8) */
26. break;
27. }
28. }
29. }
30. }
NO
YES
Is preparation for data
read complete?
Preparation for data read
Read data
End data read
Phone: 800.894.0412 - Fax: 888.723.4773 - Web: www.clrwtr.com - Email: [email protected]