I am new to arduino, so I am here to ask some advice on how to approach this task I have at hand.
Right now, I have a graphene CVD system, where the pressure of the system plays the key role in the graphene growth. I am trying to use the arduino to take in the analog signal from the pressure gauge ( KJLC 275i ) and convert the analog input value into pressure information. The manual provided a table to map the input voltage values to pressure values.
With my knowledge on the arduino and basic programming, the only thing I can come up with is to have a bunch of 'if' statements doing:
If the analog input is within this range, then interpolate the discrete values from the table to get me a pressure values in between.
I think it will work, but I am sure there is more efficient way of doing the same thing. Argh, with 31 points from the table, I would have to have at least 30 'if' statements, which can be messy!
A link to the pressure sensor might help, but as long as it's a linear responding analog voltage then it should not be a big deal converting the reading to any internal scaling you require in your program. Reading a analog input pin results in a integer value that can range from 0-1023 counts. From the sensor datasheet it should give you the measurement voltage range Vs pressure range. So for an example lets assume one has a pressure sensor that measures from 0-200 kilopascal of pressure and sends a corresponding voltage output of 0-5vdc.
A arduino converts a 0-5vdc analog voltage to a integer value of 0-1023. So then one can use the arduino mapping function as such:
int scaledReading;
int rawReading;
rawReading = analogRead(pin#);
scaledReading = map(rawReading, 0,1023,0,200);
Then you have a variable named scaledReading that can range in value from 0-200 to utilize in your program.
Again a link to your specific pressure sensor would be required to make this all accurate, but hopefully you get the concept?
Oh my~! Thank you all, guys! All of your info are right on the dot for what I want to do. I have the code written. Now, I would need to test this with the system. Again, THANK YOU!!