Saturday, September 6, 2014

Sensor Calibration

Hello again. I know its been a while, however I was enjoying my long vacations :)
Since I managed to make my BT Fuel manager work with all sensors, I had to calibrate them because for most the datasheet was crap!! So here it is, well an old version of it I think. Don't even know if it is the working one since my device is installed on my boat.

How it works:

The counters start from 0 in the Serial Console.
Connect the sensors and pass a litre of water (gasoline is better, but stick to water) through the sensor.
I did this by connecting a fuel hose to a bottle which hat exactly one liter in it.
After all the water has passed trough the sensor , notice the number of Pulses it registered. Thats your pulses per liter!

Easy!


//******************************************************
//     BT Fuel Manager Sensor Calibration Arduino
//               sketch by MaleBuffy
//                21/6/2014
//******************************************************
//
//     Pin D4 for +5V for the Sensor 1
//     Pin D6 for GND for the Sensor 1
//     Pin D2 for Sensor 1 cable
//     Pin D3 for Sensor 2 cable
//     Pin D4 for +5V for the Sensor 2
//     Pin D6 for GND for the Sensor 2




#include <SoftwareSerial.h> // import the Arduino serial library 

volatile float PulseSensor=0; // Measuring the pulse from the sensor 1
volatile float PulseSensor2=0;// Measuring the pulse from the sensor 2

int hall = 2;    // Sensor 1 Pin should be connected to Pin 2 of the Arduino
int hall2 = 3;   // Sensor 2 Pin should be connected to Pin 3 of the Arduino


void incementpulse ()     //This is the function that incements the pulse counter. PulseSensor 1
{
  PulseSensor++;  // Equals PulseSensor = PulseSensor + 1
}

void incementpulse2 ()     //This is the function that incements the pulse counter. PulseSensor 2
{
  PulseSensor2++;  // Equals PulseSensor = PulseSensor + 1
}


// Begin of Code. Setting pins up.

void setup()
{

  pinMode(hall, INPUT); // Init Pin 2 to receive data from the Sensor
  digitalWrite(hall, HIGH); // Using Internal Pull up resistor to pin 2

  pinMode(hall2, INPUT); // Init Pin 3 to receive data from the Sensor
  digitalWrite(hall2, HIGH); // Using Internal Pull up resistor to pin 3


  pinMode(4, OUTPUT); // Initializes digital pin 4 as an OUTPUT
  digitalWrite(4, HIGH); // 5V to pin 4 (Flow Sensor)
  pinMode(6, OUTPUT); // Initializes digital pin 6 as an OUTPUT
  digitalWrite(6, LOW); // GND to pin 6 (Flow Sensor)
 

  attachInterrupt(0, incementpulse, RISING); // attaching the interupt
  attachInterrupt(1, incementpulse2, RISING); // attaching the interupt
  sei();      // Enabling interrupts

 Serial.begin(9600);
}


// Loop measuring pulses from Sensor

void loop ()  
{

  Serial.print("PulseSensor: ");
  Serial.println(PulseSensor);

  Serial.print("PulseSensor2: ");
  Serial.println(PulseSensor2);


}

No comments:

Post a Comment