Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions DAQ_FW/include/ISensorDriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <Arduino.h>

uint16_t baseTemp();


uint16_t brakePressure();


uint16_t tirePressure();
24 changes: 24 additions & 0 deletions DAQ_FW/src/ISensorDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <Arduino.h>
#include <ISensorDriver.h>

uint16_t baseTemp(data, x)
{
// for tempurature sensors - analog reading is directly proportional to temperature in deg-C
uint16_t temperature = data*x; //where x = proportionality constant,
return temperature;
};

uint16_t brakePressure(data)
{
//for brake pressure sensor (MIPAN2XX500PSAAX)
uint16_t pressure = 625*(data-0.5); // in PSI, V_supply @ 25 deg-C = 5V (ratiometric)
return pressure;

};

uint16_t tirePressure(data)
{
//for coolant pressure sensor (116CP31-M04S2-50)
uint16_t pressure = 20*(data-0.5);
return pressure;
};
42 changes: 26 additions & 16 deletions DAQ_FW/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#include "Logger.h"

void setup()
{
// put your setup code here, to run once:
Logger::Start();
Logger::Notice("Setup");
}

void loop()
{
// put your main code here, to run repeatedly:
Logger::Notice("Hello World");

delay(1000);
}
#include <Arduino.h>
#include <ISensorDriver.h>

int sr = 4; // pin number

void setup() {
// put your setup code here, to run once:
pinMode(sr, OUTPUT);
Serial.begin(9600);
Serial.println("Connected");
};

void loop() {
int data = analogRead(sr);

float x=0.5; //temp sensor proportionality constant

// example implementation of functions
// data = brakePressure(data);

//display data
Serial.print("Sensor reading=");
Serial.println(data);

delay(1000);
};
87 changes: 87 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include <Arduino.h>
#include <iostream>

#define temp_PIN 4 // pin numbers
#define brakePressure_PIN 5
#define coolantPressure_PIN 6

#define wheelSpeed_PIN 14

#define tempConst 5 // adjustable temperature proportionality constant for testing

uint16_t wheelPulses=120; // set at random number for testing
Comment thread
rafguevara14 marked this conversation as resolved.
Outdated

void IRAM_ATTR ISR(){ // interrupt service routine
wheelPulses ++;
}

void setup() {
// put your setup code here, to run once:
/*pinMode(temp_PIN, OUTPUT);
pinMode(brakePressure_PIN, OUTPUT);
pinMode(coolantPressure_PIN, OUTPUT); */
pinMode(wheelSpeed_PIN, OUTPUT);

// attach interrupt that adds to pulse count when pin goes from HIGH to LOW
attachInterrupt(wheelSpeed_PIN, ISR, FALLING);

Serial.begin(9600);
Serial.println("Connected");
};

void loop() {
//------------- functions for temperature and pressure sensors ------------//

//int tempData = analogRead(temp_PIN);
//int brakePressureData = analogRead(brakePressure_PIN);
//int tirePressureData = analogRead(coolantPressure_PIN);

// example implementation of functions
// data = brakePressure(data);

// for tempurature sensors - analog reading is directly proportional to temperature in deg-C
//uint16_t temperature = tempData*tempConst;

//for brake pressure sensor (MIPAN2XX500PSAAX)
//uint16_t brakePressure = 625*(brakePressureData-0.5); // in PSI, V_supply @ 25 deg-C = 5V (ratiometric) //display data

//for coolant pressure sensor (116CP31-M04S2-50)
//uint16_t tirePressure = 20*(tirePressureData-0.5);

// for wheel speed sensor
//wheelPulses = 0; // start at 0

//Serial.print("Temperature reading= ");
//Serial.println(temperature);

//Serial.print("Brake pressure reading= ");
//Serial.println(brakePressure);

//Serial.print("Tire pressure reading= ");
//Serial.println(tirePressure);

//-------------- wheel speed interrupt data --------------//

delay(1000); // interrupt detects pulses over 1000ms
uint16_t wheelRPM = wheelPulses/20*60; // 20 pulses from wheel speed sensor corresponds to 1 revolution

Serial.print("Wheel speed (RPM)= ");
Serial.println(wheelRPM);

//-------------- wheel speed sensor testing --------------//

int wheelSpeedData = analogRead(wheelSpeed_PIN);


if (wheelSpeedData == 1){
Serial.println("Unblocked"); //test
};

if (wheelSpeedData==0){
Serial.println("Blocked"); //test
};

//Serial.println(wheelPulses);

};