Propeller Activity Board A/D Signal Library  v0.85
Take AC signal measurements with A/D 0, 1, 2, and/or 3.
Data Structures | Typedefs | Functions
adcACpropab.h File Reference

Measure ADC124S021 for signal recording and measurements. For the voltmeter version, check out the DC version of this library: adcACpropab. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  AdcMailbox
 structure for exchanging information with cogc program running in other cog. More...
struct  AdcBox
 structure for exchanging information with cogc program running in other cog. More...

Typedefs

typedef struct AdcMailbox AdcMailbox_st
 structure for exchanging information with cogc program running in other cog.
typedef struct AdcBox AdcBox_st
 structure for exchanging information with cogc program running in other cog.

Functions

int adc_start (int doPin, int diPin, int clkPin, int csPin, int pattern, int *arrayAddr)
 Launch A/D converter process into other cog.
void adc_stop (void)
 Stop A/D conversion process and free up a cog.

Detailed Description

Measure ADC124S021 for signal recording and measurements. For the voltmeter version, check out the DC version of this library: adcACpropab.

Author
Andy Lindsay
Version
0.85
Core Usage
A call to adc_start will launch 1 additional core that repeatedly updates ADC measurements.
Help Improve this Library
Please submit bug reports, suggestions, and improvements to this code to edito.nosp@m.r@pa.nosp@m.ralla.nosp@m.x.co.nosp@m.m.

Function Documentation

int adc_start ( int  doPin,
int  diPin,
int  clkPin,
int  csPin,
int  pattern,
int *  arrayAddr 
)

Launch A/D converter process into other cog.

After you call this function, the adc process will go as fast as it can and store results in an array. You will have to pass it pin, pattern, and array address parameters. The pattern is a four-digit binary value that allows you to tell the process which channels to monitor and update. The array address is the array where the ADC process will store the perpetually updated, latest set of measurement results.

[b] Propeller Activity Board Example[/b]

Propeller Activity Board Example:

#include "adcPropABac.h" // Include adcPropABdc
int adcVal[4]; // Required by adcPropABac
int main() // Main function
{
adc_start(19, 18, 20, 21, // CS=21, SCL=20, DO=19, DI=18
0b0101, // Ch3 off, 2 on, 1 off, 0 on
adcVal); // Array for measurements
...
Parameters
csPin,PropellerI/O pin connected to the A/D converter's chip select pin.

The Propeller chip uses that pin to enable communication with the A/D converter chip.

This connection is labeled /CS-P21 on the Propeller Activity Board. In that case Propeller I/O pin P21 is connected to the A/D converter's chip select pin, so you would use 21 for this parameter.
sclPin,PropellerI/O pin connected to the A/D converter's serial clock pin.

The Propeller chip sends a series of pulses to the A/D converter's SCL pin to drive the conversion and signal to send/recieve binary conversion values.

This connection is labeled SCL-P20 on the Propeller Activity Board. In that case Propeller I/O pin P20 is connected to the A/D converter's serial clock pin, so you would use 20 for this parameter.
doPin,PropellerI/O pin connected to the A/D converter's data out pin.

The A/D converter sends binary values to the controller with this pin.

This connection is labeled DO-P19 on the Propeller Activity Board. In that case Propeller I/O pin P19 is connected to the A/D converter's data out pin, so you would use 19 for this parameter.
diPin,PropellerI/O pin connected to the A/D converter's data in pin.

The Propeller chip sends a channel selection to the A/D converter, and it receives it with this pin.

This connection is labeled DI-P18 on the Propeller Activity Board. In that case Propeller I/O pin P18 is connected to the A/D converter's chip data in, so you would use 18 for this parameter.
pattern,Fourbit binary number that tells which channels to use update in the array. For example, if you only want to monitor channels 2 and 0, use 0b0101. If you instead want to monitor channels 3, and 2, use 0b1100.
array,Addressof the four int array that will receive the updates. Channel-3 measurement goes into array[3], channel-2 into array[2], and so on. Regardless of how many channels you intend to monitor, make sure to declare an in array with four elements. At the start, the process will store -1 in any slots that the pattern parameter says not to monitor. After that, it skips those slots and only updates the array elements that pattern says to monitor.