Campbell-scientific CR1000 Measurement and Control System Uživatelský manuál Strana 208

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 588
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 207
Section 7. Installation
208
7.8.8.5.3 Output Programming Basics
Applications with the purpose of transmitting data to another device usually
include the following procedures. Other procedures may be required depending on
the application.
1. Open a serial port (SerialOpen() command) to configure it for
communications.
Parameters are set according to the requirements of the communications link
and the serial device.
Example:
SerialOpen(Com1,9600,0,0,10000)
Designate the correct port in CRBasic.
Correctly wire the device to the CR1000.
Match the port's baud rate to the baud rate of the device in CRBasic.
Use a fixed baud rate (rather than auto baud) when possible.
2. Build the output string.
Example:
SerialOutString = "*" & "27.435" & "," & "56.789" & "#"
Tip — Concatenate (add) strings together using & instead of +.
TipCHR() instruction is used to insert ASCII / ANSI characters into a
string.
3. Output string via the serial port (SerialOut() or SerialOutBlock() command).
Example:
SerialOut(Com1,SerialOutString,"",0,100)
Declare the output string variable large enough to hold the entire
concatenation.
Example:
Public SerialOutString As String * 100
SerialOut() and SerialOutBlock() output the same data, except that
SerialOutBlock() transmits null values while SerialOut() strings are
terminated by a null value.
7.8.8.5.4 Translating Bytes
One or more of three principle data formats may end up in the SerialInString()
variable (see examples in Serial Input Programming Basics
(p. 206) ). Data may be
combinations or variations of all of these. The manufacturer of the instrument
must provide the rules by which data are to be decoded.
Alpha-numeric: Each digit represents its own alpha-numeric value. For
example, R = the letter R, and 2 = decimal 2. This is the easiest protocol to
translate since the literal translation is what is received from the transmitting
instrument. Normally, the CRBasic program receiving the transmission will
be written to parse (split) the string up and place the values in CR1000
variables.
Zobrazit stránku 207
1 2 ... 203 204 205 206 207 208 209 210 211 212 213 ... 587 588

Komentáře k této Příručce

Žádné komentáře