|
|
|
|
|
|
|
||
|
||
|
|
||
May 1999 |
Revision 1.02 |
|
Persistor Instruments Inc. |
© 1998 All rights reserved. |
|
This document describes the Max146 A-D driver built upon the PicoDOS QPB driver. This driver should form the basis for a variety of Maxim A-D devices.
The Max146 bipolar mode does not allow you to connect negative voltage signals to the analog inputs. Some Maxim A-D converters that feature bipolar inputs provide a separate negative supply voltage to accommodate negative going signals. The Max146 does not. Connecting signals below -0.3 volts to the analog inputs will most likely result in device failure.
The Max146Examples.mcp CodeWarrior project is a multiple target project. This is described in Metrowerk's IDE guide, but basically, you select the current build target from the large popup menu near the upper left of the project window. To keep from cluttering up the directory containing the project and source files, we generate the object and map files into the "Max146Examples Data" directory, and this is where you must direct MotoCross when loading files to the CF1.
This is Maxim's acrobat document that fully describes the Max146 device. You can get to this from the link in the Max146Examples.mcp project in CodeWarrior or navigate to it in the "MotoCross Support\CF1\Docs\pdf" directory.
This document provides the schematic for the PRC-PLG RecipeCard and shows one way of connecting a Max146 to the CF1. It also contain the connection diagram for the 14 pin header that brings out the Max146 connection points.
This header file contains the function declarations used by your programs, and command constants used by the Max146 driver. You will need to include this header in every source module that references the Max146 functions.
This document describes and annotates several example programs that run on the PicoDAQ RecipeCard and work the Max146 A-D converter at extremes of speed and low power.
The PicoDAQ example source demonstrates most of the capabilities of the Max146 driver code, but it's required complex functionality makes it less than ideal for learning how to use these functions. It does however demonstrate how to stream A-D data to CompactFlash files a fairly high data rates.
The Max146Init() function does pretty much what its name implies: it sets up a QPB slot to work with the Max146. The PRC-PLG RecipeCard connects a single Max146 device to the QSPI's peripheral chip select 3 (\PCS3) which in turn maps to QPB slot 7 which is defined in <cf1pico.h> as NMPCS3. This same driver should work with any number of Max146 devices, directly connected or multiplexed, but you will need to call Max146Init() once for each active device.
|
Prototype: |
bool Max146Init(ushort qslot); |
|
Definition: |
#include <Max186.h> |
|
Inputs: |
qslot is the QPB slot number associated with this Max146 device |
|
Returns: |
true if initialization successful |
|
Notes: |
|
|
Timing: |
not specified |
The Max146Lock() functions tells QPB to limit QSPI access to just this slot/device to take advantage optimizations that result from not having to completely reload all of the QSPI module registers for each transaction. These optimizations allow for aggregate speeds of 80kHz (8 channels at 10kHz rate) and lowest power at slow rates by minimizing the time the CPU must be left running. Both Max146FastAD.c and Max146LowPowerAD.c examples demonstrate the use of this function.
|
Prototype: |
bool Max146Lock(ushort qslot); |
|
Definition: |
#include <Max186.h> |
|
Inputs: |
qslot is the QPB slot number associated with this Max146 device |
|
Returns: |
true if lock successful |
|
Notes: |
See the Max146FastAD example for typical usage. |
|
Timing: |
Timing-TBD |
The Max146Unlock() functions tells QPB to release the specified slot/device and allow other peripherals access to QPB. This is the opposite function to Max146Lock() described above.
|
Prototype: |
bool Max146Unlock(ushort qslot); |
|
Definition: |
#include <Max186.h> |
|
Inputs: |
qslot is the QPB slot number associated with this Max146 device |
|
Returns: |
true if unlock successful |
|
Notes: |
|
|
Timing: |
Timing-TBD |
The Max146PowerDown() function simply puts the A-D converter into shutdown mode to reduce power consumption. Specify true for fullpd to put the Max146 into its lowest drain mode (just over 1uA), but be prepared to wait from 0.2 to 2.0 milliseconds (depending on time in shutdown) before the converter's reference will give reliably accurate results. Specify false for fullpd to put the Max146 into fast power down mode of about 30uA.
|
Prototype: |
void Max146PowerDown(ushort qslot, bool fullpd); |
|
Definition: |
#include <Max186.h> |
|
Inputs: |
|
|
Notes: |
See the Max146LPStop example for typical usage. |
|
Timing: |
Timing-TBD |
The Max146Sample() function takes a single reading from the A-D converter. You specify which channel (0 to 7) to convert, unipolar or bipolar conversion, single-ended or differential sampling, and optionally dropping into fast power down at the end of the conversion. Unipolar conversions accepts analog inputs in the range of 0 to 2.5 volts with COM at zero volts. Bipolar conversions accepts analog inputs in the range of COM -1.25 to + COM + 1.25 volts where COM is the analog input ground reference and must be greater than or equal to 1.25 volts in bipolar mode.
|
Prototype: |
short Max146Sample(ushort qslot, ushort chan, bool uni, bool sgl, bool pd); |
|
Definition: |
#include <Max186.h> |
|
Inputs: |
|
|
Returns: |
the analog value as describe below |
|
Notes: |
See the Max146SimpleAD example for typical usage. |
|
Timing: |
130us 16MHz/0wts 175us 8MHz/-1wts |
In unipolar mode, the 12 A-D bit readings appear as though they were 16 bit signed integers, always in the range of 0 to 32767. This happens to be the natural fielding of the A-D data in the SPI data stream and is also quite useful as is. Each step in the full 2.5 volt range represents 1/32768 of full scale or 76.3 millivolts. Use the following formula to convert a unipolar reading to floating point voltage:
volts = ((float) unisample * 2.5) / 32768.0);
The actual resolution of the Max146 is 12 bits and if you will be doing any data packing, use the following formula to convert the 16 bit signed reading back to a 12 bit unsigned value in the range of 0 to 4095 with no loss of resolution.
bits12 = unisample >> 3;
In bipolar mode, the 12 A-D bit readings naturally field into signed numbers, but not in a particularly convenient fashion. To work with the actual signed values requires some bit shifting as follows:
int16 = (ushort) bisample << 1;
Use the following formula to convert the raw reading to floating point voltage:
volts = ((float) ((ushort) bisample << 1) * 1.25) / 32768.0);
The Max146Repeat() function takes a single reading from the A-D converter using parameters and setup from the last Max146Sample(). The Max146 device/slot must be locked to this slot (Max146Lock()) for QPB to accept this command. This is primarily useful for repeated sampling of the same channel because it requires less setup time.
|
Prototype: |
short Max146Repeat(ushort qslot); |
|
Definition: |
#include <Max186.h> |
|
Inputs: |
qslot is the QPB slot number associated with this Max146 device |
|
Returns: |
the analog value as described in Max146Sample() |
|
Notes: |
See the Max146SimpleAD example for typical usage. |
|
Timing: |
65us 16MHz/0wts 90us 8MHz/-1wts |
The Max146SampleBlock() function takes a range of readings from the A-D converter on the channels you specify. You specify which channel (0 to 7) to convert, unipolar or bipolar conversion, single-ended or differential sampling, and optionally dropping into fast power down at the end of the conversion. Unipolar conversions accepts analog inputs in the range of 0 to 2.5 volts with COM at zero volts. Bipolar conversions accepts analog inputs in the range of COM -1.25 to + COM + 1.25 volts where COM is the analog input ground reference and must be greater than or equal to 1.25 volts in bipolar mode.
|
Prototype: |
short *Max146SampleBlock(ushort qslot, ushort first, ushort count, vfptr asyncf, bool uni, bool sgl, bool pd); |
|
Definition: |
#include <Max186.h> |
|
Inputs: |
|
|
Returns: |
a pointer to an array of analog values as described for Max146Sample() |
|
Notes: |
See the Max146FastAD example for typical usage. |
|
Timing: |
275us 8Ch/16MHz/0wts 400us 8Ch/8MHz/-1wts (synchronous mode) |
The asyncf parameter controls how this function behaves after starting a block of conversions. If asyncf is zero, the function waits for the conversions to complete, then harvests the values into an array and returns a pointer to their start. If asyncf is non-zero, it's assumed to be a pointer to an interrupt handler that will deal with the aquired data on completion, and the function starts the block of conversions, then inserts pointer asyncf into the QSPI vector table. Your asyncf handler can be written in either assembler or C (using IEV_C_FUNCT), but it must take care of clearing the QSPI interrupt (using QPBClearInterrupt()) and performing and RTE to exit (which is handled automatically by IEV_C_FUNCT). If Max146SampleBlock is being called on a periodic basis, you must make sure to move the data from the QSPI buffer before it gets overwritten by the next acquisition cycle.
![]()
|
|
|
|
|
|
Tel: 508-759-6434 |
|
Fax: 508-759-6436 |
|
|
||