REMOTE ACCES
PROGRAMMING CONCEPTS
Return to REMOTE ACCES Products
The Point
A Point is a logical channel number. For example, the RAD128 has eight analog inputs. However, using sub-multiplexer boards, each of the inputs might be expanded to 16 separate channels, yielding up to 128 channels total. To determine the Point number for any given channel, place the A/D channel number in the upper nibble of a byte, and the MUX channel number in the lower nibble, as follows:
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
0 | AD2 | AD1 | AD0 | MA3 | MA2 | MA1 | MA |
This can be done algorithmically by multiplying the A/D channel by 16 and adding the mux channel.
In C: pointnum = (adchan << 4) + muxchan; In Pascal: pointnum := (adchan shl 4) + muxchan;
The Point List Buffer
Because the Pod has up to 128 channels of Analog data, and each channel can be acquired at a different gain, and even at a different polarity, some setup is necessary to improve usability. The setup consists of telling the Pod what input range and polarity each channel is going to be acquired at, and which channels are going to be acquired in what order, using the Point List (PL) series of commands. The Point List is a list of the points to be acquired, along with all of the configuration information necessary to select polarity, range and mux gain. All of the commands to set PL entries take a point number (or the keyphrase "ALL"), and a 2-byte (4 hex characters) value describing the configuration for that point (or the keyphrase "DEFAULT"). The format of the 2-byte entry follows:
Polarity | Gain/Range Code | Analog Channel | Mux Channel | |||||||||||||
D15 | D14 | D13 | D12 | D11 | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | |
X | X | X | BIP/ | UNI | 5/10 | GN2 | GN1 | GN0 | 0 | AD2 | AD1 | AD0 | MA3 | MA2 | MA1 | MA0 |
- X:
- Don't care bits. State is ignored.
- BIP/UNI:
- See following table:
- 5/10:
- See following table:
- GN2-GN0:
- The GN2-GN0 bits of Port 1 (MUX Control). Used to control gain control bits on AIM-16 and other sub-multiplexers.
- General Notes:
- ALL numbers passed to and from the Pod are in hexadecimal.
BIP/UNI | 5/10 | Input Range (V) |
0 | 0 | 0 to 5 |
0 | 1 | 0 to 10 |
1 | 0 | +5 |
1 | 1 | +10 |
COMMAND FUNCTIONS
The following paragraphs give details of the command functions, describe what the commands cause, and give examples. Please note that all commands have an acknowledgement response. You must wait for a response from a command before sending another command.
Configure Point List
- PLnn=xxxx
- Sets point list entry for point number nn to xxxx.
- PLnn= DEFAULT
- Sets Point nn to default configuration
- PLALL=DEFAULT
- Sets all points to default configuration
NOTE: Default configuration is ±5v, GN2-GN0 all zero.
Read Point List
- PLnn?
- Reads the Point configuration for point number nn.
- PLALL?
- Reads the Point configuration for all points (0-127)
NOTE: Data is returned as xxxx xxxx xxxx ... xxxx xxxx[CR] with a total of 128 entries.
Write Point List to EEPROM
- BACKUP=PL
- Stores the point list configuration in the onboard EEPROM, for power-off safekeeping.
NOTE: The point list configuration is automatically restored every time the Pod is reset, or when PLALL=BACKUP command is issued.
Restore Point List
- PLALL=BACKUP
- Restores Point List configuration in EEPROM to the current point list.
NOTE: This command is executed automatically upon Pod reset.
Write Calibration Parameters
- BACKUP=CAL mmmm,bbbb
- Write scale and offset calibration values for Y=mX+b calibration in two's-complement hex as two four-digit numbers.
This function stores the values required to adjust the measurement readings to agree with the last calibration. The RAD128ST program will measure and write these calibration parameters. The SAMPLE1 program illustrates using the CAL? command with the results of this function.
Return Calibration Parameters
- CAL?
- Recalls the scale and offset calibration constants for Y=mX+b calibration stored using the BACKUP=CAL command.
This function recalls the stored calibration constants that may be used by your software to adjust the measurement readings to agree with the last calibration. The SAMPLE1 program includes an illustrates the use of this command.
NOTE: Cal_Value = Original_Value x Scale + Offset
Set Sample Rate
- S=xxxx
- Set Sample Rate of the A/D Converter
This function sets the sample rate of the A/D converter. Valid values range from 00A2 to FFFF. The value passed is the desired divisor of the rate clock (11.0592 MHz). The equation to use in calculating the divisor is:
Divisor = [(1/Rate) - 22µSec] * [Clock/12]
Examples:
Program the RAD128 for 1K samples per second.
SEND: S0385 RECEIVE: [CR]
NOTE: The sample rate configured is stored in EEPROM on the Pod, and will be used as the default (power-on) sample rate. The factory default sample rate (100Hz) can be restored by sending "S0000" to the Pod.
Read Sample Rate
- S?
- Returns the clock Divisor from EEPROM on the Pod.
Configure Bits as Input or Output
- Mxx
- Configures digital bits as inputs or outputs.
- Mx+
- Configures digital bit 'x' as output.
- Mx-
- Configures digital bit 'x' as input.
These commands program the digital bits, on a bit-by-bit basis, as input or output. A "zero" in any bit position of the xx control byte designates the corresponding bit to be configured as an input. Conversely, a "one" designates a bit to be configured as an output. (Note: Any bit configured as an output can still be read as an input if the current value output is a "one".
Examples:
Program even bits as outputs, and odd bits as inputs.
SEND: MAA RECEIVE: [CR]
Program bits 0-3 as input, and bits 4-7 as output.
SEND: MF RECEIVE: [CR]
Read Digital Inputs
- I
- Read 8 bits
- In
- Read bit number n
These commands read the digital input bits from the Pod. All byte responses are sent most-significant nibble first.
Examples:
Read ALL 8 bits.
SEND: I RECEIVE: FF[CR]
Read only bit 2.
SEND: I02 RECEIVE: 1[CR]
Write Digital Outputs
- O0xx
- Write to all 8 digital output bits. (Port 0)
- Ox±
- Set bit x hi or low
- O1xx
- Write to AIM-16 output port. (Port 1)
These commands write outputs to digital bits. Any attempt to write to a bit configured as an input will fail. Writing to a byte or word wherein some bits are input and some are output will cause the output latches to change to the new value, but the bits which are inputs will not output the value until/unless they are placed in output mode.
Single bit commands will return an error (4) if an attempt is made to write to a bit configured as an input.
Writing a "one" (+) to a bit asserts the pull-down for that bit. Writing a "zero" (-) de-asserts the pull-down. Therefore, if the factory default +5V pull-up is installed, writing a one will cause zero volts to be at the connector, and writing a zero will cause +5 volts to be asserted.
Examples:
Write a one to bit 7 (set output to zero volts, assert the pull-down).
SEND: O7+ RECEIVE: [CR]
Write a zero to bit 2 (set output to +5V or user pull-up).
SEND: O2- or SEND: O02- RECEIVE: [CR]
Write zeros to bits 0-7.
SEND: O00 RECEIVE: [CR]
Write zeros to every odd bit.
SEND: OAA RECEIVE: [CR]
Counter/Timer Commands
- CMxx[CR]:
- Writes the byte value of xx to the counter/timer control byte.
- CLn,xxxx[CR]:
- Loads the hex value of xxx to counter/timer n.
- CRn[CR]:
- Reads the hex value xxxx of the current count in counter nn (00, 01, or 02)
Read Firmware Revision Number
- V
- Read the firmware revision number
This command is used to read the version of firmware installed in the Pod. It returns "X.XX[CR]".
Example:
Read the RAD128 version number.SEND: V RECEIVE: 1.00[CR]
NOTE: The "H" command returns the version number along with other information. See "Hello Message".
Resend Last Response
- n
- Resend last response
This command will cause the Pod to return the same thing it just sent. This command works for all responses less than 255 characters in length. Normally this command is used if the host detected a parity or other line fault while receiving data, and needs the data to be sent a second time.
The "n" command may be repeated.
Example:
Assuming the last command was "I", ask Pod to resend last response.
SEND: n RECEIVE: FFFFFF[CR] ;or whatever the data was
Hello Message
- H*
- Hello message
Any string of characters starting with "H" will be interpreted as this command. ("H[CR]" alone is also acceptable.) The return from this command takes the form (without the quotes):
"=Pod aa, RAD128 Rev rr Firmware Ver:x.xx ACCES I/O Products, Inc. W/MUX"aa is the Pod address
rr is the hardware revision, such as "B1"
x.xxis the software revision, such as "1.00"
Multiplexer support as "W/MUX" or "NOMUX"
Example:
Read the greeting message.
SEND: Hello? RECEIVE: = Pod 00, RAD128 Rev B1 Firmware Ver:1.00 ACCES I/O Products, Inc. NOMUX[CR]
Configure Baud Rate
(When shipped by ACCES, the baud rate is set at 9600.)
- BAUD=nnn
- Program the Pod with a new baud rate
This command sets the Pod to communicate at a new baud rate. The parameter passed, nnn, is slightly unusual. Each n is the same digit from the following table:
CODE | BAUD RATE |
0 | 1200 |
1 | 2400 |
2 | 4800 |
3 | 9600 |
4 | 14400 |
5 | 19200 |
6 | 28800 |
Therefore, valid values for the command's "nnn" are 000, 111, 222, 333, 444, 555, or 666. The Pod returns a message indicating it will comply. The message is sent in the old baud rate, not the new one. Once the message is transmitted, the Pod changes to the new baud rate. The new baud rate is stored in EEPROM and will be used even after power-reset, until the next "BAUD=nnn" command is issued.
Example:
Set the Pod to 19200 baud.
SEND: BAUD=555 RECEIVE: =:Baud:05[CR]
Set the Pod to 9600 baud.
SEND: BAUD=333 RECEIVE: =:Baud:03[CR]
Note: There is a Code 7 which selects 57600 baud. This code can be used but only in non-isolated mode with short cables. Use of this code is not recommended due to possible difficulty with character drop-out and other line noise problems.
Configure Pod Address
- POD=xx
- Program the currently selected Pod to respond at address xx.
This command changes the Pod's address to xx. If the new address is 00, the Pod will be placed into non-addressed mode. If the new address is not 00, the Pod will not respond to further communications until a valid address command is issued. Hex numbers 00-FF are considered valid addresses. The RS-485 specification allows only 32 drops on the line, so some addresses may be unused.
The new Pod address is saved in EEPROM and will be used even after power-down until the next "Pod=xx" command is issued. Note that, if the new address is not 00 (i.e., the Pod is configured to be in addressed mode), it is necessary to issue an address command to the Pod at the new address before it will respond.
The Pod returns a message containing the Pod number as confirmation.
Example:
Set the Pod address to 01.
SEND: A=01 RECEIVE: =:Pod#01[CR]
Set the Pod address to F3.
SEND: A=F3 RECEIVE: =:Pod#F3[CR]
Take the Pod out of addressed mode.
SEND: A=00 RECEIVE: =:Pod#00[CR]
Address Select
- !xx
- Selects the Pod addressed 'xx'
NOTE: When using more than one Pod in a system, each Pod is configured with a unique address. This command must be issued prior to any other commands to that particular Pod. This command needs to be issued only once prior to executing any other commands. Once the address select command has been issued, that Pod will respond to all other commands until a new address select command is issued.
Enter a New Program
- PROGRAM=
- This command initiates transfer of a new program to the RAD128.
This command should be used carefully. If you accidentally issue a "PROGRAM=" command, ESC (ASCII 27) will restart the Pod as if power had been reset. This feature is designed to allow ACCES to provide field-upgrades to the RAD128 firmware, and, for advanced users, the opportunity to customize the firmware in the Pod. Documentation relating to use of this command is provided with the upgrade diskette, or is available separately for a small fee.
- | (Vertical Bar)=
- Same as PROGRAM= except it is used only after a reset has occurred. Allows access to Pod to download new firmware.
Special Acquisition Commands
- ACnn1-nn2,xxxx:
- Acquires Point List entries nn1 through nn2, with a total of xxxx conversions performed.
xxxx must be equal to or less than 2710hex (which is 10000 decimal--all numbers must be presented to the Pod in hex). 10000 data samples is the maximum internal storage capacity of the standard Pod. (Optional firmware can increase this capacity. Contact the factory for further information.) Please note that this function does not return any data. Data is stored in the internal SRAM storage for later retrieval using the R command.
- R:
- This command reads the last buffer of data acquired using the AC command.
The data is returned in CCXXXX CCXXXX ... CCXXXX CCXXXX[CR] format, where CC is the point number that was acquired, and XXXX is the analog conversion data. The total number of return values is identical to the XXXX parameter passed to the most recently issued AC command.
- Axxxx:
- Acquires a single channel and returns the data immediately via the serial port, bypassing the point list.
This command takes as its sole argument the same 2-byte parameter passed to the PL series of commands. The channel specified in the parameter is acquired using the range, polarity, and mux gain specified. The data is returned immediately, unlike the AC command.
- Ann-nn,xxxx
- The A command works very similarly to the AC command. All parameters are the same. However, the A command runs in the foreground, occupying all of the attention of the Pod's microcontroller. This yields higher throughput, but sacrifices flexibility. The Pod acquires data at its fastest possible rate.