Group Abstract Group Abstract

Message Boards Message Boards

Use SPI protocol with Arduino & ADC?

Posted 10 years ago

Hi, I'm interested in how I use SPI protocol. In Mathematics documentation has information that might somehow use the SPI library in Arduino. I have an Arduino Uno, and I want to connect ADC such as MAX 6675, with SPI protocol. MAX 6675 is the ADC for temperature measurement using SPI protocol for sharing information, and there are several skeches to gather information from it.

I can not imagine how.

I am interested in whether someone has sample code to work with SPI protocol.

POSTED BY: Bohdan Romanchuk
5 Replies
POSTED BY: Ian Johnson
POSTED BY: Ian Johnson
Posted 6 years ago

Does this documentation will be working for [spi standard][1] with PIC32 mcu?

POSTED BY: Jane Mole

Hi Ian.

I have purchased for my experiments board EVAL-AD7177-2. It has a AD7177-2 and voltage reference ADR445 and all that is needed for the work.

I'm a beginner in digital electronics and not sure what it was doing well. I read the datasheet for AD7177-2 and to Arduino and it looks as if I combine everything as shown in the picture.

Datasheet on the Arduino, says that you need to use a PIN 10-13 they are for SPI. I use the same pin?

What do I do next after skech will fill in Arduino?

#include <SPI.h>
#define ADCMODE 0x01
#define CONTINUOUS_READ 0x8000
#define DATA 0x04
#define READ (0 << 6)
#define WRITE (1 << 6)
void setup(){
    SPI.begin();
    //setup the device for continuous reading
    // take the SS pin low to select the chip:
    digitalWrite(10, LOW);
    //send a write command to set the ADC into continuous read mode
    //need to write this mode to the ADCMODE register
    SPI.transfer(WRITE | ADCMODE);
    SPI.transfer(CONTINUOUS_READ);
    // take the SS pin high to de-select the chip:
    digitalWrite(10, HIGH);
}
void loop(){
    //select the device for reading
    digitalWrite(10, LOW);
    //transfer the 4 bytes
    uint8_t buffer[4] = {0};
    //read from the DATA register
    SPI.transfer(READ | DATA);
    //get the data into the buffer
    SPI.transfer(buffer,4);
    //now need to combine the bytes together - NOTE this is for MSB
    unsigned long int value = buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];
    digitalWrite(10, HIGH);
    //need to determine what to set RATE to to get sufficient readings - see page 18 of datasheet
    delay(5);
}
Attachments:
POSTED BY: Bohdan Romanchuk

Hi Ian.

I am extremely grateful to you for a detailed explanation of working with ADC, MAX 6675.

I used your code to obtain information on MAX 6675, everything works as it should.

I also have another ADC with whom I would like to receive data. This AD7177-2. Unfortunately I could not find the library for it probably need to get "raw data" through the SPI protocol.

I would appreciate to you for the example code to work with the device without a library for it.

result

POSTED BY: Bohdan Romanchuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard