Skip to content

Commit

Permalink
Arduino library release
Browse files Browse the repository at this point in the history
  • Loading branch information
protocentralashwin committed Oct 31, 2020
1 parent 1474adf commit 8450e37
Show file tree
Hide file tree
Showing 14 changed files with 1,288 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
51 changes: 51 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
License Information
===================

Hardware
---------

**All hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).**

You are free to:

Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:

Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices:

You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.


Software
--------

**All software is released under the MIT License(http://opensource.org/licenses/MIT).**

The MIT License (MIT)

Copyright (c) 2015 ProtoCentral

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# protocentral-ads1292r-arduino
Arduino Library for the ADS1292R ECG/Respiration shield and breakout boards from ProtoCentral
ProtoCentral ADS1292R ECG/respiration Arduino Library
================================

[Dont have it yet? But one here: ADS1292R ECG/Respiration Shield for Arduino- v2 (PC-4128)](https://www.protocentral.com/arduino-shields/818-ads1292r-ecgrespiration-shield-v2.html)

[![bob](docs/img/ads1292r_breakout.jpg)
Dont have it yet? But one here: ADS1292R ECG/Respiration Breakout for Arduino- v3 (PC-4116)](https://www.protocentral.com/analog-adc-boards/783-ads1292r-ecgrespiration-breakout-board.html?search_query=ecg&results=4)


This is the Arduino library for the ProtoCentral ADS1292R-based ECG/Respiration monitoring shield and breakout boards.

## For the main documentation site, GUI and more resources, please check out our main [GitHub Repo](https://github.com/Protocentral/ADS1292rShield_Breakout)


License Information
===================

This product is open source! Both, our hardware and software are open source and licensed under the following licenses:

Hardware
---------

**All hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).**
![CC-BY-SA-4.0](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)

You are free to:

* Share — copy and redistribute the material in any medium or format
* Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

* Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
* ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

Software
--------

**All software is released under the MIT License(http://opensource.org/licenses/MIT).**

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Please check [*LICENSE.md*](LICENSE.md) for detailed license descriptions.
Binary file added docs/.DS_Store
Binary file not shown.
Binary file added docs/img/.DS_Store
Binary file not shown.
Binary file added docs/img/ads1292r_breakout.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
//////////////////////////////////////////////////////////////////////////////////////////
//
// Arduino Library for ADS1292R Shield/Breakout
//
// Copyright (c) 2017 ProtoCentral
// Heartrate and respiration computation based on original code from Texas Instruments
//
// This software is licensed under the MIT License(http://opensource.org/licenses/MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Requires g4p_control graphing library for processing. Built on V4.1
// Downloaded from Processing IDE Sketch->Import Library->Add Library->G4P Install
// If you have bought the breakout the connection with the Arduino board is as follows:
//
// |ads1292r pin label| Arduino Connection |Pin Function |
// |----------------- |:--------------------:|-----------------:|
// | VDD | +5V | Supply voltage |
// | PWDN/RESET | D4 | Reset |
// | START | D5 | Start Input |
// | DRDY | D6 | Data Ready Outpt|
// | CS | D7 | Chip Select |
// | MOSI | D11 | Slave In |
// | MISO | D12 | Slave Out |
// | SCK | D13 | Serial Clock |
// | GND | Gnd | Gnd |
//
/////////////////////////////////////////////////////////////////////////////////////////


#include "protocentralAds1292r.h"
#include "ecgRespirationAlgo.h"
#include <SPI.h>

volatile uint8_t global_HeartRate = 0;
volatile uint8_t global_RespirationRate=0;

//Pin declartion the other you need are controlled by the SPI library
const int ADS1292_DRDY_PIN = 6;
const int ADS1292_CS_PIN = 7;
const int ADS1292_START_PIN = 5;
const int ADS1292_PWDN_PIN = 4;

uint8_t DataPacketHeader[30];
uint8_t data_len = 20;

int16_t ecg_wave_buff, ecg_filterout;
int16_t res_wave_buff,resp_filterout;

ads1292r ADS1292R; // define class ads1292r
ecg_respiration_algorithm ECG_RESPIRATION_ALGORITHM; // define class ecg_algorithm

void setup()
{
delay(2000);

SPI.begin();
SPI.setBitOrder(MSBFIRST);
//CPOL = 0, CPHA = 1
SPI.setDataMode(SPI_MODE1);
// Selecting 1Mhz clock for SPI
SPI.setClockDivider(SPI_CLOCK_DIV16);

pinMode(ADS1292_DRDY_PIN, INPUT);
pinMode(ADS1292_CS_PIN, OUTPUT);
pinMode(ADS1292_START_PIN, OUTPUT);
pinMode(ADS1292_PWDN_PIN, OUTPUT);

Serial.begin(115200);
ADS1292R.ads1292_Init(ADS1292_CS_PIN,ADS1292_PWDN_PIN,ADS1292_START_PIN);
Serial.println("Initiliziation is done");
}

void loop()
{
ads1292_output_values ecg_respiration_values;
boolean ret = ADS1292R.ads1292_ecg_and_respiration_samples(ADS1292_DRDY_PIN,ADS1292_CS_PIN,&ecg_respiration_values);

if (ret == true)
{
ecg_wave_buff = (int16_t)(ecg_respiration_values.s_Daq_Vals[1] >> 8) ; // ignore the lower 8 bits out of 24bits
res_wave_buff = (int16_t)(ecg_respiration_values.sresultTempResp>>8) ;

if(ecg_respiration_values.leadoff_detected == false)
{
ECG_RESPIRATION_ALGORITHM.ECG_ProcessCurrSample(&ecg_wave_buff, &ecg_filterout); // filter out the line noise @40Hz cutoff 161 order
ECG_RESPIRATION_ALGORITHM.QRS_Algorithm_Interface(ecg_filterout,&global_HeartRate); // calculate
//resp_filterout = ECG_RESPIRATION_ALGORITHM.Resp_ProcessCurrSample(res_wave_buff);
//ECG_RESPIRATION_ALGORITHM.RESP_Algorithm_Interface(resp_filterout,&global_RespirationRate);

}else{
ecg_filterout = 0;
resp_filterout = 0;
}

DataPacketHeader[0] = CES_CMDIF_PKT_START_1 ; // Packet header1 :0x0A
DataPacketHeader[1] = CES_CMDIF_PKT_START_2; // Packet header2 :0xFA
DataPacketHeader[2] = (uint8_t) (data_len); // data length
DataPacketHeader[3] = (uint8_t) (data_len >> 8);
DataPacketHeader[4] = CES_CMDIF_TYPE_DATA; // packet type: 0x02 -data 0x01 -commmand
DataPacketHeader[5] = ecg_filterout;
DataPacketHeader[6] = ecg_filterout >> 8;
DataPacketHeader[7] = res_wave_buff;
DataPacketHeader[8] = res_wave_buff >> 8;

DataPacketHeader[19] = global_RespirationRate;
DataPacketHeader[21] = global_HeartRate;
DataPacketHeader[25]= CES_CMDIF_PKT_STOP_1; // Packet footer1:0x00
DataPacketHeader[26]= CES_CMDIF_PKT_STOP_2 ; // Packet footer2:0x0B

for (int i = 0; i < 27; i++)
{
Serial.write(DataPacketHeader[i]); // transmit the data over USB
}
}
}
108 changes: 108 additions & 0 deletions examples/2-Calculated-values-only/2-Calculated-values-only.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//////////////////////////////////////////////////////////////////////////////////////////
//
// Arduino Library for ADS1292R Shield/Breakout
//
// Copyright (c) 2017 ProtoCentral
// Heartrate and respiration computation based on original code from Texas Instruments
//
// This software is licensed under the MIT License(http://opensource.org/licenses/MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Requires g4p_control graphing library for processing. Built on V4.1
// Downloaded from Processing IDE Sketch->Import Library->Add Library->G4P Install
// If you have bought the breakout the connection with the Arduino board is as follows:
//
// |ads1292r pin label| Arduino Connection |Pin Function |
// |----------------- |:--------------------:|-----------------:|
// | VDD | +5V | Supply voltage |
// | PWDN/RESET | D4 | Reset |
// | START | D5 | Start Input |
// | DRDY | D6 | Data Ready Outpt|
// | CS | D7 | Chip Select |
// | MOSI | D11 | Slave In |
// | MISO | D12 | Slave Out |
// | SCK | D13 | Serial Clock |
// | GND | Gnd | Gnd |
//
/////////////////////////////////////////////////////////////////////////////////////////

#include "ads1292r.h"
#include "ecg_respiration_samples.h"
#include <SPI.h>

volatile uint8_t global_HeartRate;
volatile uint8_t global_RespirationRate=0;

//Pin declartion the other you need are controlled by the SPI library
const int ADS1292_DRDY_PIN = 26;//26 Kalam //26 Healthy pi
const int ADS1292_CS_PIN = 13;//17 Kalam//13 Healthy pi
const int ADS1292_START_PIN = 14;//16 Kalam//14 Healthy pi
const int ADS1292_PWDN_PIN = 27;//2 Kalam//27 Healthy pi

int16_t ecg_wave_buff, ecg_filterout;
int16_t res_wave_buff,resp_filterout;

long time_elapsed=0;

ads1292r ADS1292R; // define class ads1292r
ecg_respiration_algorithm ECG_RESPIRATION_ALGORITHM; // define class ecg_algorithm

void setup()
{
delay(2000); // initalize the data ready and chip select pins:
pinMode(ADS1292_DRDY_PIN, INPUT); //6
pinMode(ADS1292_CS_PIN, OUTPUT); //7
pinMode(ADS1292_START_PIN, OUTPUT); //5
pinMode(ADS1292_PWDN_PIN, OUTPUT); //4
Serial.begin(115200); // Baud rate for serial communica
ADS1292R.ads1292_Init(ADS1292_CS_PIN,ADS1292_PWDN_PIN,ADS1292_START_PIN); //initalize ADS1292 slave
Serial.println("Initiliziation is done");
}

void loop()
{
ads1292_output_values ecg_respiration_values;
boolean ret = ADS1292R.ads1292_ecg_and_respiration_samples(ADS1292_DRDY_PIN,ADS1292_CS_PIN,&ecg_respiration_values);

if (ret == true)
{
ecg_wave_buff = (int16_t)(ecg_respiration_values.s_Daq_Vals[1] >> 8) ; // ignore the lower 8 bits out of 24bits
Serial.println(ecg_wave_buff);
res_wave_buff = (int16_t)(ecg_respiration_values.sresultTempResp>>8) ;
Serial.println(res_wave_buff);

if(ecg_respiration_values.leadoff_detected == false)
{
ECG_RESPIRATION_ALGORITHM.ECG_ProcessCurrSample(&ecg_wave_buff, &ecg_filterout); // filter out the line noise @40Hz cutoff 161 order
ECG_RESPIRATION_ALGORITHM.QRS_Algorithm_Interface(ecg_filterout,&global_HeartRate);// calculate
resp_filterout = ECG_RESPIRATION_ALGORITHM.Resp_ProcessCurrSample(res_wave_buff);
ECG_RESPIRATION_ALGORITHM.RESP_Algorithm_Interface(resp_filterout,&global_RespirationRate);

}else{

ecg_filterout = 0;
resp_filterout = 0;
}

if(millis() > time_elapsed) // update every one second
{
if(ecg_respiration_values.leadoff_detected == true) // lead in not connected
{
Serial.println("ECG lead error!!! ensure the leads are properly connected");
}else{

Serial.print("Heart rate: ");
Serial.print(global_HeartRate);
Serial.println("BPM");
Serial.print("Respiration Rate :");
Serial.println(global_RespirationRate);
}
time_elapsed += 1000;
}
}
}
9 changes: 9 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=ProtoCentral ADS1292R ECG & Respiration shield/breakout board Arduino Library
version=1.0.2
author=ProtoCentral Electronics <[email protected]>
maintainer=ProtoCentral Electronics <[email protected]>
sentence=Library for the ProtoCentral ADS1292R Shield/Breakout board
paragraph= Measure ECG and respiration using the ADS1292R-based shield/breakout boards from ProtoCentral
category=Sensors
url=https://github.com/Protocentral/protocentral-ads1292r-arduino
architectures=*
Loading

0 comments on commit 8450e37

Please sign in to comment.