The text of a manual · part 19 of 23
Owner's Manual: BayTech M Series DAC, pages 181 to 190
Pages 181 to 190 of 229
The original document is the PDF (499 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the BayTech M3 DAC
Page 181
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________
* int n1; for(n1=1;n1!=61;++n1){ if(get_connect()==0){ delay(1000);; got_connect=0;; } else{ got_connect=1; break; } } return (got_connect); * * * This code fragment waits up to 60 seconds for the function get_connect() to go true. 4b. char *ctime() Input: none Output: pointer to a string Description: The ctime() function returns a pointer to a string of the following form: day month date hours:minutes:seconds year\n. No arguments are required. The buffer used by ctime() to hold the formatted output string is overwritten each time the function is called. If you wish to save the contents of the string, it is necessary to copy it elsewhere. An example of the ctime() function is shown in the serout(...) function example below. 4c. int serout(int a,int b,char *s) Input:
Output:
a - module number (1 to 16) b - desired port number (1 to 4) *s - pointer string for output 0 - successful
169
Page 182
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________
Description: The serout(. ..) function transfers the specified null terminated character string to the selected module and port. The selected module must be a 4-port serial I/O module (e.g., V74, V75, etc.). Example: Assume a V74 4-port serial I/O module is installed as Module 2. int s; char string[30]; * * * x=O; do{ delay(1000); strncpy(string,ctime()); serout(2,1,string); serout(2,1,"\r"); } while(x<100); * * * In this code fragment, the time and date is output to Module 2, Port 1 each second for 100 seconds. The output will be sirnilar to the following: Tue Aug 13 08:11:01 1998 Tue Aug 13 08:11:02 1998 Tue Aug 13 08:11:03 1998 * * * Tue Aug 13 08:12:39 1998
4d. int serin(int a,int b,char *s) Input:
Output:
170 a - module number (1 to 16) b - desired port number (1 to 4) *s - pointer stnng for output 0 - successful
Page 183
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________
Description: The serin(...) function reads data from the selected module and stores the data as a null terminated string in the specified character array. The selected module must be a 4-port senal I/O module. Example: Assume a V74 4-port serial I/O module is installed as Module 2 and is receiving data from a modem connected to Port 1 after a dial string has been sent. int get_connect() * * * { char from_modem[30]; char *p; serin(2,1,from_modem); p=strchr(from_modem, ‘C’); if(strncmp(p,"CONNECT",7)==0); return(1); else return(0); } * * * In this code fragment, data received from Module 2, Port 1 is stored in character array “from_modem". The "p" pointer is positioned to the first occurrence of capital “C” and the next seven characters are compared against”CONNECT". If a match is found, a connection to the remote modem is assumed and subsequent data can be sent to the modem. 4e. int charsout(int a,int b,char *s) Input: a - module number (I to 16) b - desired port number (1 to 4) *s - pointer string for output Output: 0 - successful
171
Page 184
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________
Description: The charsout(...) function transfers a specified number of characters from the specified character array to the selected module and port. The first character of the specified array must be a byte count (0 to 255 decimal). The charsout(...) function sends all characters in the byte count range include null characters. The selected module must be a 4-port serial I/O module (e.g., V74, V75, etc.). The charsout(...) function behaves the same way as the serout(...) function described above except that only a specified number of characters are sent and any null characters encountered in the byte count range are sent. 4.f int charsin(int a,int b,char *s) Input: a - module number (1 to 16) b - desired port number (1 to 4) *s - pointer strino for output Output: 0 - successful Description: The charsin(...) function reads all data from the selected module including null characters and stores the data in the specified character array. The first character stored is a byte count that corresponds to the number of characters read (0 to 255 decimal). The selected module must be a 4-port serial I/O module. The charsin(...) function behaves the same way as the serin(...) function described above except that all characters are read (including null characters) and the first byte stored is the byte count. 4g. int dial(int a,int 1,char *s) lnput: a - module number (1 to 16) b - integer number 1 *s - nointer string for output Output: 0 - successful Description: The dial(. ..) function causes the selected module to go off-hook and send the character string to the modem. The selected module must be a V93 modem module. Example: Assume a V93 modem host is installed as Module 1 and a V74 module installed as Module 2. char dial_strl[7]={"ATDT18005551212\r"}; dial(1,1,dial str); serout(2,1,"123\r\n");
172
Page 185
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________
In this example the dial string ATDT18005551212\r is first transmitted to the modem in Module 1. After a connection is made the string "123\r\n” is transmitted. 4h. int hang_up(int a,int 1) Input: a - module number (1 to 16) b - integer number 1 *s - pointer string for output Output: O - successful Description: The hang_up(...) function causes the selected module and port to go onhook. The selected module must be a V93 modem module. Example: Assume a V93 modem host is installed as Module 1 and a V74 module installed as Module 2. char dial_str[10]={"ATDT18005551212\r"}; dial(1,1,dial str); serout(2,1,”123\r\n”); delay(10000); hang up(2,1); In this example the dial string ATDT18005551212\r is first transmitted to the modem in Module 1. When a connection is made, the string "123\r\n” is transmitted. After a 10 second delay the modem is disconnected with the hang_up(...) function. 4i. int atod(int a,int b,float *c) Input: a - module number (1 to 16) b - desired channel number (1 to 16 for the V77 or 1 to 6 for the V84) *c - pointer to storage location Output: O - successful (always) Description: The atod(...) function stores the value of a specified V77 ADM-1 or V84 ADR-1 analog input channel into the floating point variable. Example: Assume a V84 ADR-1 is installed as Module 3 and a V74 I/O module is installed as Module 2. double valdob; float atodVal; int s; char string[30];
173
Page 186
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________ x=O; do{ delay(1000): atod(3,1,&atodVal): valdob=atodVal: sprintf(string,"val=;%6.3e\r\n",valdob); ++x serout(2,1,string); }while(x<100); In this code fragment, the analog value of Module 3, Channel 1 is sent to the device connected to Module 2, Channel 1 each second for 100 seconds. The output will look like the following for a voltage input of 10.0 volts: val = l.OOOOOOE+OO1 val = 1.OOOOOOE +001 val = l.OOOOOOE+OO1 val = 1.OOOOOOE + 001 4j. int disc_in(int a,int b) Input: a - module number (1 to 16) b - desired channel number (1 to 16 for the V79 & V80 or 7 to 12 for the v84) Output: 1 - discrete input is true (V79- closed, V80- voltage detected) O discrete input is false (V79- open, V80- no voltage detected) Description: The disc_in(.. .) function determines the input status of a selected discrete module and channel. It returns a " 1 " if the input is true or a "0" if the input is false. The selected module must be a V79 PDI-l, V80PDI-2, or a V84 ADR-I. Example: Assume a V84 ADR-1 is installed as Module 3 and a V74 I/O module installed as Module 2. * * * int s; char string[30]; x=O do{ delay(1000);
174
Page 187
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________ strncpy(string,ctime(),19); s=disc in(3,7); if(!s){ serout(2,1,"on "); serout(2,1,string); serout(2,1,"\r"); }else{ serout(2,1,"off "); serout(2,1,string); serout(2,1,"\r"); ++x; }while(x<100); * * * In this code fragment, the status of the discrete input Module 3 Channel 7 is sent to Module 2, Port I each second for 100 seconds. The output will look like the following: on Tue Aug 13 08:11:01 on Tue Aug 13 08:11:02 off Tue Aug 13 08:11:03 * * * on Tue Aug 13 08:12:39 4k. int rlyset(int a,int b) Input: a - module number (1 to 16) b - desired channel number (1 to 8 for the V78 or 13 to 16 for the V84) Output: O - successful (always) Description: The rlyset(...) function energizes the specified relay channel of a selected module. The selected module must be a V78 CRM-1 or a V84 ADR-1. An example of the rlyset(...) function is shown in the rlyrst(...) function example below. 41. int rlyrst(int a,int b) Input: a - module number (1 to 16)
175
Page 188
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________ b - desired channel number (1 to 8 for the V78 or 13 to 16 for the V84) Output: O - successful (always) Description: The rlyrst(...) function de-energizes the specified relay of a selected module. The selected module must be a V78 CRM-1 or a V84 ADR-1. Example: Assume a V84 ADR-1 is installed as Module 3. * * * do{ delay(1000): rlyset(3,13); delay(1000); rlyrst(3,13): while l==1; In this code fragment, the relay located at Module 3, Channel 13 is energized for 1 second and then deenergized for I second continuously.
5. Default channel names and logic value defulitions: HOST AND I/O CHANNELS – DEFAULT CHANNEL NAMES AND LOGIC VALUE Module Type V71 Host Module
V93 Host Module Module
V74/V75/V87 I/O Module Note: These modules must be programmed to operate in command mode. V77 A-to-D Module Note: This module must be programmed to operatein immediate sampling mode and command reporting mode.
Channel Number 1 2 Note: Port 2 is used only if PCM-1 receives data from V71 Port 1. 1 2 Note: Port w is used only if PCM-1 receives data from V93 Port 1. 1 2 3 4
(differential)
(single-ended)
176
1 2 . . 8 . . 16
Logic
Page 189
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________ V78 Relay Module Note: This module must be programmed to operate in command mode. V79 Switch Closure Module Note: This module must be programmed to operate in command mode. V80 Isolated Voltage Module Note: This module must be programmed to operate in command mode. V84 A-to-D/Relay/Switch/Isolated Voltage Input Module Note: A-to-D channels must be programmed to operate in immediate sampling mode and command reporting mode.
V93
1 2 . . 8 1 2 . . 16 1 2 . . 16 1 (A-to-D) 2 (A-to-D) . . 6 (A-to-D) 7 (Switch/Voltage Input) . . 12(Switch/Volatage Input) 13 (Relay) 14 (Relay) 15 (Relay) 16 (Relay)
1 = Energized 0 = De-Energiz
1 = closed (no r 0 = open (max
1 = voltage dete 0 = no voltage d
A-to-D Channe
Switch Closure 1 = closed (no r 0 = open (max
Isolated Voltag 1 = voltage dete 0 = no voltage d
Relay Channel 1 = Energized 0 = De-Energiz
OPERATION a. You are ready to perform commands when a terminal or PC is communicating with: (1) the V93A's EIA-232 port. (2) a remote modem is communicating with the V93A’s modem. b. If you are using a PC, you can communicate with the V93A by using a terminal emulation program or by using a software communications program that emulates a terminal. BayTech supplies an utility diskette which includes TERM.EXE, a terminal emulation program, to put your PC into terminal emulation mode. Popular 177
Page 190
M SERIES DAC BASE UNIT AND MODULE OPERATION ____________________________________________________________________________ communication software packages such as PROCOMM PLUS(R) by Data Storm Technologies, also provide terminal emulation capabilities and allow for communications with the V93A. c. If configuring the V93A from the EIA-232 port, configure the host terminal’s serial parameters to match those of the V93A. From the factory, the V93A is set at 9600 baud, 8 data bits, 1 stop bit no parity and XON/XOFF disabled.
LOGIN PASSWORD Once the V93A has been connected to the phone line and configured for the desired parameters, a remote host computer can make a connection to the V93A modem over a dial line and perform data acquisition and control functions with the various M Series I/O modules. The V93A will send a message similar the following when a remote host computer establishes a connection: M-Series V93A DAC Host Unit 2 Module 1 REV. 4.XX Copyright (c) Bay Technical Associates
1995-1997
To login, enter password Login: BTA (default)
You will be prompted to type in the desired password followed by <ENTER> when a connection to the V93A modem is first made. You are given three tries to type in the correct password before the modem hangs up. Type the appropriate password (Default is BTA). The V93A will respond with: Login successful Port Select Code: $BT Attnetion Character: ;
Among the functions you can perform are data commands/port selection and configuration. Configuration commands are used to program the features of the various I/O modules and the data
178