here's my latest code for my 16 bit adc project.
it appears to be sampling at about 4.4 microseconds, from my timing experiments, I'm hoping to get it in the 2-3 microseconds range,
the areas for improvement are:
A single 16 bit transfer instead of the 2, 8 byte transfers
Using a different type of digital write for the SELPIN.
Philip
(maybe tomarrow i'll post a picture or a video of it action)
it appears to be sampling at about 4.4 microseconds, from my timing experiments, I'm hoping to get it in the 2-3 microseconds range,
the areas for improvement are:
A single 16 bit transfer instead of the 2, 8 byte transfers
Using a different type of digital write for the SELPIN.
Philip
(maybe tomarrow i'll post a picture or a video of it action)
Code:
/* ADS8319 16-BIT, 500-KSPS, SERIAL INTERFACE experiment by Philip Crawford
This is free software, for educational use only / for the Chipkit uno32
*/
#include <DSPI.h> // the DSPI library has a little more flexiabilty
// than the standard SPI library
#include <CK_LCD5110_Graph.h>
#define SELPIN 9
#define MISOPIN 12
#define SCLKPIN 13
// This program requires a Nokia 5110 LCD module.
//
// It is assumed that the LCD module is connected to
// the following pins:
// SCK - Pin 41
// MOSI - Pin 40
// DC - Pin 39
// RST - Pin 38
// CS - Pin 37
//
LCD5110 myGLCD(41,40,39,38,37);
extern unsigned char SmallFont[];
int adcvalue;
byte byte1; byte byte2;
const float aRefVoltage = 4.096;
float volts = 0;
DSPI0 spi;
void setup() {
pinMode(SELPIN, OUTPUT); // ADC's conversion pin
pinMode(SCLKPIN, OUTPUT);// ADC's clock pin
pinMode(MISOPIN, INPUT); // ADC's data out
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
myGLCD.print("ADC read", CENTER, 0);
myGLCD.update();
spi.begin();
spi.setSpeed(20000000); // 20 mhz spi clock
Serial.begin(9600);
}
void loop(){ // calls the subroutine "read_adc"
read_adc();
}
void read_adc()
{
digitalWrite(SELPIN, HIGH); // starts conversion of adc
digitalWrite(SELPIN, LOW); // ends conversion, starts Acquisition
byte1 = spi.transfer(0x00); //transfer (read) 8 bits from the adc chip D15-8
byte2 = spi.transfer(0x00); //transfer (read) the second 8 bits. D7-0
adcvalue = (byte1 << 8 ) | (byte2 & 0xff); // combine the 2 bytes to make our 16 bit word
Serial.print("Adc value: ");
Serial.print(adcvalue,HEX); // display the HEX value also
volts = (adcvalue*aRefVoltage/65535); // formula for figureing voltage
// 65535 = the 16 bit "deciamal" value
Serial.print(" Adc volts: ");
Serial.println(volts,5); // display the "voltage" with 5 digits
myGLCD.print("ADC read", CENTER, 0);
myGLCD.printNumF(volts, 5, CENTER,10); // display the "voltage" with 5 digits
// lets center the value
// and display it on the 10th pixel
// from the top left
myGLCD.update(); // update the display
delay (100);
}


, but from what I seen so far is, I'll need to work on the SPI interface, might have write my own
, I'll need to squeeze 24 MHz out of it to make the results worth while.



Comment