Go Down

Topic: [SOLVED]Writing Commands to MAX11632 ADCs without SPI (Read 702 times) previous topic - next topic


May 29, 2013, 09:53 pm Last Edit: May 30, 2013, 02:48 pm by awesomelyjen Reason: 1
Hey guys,

So I'm trying to interface with a MAX11632 ADC using an Arduino UNO board without using any SPI through the MISO, MOSI, CS, and SCK pins. The data sheet for this specific ADC can be found here: http://pdf1.alldatasheet.com/datasheet-pdf/view/434696/MAXIM/MAX11632.html.

This is the code I've written so far:
Code: [Select]
#include <SPI.h>

//Pin definitions
const int CS0 = 4;
const int CS1 = 5;
const int CS2 = 6;
const int DECODER_EN = 7;
const int MOSIPIN = 11;
const int MISOPIN = 12;
const int SCKPIN = 13;

//packet structure bytes
byte START_BYTE = '*';
byte END_BYTE = '#';
byte DELIMITER = ',';

//enumeration of channels for loops
//enum channels { CH0, CH1, CH2, CH3, CH4, CH5, CH6,
 //CH7, CH8, CH9, CH10, CH11, CH12, CH13, CH14, CH15 };

//array of conversion registries
byte channels[] = {B10000100, B10001100, B10010100,
B10011100, B10100100, B10101100, B10110100, B10111100, B11000100,
B11001100, B11010100, B11011100, B11100100, B11101100, B11110100,

//Other two setup registries
byte setupReg = B01111000;
byte averageReg = B00111100;
byte reg1 = B10000100;
byte reg2 = B10001100;
byte convReg = reg1;

void setup()
 //Set up ADC we wish to comm with
 //But don't start comm
 //This circuit has a chip select decoder to determine which of the 5 adcs to look at
 //Set clock low to prepare for data write
void loop()
 byte result;
//  Serial.println(START_BYTE);
//  for(int i = 0; i < 2; i++){
//    byte convReg;
//    if (i == 0){
//      convReg = reg1;
//    }
//    else{
//      convReg = reg2;
//    }
   //First we give the ADC register settings
   //takes input on rising clock edge
   //We then let the ADC run conversion
   //sends data to DOUT on falling clock edge
   result = analogRead(MISOPIN);
   //start comm with ADC again
   //read result from dataout
   //once we have data cut off comm
   //print out result

I'm pretty sure the ADC is not working the way it should, as I'm getting pretty much the exact same numbers no matter whether I'm reading from a channel connected to a Hall-effect sensor or a channel connected to a thermistor.

Any sort of nudge in the right direction would be much appreciated.

Thanks in advance!


Code: [Select]

const int MISOPIN = 12;
    result = analogRead(MISOPIN);

12 is not a valid analog input pin.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp



I think I ended up resolving the problem, which was more of me not understanding how and when to use SPI.

I did need to use an SPI interface for this code and eventually got it working.

Go Up