Skip to content

Commit

Permalink
Migrated configs to separate header file, made adjustment to definition
Browse files Browse the repository at this point in the history
  • Loading branch information
pyr0ball committed Jul 19, 2019
1 parent 95ea534 commit 56c0600
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
Expand Up @@ -54,16 +54,6 @@ The gain STATE is representative of these values:
4 = 11x
*/

// Configurable settings:
int GAIN_FACTOR = 2; // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
#define InitCount 6 // Number of times to blink the LED on start
int LOOP_DUR = 50; // duration of time between ADC checks and other loop functions
int TRG_DUR = 20; // duration of the Z-axis pulse sent, in ms
#define senseThrs 1450
#define compThrs 2850
int Hyst = 20; // Hysteresis value for ADC measurements
long voltMeterConstant = 1125300L; // For fine tuning input voltage sense

/*------------------------------------------------------------*/

// Debug output toggle. Uncomment to enable
Expand All @@ -76,12 +66,13 @@ long voltMeterConstant = 1125300L; // For fine tuning input voltage sense
// Headers, variables, and functions
#include "LightChrono.h"
#include "pP_pins.h"
#include "pP_config.h"
#include "pP_volatile.h"
#include "pP_function.h"
#include "pP_serial.h"

// i2c input toggle. Uncomment to enable
#define I2C true
//#define I2C_INPUT true

void setup() {
pinMode(TRG_OUT, OUTPUT); // declare the Trigger as as OUTPUT
Expand All @@ -103,7 +94,7 @@ void setup() {
/*------------------------------------------------*/

void loop() {
if (mainLoop.haspassed(LOOP_DUR)) {
if (mainLoop.hasPassed(LOOP_DUR)) {
mainLoop.restart();
// Blink LED's on init
if (BlinkCount > 0) {
Expand Down
41 changes: 41 additions & 0 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_config.h
@@ -0,0 +1,41 @@
// Configurable settings:

#if !(defined(GAIN_FACTOR))
int GAIN_FACTOR = 2; // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
#endif

#ifndef senseThrs
#define senseThrs 1450
#endif

#ifndef compThrs
#define compThrs 2850
#endif

#ifndef InitCount
#define InitCount 6 // Number of times to blink the LED on start
#endif

#if !(defined(LOOP_DUR))
int LOOP_DUR = 50; // duration of time between ADC checks and other loop functions
#endif

#if !(defined(TRG_DUR))
int TRG_DUR = 20; // duration of the Z-axis pulse sent, in ms
#endif

#if !(defined(Hyst))
int Hyst = 20; // Hysteresis value for ADC measurements
#endif

#if !(defined(voldMeterConstant))
long voltMeterConstant = 1125300L; // For fine tuning input voltage sense
#endif

#ifdef I2C
#if !(defined(pP_i2c_address))
byte pP_i2c_address = 0xa0; // I2C Bus Address
#endif
#endif


10 changes: 6 additions & 4 deletions firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/pP_volatile.h
Expand Up @@ -9,10 +9,11 @@ int VOld = 5000; // Variable to store previous cycle's Vin
int VLast = 0;

// Convert threshold values based on the input voltage

long senseLong = senseThrs * 1024L;
long compLong = compThrs * 1024L;
long senseInt = senseLong / Vin;
long compInt = compLong / Vin;
long senseInt;
long compInt;

// Voltage Comparator Adjustment parameters
int VComp = 0;
Expand All @@ -25,6 +26,7 @@ int diffAdjL = VAdj - senseInt;
int diffAdjH = senseInt - VAdj;

// Error blink parameters

int BlinkState = LOW;
int BlinkCount = InitCount * 2; // Multiply Blink count by 2 to handle toggle state

Expand All @@ -39,8 +41,8 @@ bool serialIncoming = false;
char serialMessageIn[buffSize] = {0};
int serialInt = 0;

#define LOW 0
#define HIGH 1
//#define LOW 0
//#define HIGH 1

// Task scheduler instances
LightChrono mainLoop;

0 comments on commit 56c0600

Please sign in to comment.