AnsweredAssumed Answered

adas 1000 to arduino code

Question asked by ill on Jan 26, 2017
Latest reply on Jan 30, 2017 by DragosB

Hi Analog


do you have simple arduino code to stream ECG capture ADAS1000?


I'm using Microcontroler Arduino Due. Arduino - ArduinoBoardDue 


This the SPI refference link and example for arduino code.

 had coding on it, modify from analog ADXL345 sensor code's, like this. but no data stream.
here the code. in ADXL345 acceleration data stream very well.

//Add the SPI library so we can communicate with the ADAS1000 sensor
#include <SPI.h>

//Assign the Chip Select signal to pin 10.
int CS = 10;

//This is a list of some of the registers available on the ADAS1000.
//To learn more about these and the rest of the registers on the ADAS1000, read the datasheet!
char ECGCTL = 0x01; //ECG control
char LOFFCTL = 0x02; //Lead-off control
char PACEAMPTH = 0x07; //Show PACEAMPTH or Pace amplitude threshold // reset value 0x242424
char FRAMES = 0x40; //Frame header // reset value 0x800000
char LADATA = 0x11; //LA or Lead I data
char LLDATA = 0x12; //LL or Lead II data
char RADATA = 0x13; //RA or Lead III data
char V1DATA = 0x14; //V1 or V1’ data
char V2DATA = 0x15; //V2 or V2’ data
char PACEDATA = 0x1A; //Read pace detection data/status

//id velues
unsigned char id = 0;
//This buffer will hold values read from the ADAS1000 registers.
unsigned char values[10];
//These variables will be used to hold the x,y and z axis accelerometer values.
int x, y, z;

void setup() {
//Initiate an SPI communication instance.
//Configure the SPI connection for the ADAS1000.
//Create a serial connection to display the data on the terminal.

//Set up the Chip Select pin to be an output from the Arduino.
pinMode(CS, OUTPUT);
//Before communication starts, the Chip Select pin needs to be set high. CS is vertival dash or active low
digitalWrite(CS, HIGH);

//Put the ADAS1000 into +/- 4G range by writing the value 0x01 to the LOFFCTL register.
//writeRegister(LOFFCTL, 0x02);
//Put the ADAS1000 into Measurement Mode by writing 0x08 to the ECGCTL register.
//writeRegister(ECGCTL, 0x01); //Measurement mode

//TEST to read register reset value ADAS1000 and print serial monitor
readRegister(PACEAMPTH, 1, &id);
Serial.print("PACEAMPTH = "); //reset value is 0x242424
Serial.println(id, BIN);

//TEST to read register reset value ADAS1000 and print serial monitor
readRegister(FRAMES, 1, &id);
Serial.print("FRAMES = "); // reset value 0x800000
Serial.println(id, BIN);


void loop() {

//Reading 6 bytes of data starting at register LADATA will retrieve the x,y and z acceleration values from the ADAS1000.
//The results of the read operation will get stored to the values[] buffer.
readRegister(LADATA, 6, values);

//The ADAS1000 gives 10-bit acceleration values, but they are stored as bytes (8-bits). To get the full value, two bytes must be combined for each axis.
//The X value is stored in values[0] and values[1].
x = ((int)values[1]);// << 8) | (int)values[0];// hapus --> );//
//The Y value is stored in values[2] and values[3].
y = ((int)values[3]);// << 8) | (int)values[2];
//The Z value is stored in values[4] and values[5].
z = ((int)values[5]);// << 8) | (int)values[4];

//Print the results to the terminal.
Serial.print(x, DEC);
Serial.print(y, DEC);
Serial.println(z, DEC);

//This function will write a value to a register on the ADAS1000.
// char registerAddress - The register to write a value to
// char value - The value to be written to the specified register.
void writeRegister(char registerAddress, char value) {
//Set Chip Select pin low to signal the beginning of an SPI packet.
digitalWrite(CS, LOW);
//Transfer the register address over SPI.
//Transfer the desired register value over SPI.
//Set the Chip Select pin high to signal the end of an SPI packet.
digitalWrite(CS, HIGH);

//This function will read a certain number of registers starting from a specified address and store their values in a buffer.
// char registerAddress - The register addresse to start the read sequence from.
// int numBytes - The number of registers that should be read.
// char * values - A pointer to a buffer where the results of the operation should be stored.
void readRegister(char registerAddress, int numBytes, unsigned char * values) {
//Since we're performing a read operation, the most significant bit of the register address should be set.
char address = 0x00 | registerAddress; // 0x08-->0x00
//If we're doing a multi-byte read, bit 6 needs to be set as well.
if (numBytes > 1)address = address | 0x40;

//Set the Chip select pin low to start an SPI packet.
digitalWrite(CS, LOW);
//Transfer the starting register address that needs to be read.
//Continue to read registers until we've read the number specified, storing the results to the input buffer.
for (int i = 0; i < numBytes; i++) {
values[i] = SPI.transfer(0x00);
//Set the Chips Select pin high to end the SPI packet.
digitalWrite(CS, HIGH);


Best Regard