Did you know...
|
|
Serial Wombat Datalogger Pin Mode
The Serial Wombat can store any pin's public data into a queue
at regular intervals. This allows much more precise sampling of
data than would be possible through queries over the serial port.
For instance, one might wish to sample one of the
analog-to-digital conversion pins every 5ms and store the data
into a queue in the user ram area. Since the queues can be filled
by the pin mode and read by serial commands in real time it is
possible to achieve a stream of periodically sampled data to the
host, given a sufficently slow sampling frequency and
sufficiently high baud rate.
The pin assigned to datalogger mode can be a pin which is
being sampled, or can be a control pin which controls sampling or
outputs sample status. See the examples below for more detail.
The Datalogger mode has a number of options:
- Pin function: The pin which is assigned
to datalogger mode may be configured to be a signal
input, a control input, or a control output. Signal
inputs are sampled for raw A/D value. Control inputs can
be used to gate the sampling of other pins' public data
(for instance only sample some pin(s) while the
datalogger pin is high), or as a trigger (for instance,
begin sampling some pin(s) once the datalogger pin goes
low). The datalogger pin can also be a control output. It
can be configured to go high while sampling is occuring,
then go low once the queue has filled.
- Pins to be sampled: When a pin is
configured to datalogger mode the data from up to 4 pins
can be pushed into the queue at a time. The pin which is
configured to datalogger mode is not necessarily the pin
whose data will be stored in the queue. For instance, pin
20 might be configured as a datalogger which stores data
from pins 2,3,4 and 5.
- Frames between samples: The number of
frames (by default a frame is 1 ms) which elapse between
storing values to the queue. This value can range between
0 (store on every frame) and 255 (store on every 256th
frame).
- Sample Resolution: The datalogger can be
configured to store all 16bits of the sampled pins'
public data, only the most significant 8 bits, or only
the least significant 8 bits. This allows the user to
choose how much storage is appropriate for his or her
data.
For instance, in an application where precision of A/D
conversion was most important, all 16 bits of an A/D pin
might be stored. However, only 10 bits of this data is
really useful, since the hardware A/D converter
resolution is only 10 bits. A user might choose instead
to only store the 8 most significant bits in order to
effectively double the number of stored samples in
exchange for loosing 2 bits of resolution.
In a case where the user was sampling the public data of
a pin mode whose output was always less than 256 then
choosing only the least significant 8 bits would make
sense.
- Queue Address: The pin mode puts data
into a queue in User ram. The host is responsible for
initializing this queue and providing the address of the
queue to the datalogger pin mode.
- Queue Overflow action: The datalogger
can deal with a full queue in two ways: it can stop
logging data, or it can throw out the oldest piece of
data in order to make room for a new one.
Message format:
Message 200 is used to initialize the Pin mode. It tells the
pin mode which pins should be logged to the queue (up to 4 pins),
and how long to wait between samples.
| Data Sent to the Wombat: |
200 |
Pin # |
31 |
Pin to log |
Pin to log |
Pin to log |
Pin to log |
Delay between samples |
| Meaning: |
Configure Pin First message |
Pin Number to be set to Data
Logger Mode |
Data Logger Mode |
First of up to 4 pins to log
to queue. 255 if unused. |
Second of up to 4 pins to log
to queue. 255 if unused. |
Third of up to 4 pins to log
to queue. 255 if unused. |
Fourth of up to 4 pins to
log. 255 if unused |
Number of frames to wait
between logging data |
| This message is echoed back by
the Wombat. |
Message 201 is used to configure how the datalogger pin
behaves, and how to deal with a full queue.
| Data Sent to the Wombat: |
201 |
Pin # |
31 |
Data Logger Pin Function |
Active State: |
Inactive State |
Full queue action |
0x55 |
| Meaning: |
Configure Pin Second message |
Pin Number to be set to Data
Logger Mode |
Data Logger Mode |
0: Fixed. Used if the pin is
one of the pins being sampled. 1: Enable Gate input.
The datalogger will only log data when this pin reads a
digital value equal to the 'active' setting.
2: Trigger input. The datalogger will begin logging
when the active state is detected, and continue logging
after that point.
3: Status Output: The pin will display the 'Active'
state while logging, and 'Inactive' when not logging
(usually because of full buffer).
|
In Enable Gate and Trigger
pin mode the digital value which corresponds to logging
(0 or 1). In Status output mode, the pin state to
indicate currently logging (0: low, 1: high, 2: high
impedance).
Unused in Fixed mode.
|
Used in Status output mode
for the pin state when not logging. (0: low, 1: high, 2:
high impedance). |
0: Stop logging if queue
fills up. 1: Discard oldest data if queue fills up.
|
Unused. |
| This message is echoed back by
the Wombat. |
Message 202 is used to configure the queue address and set the
initial mode of the data logger.
| Data Sent to the Wombat: |
202 |
Pin # |
31 |
Bytes of Public
Data to Log |
Initial State |
Queue Address High Byte |
Queue Address Low Byte |
0x55 |
| Meaning: |
Configure Pin Third message |
Pin Number to be set to Data
Logger Mode |
Data Logger Mode |
0: all 16 bits
1: High 8 bits
2: Low 8 bits |
1: Waiting for trigger (used
with triggered pin input setting)
2: Logging: Start logging on receipt of this message
|
Address of queue
into which to place data. Queue should be initialized by
the host before issuing this command. |
Unused. |
| This message is echoed back
by the Wombat. |
Note: The size of the queue used to store the logged data
should be an even multiple of the number of bytes stored each
time data is logged. For instance, if all 16 bits of one pin's
data is being logged, then the queue size should be a multiple of
2. If the least significant 8 bits from three different pins is
being logged, then the queue size should be a multiple of 3. If
all 16 bits of 4 pins are being logged, then the queue size
should be a multiple of 8.
Example:
A pressure sensor is attached to pin number 2. That pin has
been configured to perform
a/d conversion and averaging of 16 frames:
200 2 15 4 0x55 0x55 0x55 0x55
; Pin 2 is configured for average mode (15)
; Averaging 16 samples ( 2 to the 4th power)
A queue is created at address 0x100 in user ram. The queue
size will be 200 bytes:
128 0x100 0 200 0 0x55 0x55 0x55
Configure a pin to datalogger mode. Since we'll be logging the
output of another pin and aren't actually inputing or outputing
physical signals with the datalogger itself, we'll use one of the
Wombat's power pins, number 11. Since the averaging mode on pin 2
will only produce a new reading every 16 frames, we'll configure
the data logger to log every 16 frames.
200 11 31 2 255 255 255 15
; Configure pin 11 to mode 31 (datalogger)
; Log pin 2, no other pins, skip 15 frames between logs
201 11 31 0 0 0 0 0x55
; Fixed mode ( 0 ), since we aren't using pin 15 for I/O
; The next two bytes don't matter, since they don't apply to fixed
; The final 0 means stop if the queue fills up we'll stop logging
;
202 11 31 0 2 0x0100 0x55; Log 16 bits per sample. Set queue address to 0x0100, and start logging.
This example will push one 16-bit value into the queue every
16 frames. Assuming the frame time is 1ms, this will generate
about 125 bytes of data per second. Using the Get Queue Data command up to
6 bytes of data can be retreived per 16 byte transaction.
Therefore, the host will need to average at least 21 Get Queue
Data requests per second. 21 transactions times 16 bytes per
transaction means 336 bytes per second must be transferred. With
1 start bit, 8 data bits, and 1 stop bit per byte, this means
3360 bits per second. Therefore a baud rate of 4800 bps should be
sufficent to keep up with the queue. 9600 baud or higher should
assure that the host can keep the queue drained while also doing
other things.
|
|