This device measures the gauss of a bldc 540 size rotor. I have a public github page that has the pcb gerbers, bom, stl files to print a case, and the last code I uploaded. I have made some changes since then. I am coming out with a V2, and I want to add the feature of rotor asymmetry. All that said, I do sell these to a very small market and wasn't going to post my new code.
/* Rotor Master v1.1
A WHM Racing product
written by Andrew Sarratore
Date: 7/31/2023
v1.2
added logo to the setup and loop
Date: 9/10/2023
v1.3
Changed from the single read to an average of 30
Date: 9/17/2023
v1.4
Adding Asymmetry to the reading
Date: 11/16/2023
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SELPIN 10 //Selection Pin
#define DATAOUT 11//MOSI
#define DATAIN 12//MISO
#define SPICLOCK 13//Clock
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// Edit the below values with actual values
float VCC = 5.000; // Arduino Voltage
float QOV1 = 2.500; // Quiescent Output Sensor1
float QOV2 = 2.500; // Quiescent Output Sensor2
float QOV3 = 2.500; // Quiescent Output Sensor3
float M1 = 1.000; // Multiplier Sen
int Offset1 = 2048; // Set raw reading to 0
int Offset2 = 2048; // Set raw reading to 0
int Offset3 = 2048; // Set raw reading to 0
float Sensitivity = 0.0013;
int DEL=0; // Set this to 0 with final upload
float divider = (4095 / VCC); // Compensate for Voltage difference of 5v
int readvalue1; //Raw read from ADC1
int readvalue2; //Raw read from ADC2
int readvalue3; //Raw read from ADC3
int Zero1; // Zero the reading for calculations, allows for +/-
int Zero2; // Zero the reading for calculations, allows for +/-
int Zero3; // Zero the reading for calculations, allows for +/-
int Gauss1; //Calculated Gauss
int Gauss2; //Calculated Gauss
int Gauss3; //Calculated Gauss
int HighGauss1=0; //Variable for Max + Value
int HighGauss2=0; //Variable for Max + Value
int HighGauss3=0; //Variable for Max + Value
int LowGauss1=0; //Variable for Max - Value
int LowGauss2=0; //Variable for Max - Value
int LowGauss3=0; //Variable for Max - Value
float Voltage1; // Voltage of Zero
float Voltage2; // Voltage of Zero
float Voltage3; // Voltage of Zero
float G1; // Gauss before Multiplier
float G2; // Gauss before Multiplier
float G3; // Gauss before Multiplier
float OffsetV1;
float OffsetV2;
float OffsetV3;
int i = 0;
int j = 0;
int k = 0;
long int avg1 = 0;
long int avg2 = 0;
long int avg3 = 0;
long int ADC1 = 0;
long int ADC2 = 0;
long int ADC3 = 0;
long int AverageADC1 = 0;
long int AverageADC2 = 0;
long int AverageADC3 = 0;
//for Assymetry
unsigned long HighMicros;
unsigned long prevHighMicros;
unsigned long LowMicros;
unsigned long prevLowMicros;
float ASSYMN;
float ASSYMS;
unsigned long Htime;
unsigned long Ltime;
unsigned long Ttime;
volatile unsigned long AsymisrMicros;
volatile bool AsymnewIsrMicros;
//Bitmap Logos
const unsigned char LogoIcon[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x23, 0x20, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x23, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xfe, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x40, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x78, 0x0f, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xe0, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xf0, 0x07, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x07, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x07, 0xff, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc3, 0xe0, 0x07, 0xe3, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x03, 0xf0, 0x07, 0xe0, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0xe0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x0f, 0xe0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x0f, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x1f, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x7f, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/*
const unsigned char Logotxt [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0b, 0x40, 0x1d, 0xc0, 0x3b, 0x00, 0x00, 0x7c, 0x00, 0x70, 0x01, 0xc0, 0x38, 0x07, 0x60, 0x07,
0x0b, 0xc0, 0x0d, 0x80, 0x1b, 0x00, 0x00, 0x3c, 0x00, 0x70, 0x03, 0x80, 0x18, 0x03, 0x60, 0x0f,
0x0f, 0xc0, 0x1f, 0x80, 0x1f, 0x00, 0x00, 0x2c, 0x00, 0xf0, 0x02, 0x00, 0x10, 0x03, 0xc0, 0x0f,
0x6f, 0x80, 0xff, 0x81, 0xfe, 0x00, 0x03, 0xbc, 0x0f, 0xf0, 0x3e, 0x01, 0xf0, 0x3b, 0xc0, 0x6b,
0x6f, 0x80, 0xff, 0x80, 0xd6, 0x00, 0x01, 0xe8, 0x07, 0xf0, 0x1f, 0x80, 0xf0, 0x1a, 0xc0, 0x6f,
0x0f, 0x80, 0x15, 0x80, 0x76, 0x00, 0x00, 0xec, 0x03, 0xb0, 0x07, 0x80, 0x70, 0x0e, 0xc0, 0x0e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
*/
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
}
attachInterrupt(digitalPinToInterrupt(2), AsymISR, CHANGE);
delay(1000);
display.clearDisplay();
display.drawBitmap(0, 0, LogoIcon, 128, 64, WHITE);
display.display();
pinMode(SELPIN, OUTPUT);
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(SELPIN,HIGH);
digitalWrite(DATAOUT,LOW);
digitalWrite(SPICLOCK,LOW);
delay(500);
} // End Setup
int read_adc(int channel){
int adcvalue = 0;
byte commandbits = B11000000; //command bits - start, mode, chn (3), dont care (3)
//allow channel selection
commandbits|=((channel-1)<<3);
digitalWrite(SELPIN,LOW); //Select adc
// setup bits to be written
for (int i=7; i>=3; i--){
digitalWrite(DATAOUT,commandbits&1<<i);
//cycle clock
digitalWrite(SPICLOCK,HIGH);
digitalWrite(SPICLOCK,LOW);
}
digitalWrite(SPICLOCK,HIGH); //ignores 2 null bits
digitalWrite(SPICLOCK,LOW);
digitalWrite(SPICLOCK,HIGH);
digitalWrite(SPICLOCK,LOW);
//read bits from adc
for (int i=11; i>=0; i--){
adcvalue+=digitalRead(DATAIN)<<i;
//cycle clock
digitalWrite(SPICLOCK,HIGH);
digitalWrite(SPICLOCK,LOW);
}
digitalWrite(SELPIN, HIGH); //turn off device
return adcvalue;
}
void loop() {
//readvalue1 = read_adc(1);
getIsrData();
while(i<30) {
ADC1 = read_adc(1);
avg1 += ADC1;
i++;
}
AverageADC1 = avg1/30;
avg1=0;
i=0;
//readvalue2 = read_adc(2);
while(j<30) {
ADC2 = read_adc(2);
avg2 += ADC2;
j++;
}
AverageADC2 = avg2/30;
avg2=0;
j=0;
//readvalue3 = read_adc(3);
while(k<30) {
ADC3 = read_adc(3);
avg3 += ADC3;
k++;
}
AverageADC3 = avg3/30;
avg3=0;
k=0;
OffsetV1 = (Offset1 - (QOV1 * divider)) / divider;
OffsetV2 = (Offset2 - (QOV2 * divider)) / divider;
OffsetV3 = (Offset3 - (QOV3 * divider)) / divider;
Voltage1 = (AverageADC1) / divider;
Voltage2 = (AverageADC2) / divider;
Voltage3 = (AverageADC3) / divider;
Zero1 = AverageADC1 - Offset1;
Zero2 = AverageADC2 - Offset2;
Zero3 = AverageADC3 - Offset3;
G1 = ((Voltage1 - OffsetV1)-QOV1) / Sensitivity;
G2 = ((Voltage2 - OffsetV2)-QOV2) / Sensitivity;
G3 = ((Voltage3 - OffsetV3)-QOV3) / Sensitivity;
Gauss1 = G1 * M1;
Gauss2 = G2 * M1;
Gauss3 = G3 * M1;
if (Gauss1 > HighGauss1) HighGauss1 = Gauss1;
if (Gauss2 > HighGauss2) HighGauss2 = Gauss2;
if (Gauss3 > HighGauss3) HighGauss3 = Gauss3;
if (Gauss1 < LowGauss1) LowGauss1 = Gauss1;
if (Gauss2 < LowGauss2) LowGauss2 = Gauss2;
if (Gauss3 < LowGauss3) LowGauss3 = Gauss3;
if (Gauss2 >= 0) {
digitalWrite(2, HIGH);
}
else
{
digitalWrite(2, LOW);
}
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.print(ASSYMN);
// display.print("/");
// display.print(ASSYMS);
//display.drawBitmap(0, 0, Logotxt, 128, 15, WHITE);
display.setTextSize(2);
display.setCursor(0,16);
if ((Gauss1 <= 10) && (Gauss1 >= -10)) {
display.println("0");
}
else
{
display.print(Gauss1);
}
display.setCursor(64,16);
if (Gauss1 >= 0)
{
display.print("+");
display.print(HighGauss1);
}
else
{
display.print(LowGauss1);
}
display.setCursor(0,32);
if ((Gauss2 <= 10) && (Gauss2 >= -10)) {
display.println("0");
}
else
{
display.print(Gauss2);
}
display.setCursor(64,32);
if (Gauss2 >= 0)
{
display.print("+");
display.print(HighGauss2);
}
else
{
display.print(LowGauss2);
}
display.setCursor(0,48);
if ((Gauss3 <= 10) && (Gauss3 >= -10)) {
display.println("0");
}
else
{
display.print(Gauss3);
}
display.setCursor(64,48);
if (Gauss3 >= 0)
{
display.print("+");
display.print(HighGauss3);
}
else
{
display.print(LowGauss3);
}
display.display();
Serial.print(AverageADC1);
Serial.print(" RV1 ");
Serial.println();
Serial.print(AverageADC2);
Serial.print(" RV2 ");
Serial.println(" ");
Serial.print(AverageADC3);
Serial.print(" RV3 ");
Serial.println(" ");
Serial.print(Htime);
Serial.println();
Serial.print(Ltime);
Serial.println();
Serial.print(Ttime);
/*
if (digitalRead(2) == HIGH) {
Serial.print("True");
} else {
Serial.print("False");
}
*/
delay(DEL);
} // end loop
// Assymetry Data
void getIsrData() {
if (AsymnewIsrMicros == true && Gauss2 >=0) {
HighMicros = AsymisrMicros; // Record start time for HIGH
} else if (AsymnewIsrMicros == true && Gauss2 < 0) {
LowMicros = AsymisrMicros; // Record start time for LOW
}
noInterrupts();
AsymnewIsrMicros = false;
interrupts();
Htime = LowMicros - HighMicros;
Ltime = HighMicros - LowMicros;
Ttime = (Htime + Ltime);
ASSYMN = Ltime/Htime;
ASSYMS = Htime/Ltime;
} // End getIsrData
// AsymISR
void AsymISR() {
AsymisrMicros = micros();
AsymnewIsrMicros = true;
} // End ISR