PropWare
2.1.2
C++ objects and CMake build system for Parallax Propeller
|
Click here for docs on the
develop
branch.
#include <mcp3208.h>
Public Member Functions | |
void | Start (const int dataPin, const int clockPin, const int selectPin, const int mode=0xFF, const int dacAPin=-1, const int dacBPin=-1) |
void | Stop (void) |
int | In (const int Channel) |
int | Average (const int Channel, const int N) |
void | Out (const short aOutput, const short bOutput=-1) |
MCP3208 8 channel ADC Class.
When the MCP3208 is configured for 3.3v operation each bit represents 0.00080566406v.
The MCP3208 requires three connections to the Propeller: clock, chip select, and data (tie together Dout and Din).
This object optionally provides two DACs as well. To enable these you need to have one or two Propeller I/O pins available. Each DAC I/O pin needs to have a low pass RC filter. I reccommend R = 1k and C = 0.1uF. With this configuration you should avoid changing the DAC more than once a millisecond (the cut off frequency is 1591Hz).
This driver does continuous sampling in the background.
This object is based on MCP3208.spin v1.0 written by Chip Gracey. Thanks!
Copyright (c) 2013 Kenneth Bedolla (libpr) opel ler@k enne thbed olla .com
int libpropeller::MCP3208::Average | ( | const int | Channel, |
const int | N | ||
) |
int libpropeller::MCP3208::In | ( | const int | Channel | ) |
void libpropeller::MCP3208::Out | ( | const short | aOutput, |
const short | bOutput = -1 |
||
) |
void libpropeller::MCP3208::Start | ( | const int | dataPin, |
const int | clockPin, | ||
const int | selectPin, | ||
const int | mode = 0xFF , |
||
const int | dacAPin = -1 , |
||
const int | dacBPin = -1 |
||
) |
Start the ADC driver in a new cog.
Be sure to give the driver sufficient time to start up.
dataPin | The data in and data out pins on the MCP3208 |
clockPin | The clock pin on the MCP3208 |
selectPin | The select pin on the MCP3208 |
mode | Channel enables in bits [0..7], differential mode enable in bits [8..15]. Most applications should set this to 0xFF |
dacAPin | If desired, the pin number for a DAC (see discussion above) |
dacBPin | If desired, the pin number for a DAC (see discussion above) |
void libpropeller::MCP3208::Stop | ( | void | ) |