Tuesday, May 12, 2015

DIY - Jotiz CardioMachine with Arduino Due and TI MSP 432 and MSP 430

DIY - Jotiz CardioMachine with Arduino Due and TI MSP 432 and MSP 430


I present here a series of blogs that are intended to enable the use of ‘things’ in the Internet of Things IoT complementing Jotiz.

The idea of a Microcontroller based Cardiogram Reading machine was something I had planned on for quite a while. There is little to doubt that Panchanga and Kaala have a definite influence on a person’s mind, spirit and heart. Based on that key-note, I went about assembling a small machine that could fit into your palm, read EKG through electrodes on your body and correlate heart readings to the Panchanga and Kaala of time.

There were several architectural alternatives, which I went through and I present them all to you.

1. Arduino Mega (8 Bit) MCU with Olimex EKG/EMG front-end shield.
2. Arduino Due (32 Bit SAMX) MCU with Olimex EKG/EMG front end shield
3. TI MSP 430 (16 Bit) Launchpad with SparkFun EKG front end board
4. TI MSP 423 (32 Bit) Launchpad with SparkFun EKG front end board

The TI Launchpads were connected headless to the EKG front ends. The data was collected over the serial port through a program written in Java, which would plot and render the data on the cloud. To the Arduino boards, I added shields I had created which had LCD and OLEDs mounted additional to the EKG front ends.

Links and Bill of Material: 

1. Energia - http://energia.nu/
2. Arduino - http://www.arduino.cc/
3. Arduino Mega - http://www.arduino.cc/en/Main/arduinoBoardMega
4. Arduino Due - http://www.arduino.cc/en/Main/arduinoBoardDue
5. Sainsmart Due - http://www.sainsmart.com/sainsmart-due-atmel-sam3x8e-arm-cortex-m3-board.html
6. Sintron Mega 2560 R3 ATmega2560 with USB Cable
7. Olimex EKG Frontend - https://www.olimex.com/Products/Duino/Shields/SHIELD-EKG-EMG/
8. SparkFun AD8232 EKG - https://learn.sparkfun.com/tutorials/ad8232-heart-rate-monitor-hookup-guide
9. Hammond Manufacturing 1553BRDBKBAT Enclosure
10. Gikfun Prototype Shield DIY KIT for Arduino
11. Diymall 0.96" Inch I2c IIC Serial 128x64 OLED
12. SainSmart 1.8" TFT Color LCD Display Module with SPI Interface & MicroSD
13. Radioshack Enclosure Project Skeleton Kit (Two-Tray)
14. TI MSP 430 G2 series - http://www.ti.com/lsds/ti/microcontrollers_16-bit_32-bit/msp/ultra-low_power/msp430g2x_i2x/overview.page
15. Texas Instruments MSP432 Launchpad - http://www.ti.com/tool/MSP-EXP432P401R

Three layered Jotiz-Cardio machine on Arduino (Sintron) Mega
with Olimex EKG/EMG Shield and 0.96 inch OLED

Three layered Jotiz-Cardio machine on Arduino (Sainsmart) Due
with Olimex EKG/EMG shield and 0.96 inch OLED on top shield

MSP 432 Launchpad (32 Bit) with Sparkfun AD8232 EKG Board

MSP 430 Launchpad (16 Bit) with Sparkfun AD8232 EKG Board

MSP 430 Launchpad with Sparkfun EKG inside Hammond Enclosure
with three electrodes attached

How the program works:


Arduino 32 Bit (Single channel) with Olimex EKG Shield


  screen.firstPage();
  do {
    draw();
    screen.setColorIndex(1);
  } while ( screen.nextPage() );

  starttime = millis();
  Serial.begin(57600);
  Serial.setTimeout(2000);
  Serial.println("Vedic Heart Machine");
  Serial.println(">> Please input Time : Example \"21,53,0,25,4,2015,-4\"");
  if (!pTime) {
    processTime();
    pTime = true;
  }
  if (!pDone) {
    doPanchanga();
    pDone = true;
  }
}

