EasyManua.ls Logo

Tonghui TH2816B - Page 47

Tonghui TH2816B
91 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
47
character sent by controller will be ignored. In order to make sure the
whole command is sent and received correctly, the character without a
return character should be sent again by the controller.
4) TH2816B sends information under following two conditions. The first is when
a character is received normally; TH2816B will send the character back as
response. The second is when a query command is received; TH2816B will
send the query response information.
5) Once a query command is received, TH2816B will send the query response
information immediately even if the whole command has not been executed.
So if the command includes two queries, the controller should read the
query responses twice. One query is recommended to be included in a
single command.
6) A query response is sent out in ASCII codes with NL as the terminal
character.
7) Several query responses will be sent continuously with 1ms interval. The
controller should be ready to receive the responses; otherwise the response
information will be lost.
8) The controller should receive the query response terminal character NL.
Otherwise you will confuse a terminal character NL with a returned character.
At the same time the controller should receive the last returned character
before receiving a query response.
9) For some commands that will take a long time to execute, for example
Correction command, the controller should keep waiting to avoid the next
command being lost when TH2816B is executing the former command.
Sample Program for Serial Interface
The following is a C language sample program under DOS environment. The
main function may be expanded by users, and the other sub functions teach you
how to input or output a character string via the RS232 interface.
#define PORT 0
#include "dos.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "conio.h"
void port_init( int port,unsigned char code );
int check_stat( int port ); /* read serial port state(16bit) */
void send_port( int port,char c ); /* send a character to serial port */
char read_port( int port ); /* recive a character form serial port */
void string_wr( char *ps ); /* write a string to serial port */
void string_rd( char *ps ); /* read a string from serial port */
char input[256]; /* quary recieve bufer */
main()
{ port_init( PORT,0xe3 );/* initilize serial port:baud = 9600,no verify,1 bit stop,8 bit
data */
string_wr( "trig:sour bus;*trg" );
string_rd( input );
printf( "\n%s",input );
string_wr( "freq 10khz" );
string_wr( "func:imp:type rx;:func:smon on" );
string_wr( "voltage:level 500mv" );

Table of Contents

Related product manuals