Soooo, Im really new to writing code, and I'm trying to make a display readout for an ultra high vacuum gauge. The gauge has a logarithmic curve for the pressure/voltage, as the manual states, from 0-10V. I know arduino can only use 0-5v, so I'll use a voltage divider, issue is, now I'm not sure how to make it all work.
Here is the pressure table:
interpolatepressureTable (1 - 9 =V | 10^-10 - 10^-2 =Torr)
1 {1, 0.0000000001},
1.5 {2, 0.000000001},
2 {3, 0.00000001},
2.5 {4, -7},
3 {5, 0.000001},
3.5 {6, 0.00001},
4 {7, 0.0001},
4.5 {8, 0.001},
5 {9, 0.01},
The manual gives you an equation to calculate the pressure. P=10^v-11, where P is pressure, v is voltage, so if my sensor gives me 4 volts i know the pressure reading is 1x10-7 torr. and so on.
Question is, when i send it through a voltage divider, how do I then either have the arduino solve an equation, or interpolate a lookup table. I have no idea how to do the lookup table, here is my uber basic code for the equation, however still based on 0-10V rather than 0-5 like it should be.
#include <LiquidCrystal.h>
#include <math.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("MKS Instruments");
lcd.setCursor(0, 1);
lcd.print("IMT Cold Cathode");
delay(6500);
lcd.clear();
lcd.print("Gauge Pressure:");
}
// the loop routine runs over and over again forever:
void loop() {
pinMode(A0, INPUT); //A0 is set as input
float v = analogRead(A0); //v is input voltage set as floating point unit on analogRead
v = map(v, 0, 1023, 0, 10); //v is voltage measured from 0 to 1023 mapped from 0v to 10v (needs to be 5)
float p = pow(10, v - 11.000); //p is pressure in torr, represented by k in the equation [P=10^(v-k)] which is represented-
// -by 11.000 (K = 11.000 for Torr, 10.875 for mbar, 8.000 for microns, 8.875 for Pascal)
Serial.print(v);
char pressureE[5];
dtostre(p, pressureE, 1, 0); // scientific format with 1 decimal places
lcd.setCursor(0, 1);
lcd.print(pressureE);
lcd.print(" Torr");
}
CCVacuumGaugebase.ino (1.36 KB)
MKS903.pdf (264 KB)