void doPanchanga() {
  Serial.print("PCH, Date ");
  Serial.print(nYY);
  Serial.print("-");
  Serial.print(nMM);
  Serial.print("-");
  Serial.print(nDD);
  Serial.print(" Hour ");
  Serial.print(nHour);
  Serial.print(":");
  Serial.print(nMin);
  Serial.print(" TimeZone ");
  Serial.println(nTZ);

  pch.initialize_panchanga(nDD, nMM, nYY, nHour, nMin, nTZ);

  delay(200);
  pDone = true;

  // Set the timer for EKG Reading
  // TC1 : timer counter. Can be TC0, TC1 or TC2
  // 0   : channel. Can be 0, 1 or 2
  // TC3_IRQn: irq number.
  // 250 : frequency (in Hz)
  // The interrupt service routine is TC3_Handler.
  startTimer(TC1, 0, TC3_IRQn, 250);
}

void processTime() {
  nHour = Serial.parseInt();
  nMin = Serial.parseInt();
  nSec = Serial.parseInt();
  nDD = Serial.parseInt();
  nMM = Serial.parseInt();
  nYY = Serial.parseInt();
  nTZ = Serial.parseInt();
  if (nYY == 0) nYY = 2015;
  if (nDD == 0) nDD = 25;
  if (nMM == 0) nMM = 4;
  if (nHour == 0) nHour = 23;
  if (nMin == 0) nMin = 36;
  if (nTZ == 0) nTZ = -4;
  setTime(nHour, nMin, 0, nDD, nMM, nYY);
}

  activetime = millis() - starttime;
  if (timerInitiated) {
    inADC = analogRead(0);
    Serial.print("ADC,");
    Serial.print(inADC);
    Serial.print(",");
    Serial.println(activetime);
  }

Arduino 8-Bit Mega with Olimex EKG and OLED


#define SAMPFREQ 256                      // ADC sampling rate 256
#define TIMER2VAL (1024/(SAMPFREQ))       // Set 256Hz sampling frequency                   
volatile unsigned char CurrentCh = 0;     //Current channel being sampled.
volatile unsigned int ADC_Value = 0;             //ADC current value
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16

// Needed by Panchanga
uint8_t nDay = 6;
uint8_t nDD = 11;
uint8_t nMM = 4;
unsigned int nYY = 2015;
uint8_t nHour = 23;
uint8_t nMin = 18;
int nTZ = -4;
char buf[2];
char sbuf[15];
Panchanga pch;
  noInterrupts(); 
  FlexiTimer2::set(TIMER2VAL, Timer2_Overflow_ISR);
  FlexiTimer2::start();
  interrupts(); 
  doPanchanga();
  ADC_Value = analogRead(CurrentCh);
  // Spit out the values
  Serial.print("ADC, ");   
  Serial.println(ADC_Value);

MSP 432 with Sparkfun AD8232 EKG


int starttime;
int activetime;
int previoustime = 0;
int cnt = 0;
volatile unsigned int inADC = 0;
  pinMode(2, INPUT); // Setup for leads off detection LO +
  pinMode(3, INPUT); // Setup for leads off detection LO -
  if ((digitalRead(2) == 1) || (digitalRead(3) == 1)) {
    // Leads not connected
    // Serial.println('!');
  } else{
    // send the value of analog input 0:
    inADC = analogRead(A0);  // PIN_06
    // inADC = map(inADC, -4096, 4096, 1024, 1024);
    Serial.print("ADC,");
    Serial.print(inADC);
    Serial.print(",");
    Serial.println(activetime);
    ++cnt;
  }
  //Wait for a bit to keep serial data from saturating
  delay(1);

Based on the quality of time as determined by the Panchanga many health problems can be determined. Jotiz is being expanded to included uncharted medical astrology.

Read more about this in the upcoming book “Vedic Machine”

No comments:

Post a Comment