B
B-13GFK–0804B Appendix B Micro PLC Protocol
Sample Programs

Sample C Program for Turbo C/C++ DEMO1.C

This program is provided as-is. Do not call for technical support for this free

program.

#include <dos.h>

#include <stdio.h>
#include “MCROCOMM.C”
int port;
int memtype;
int addr;
int count;
char buf [16];
int temp;
int z,x,y,value1, value2 = 0;
main ( )
{
while (z == 0)
{ port = 2 ; /* COM3 */
memtype = 2;
addr = 1;
count = 16;
temp = TCL_Rreg(port,memtype,addr,count,buf);
x = buf[0];
y = buf[1];
value1 = (x & 0x00ff) + ((y & 0x00ff) <<8) ;
x = buf[2];
y = buf[3];
value2 = (x & 0x00ff) + ((y & 0x00ff) <<8) ;
printf(Register 1, 2 values are %d %d \n, value1, value2);
}
return (0);
}