- C code for measuring Water pressure - converting the analog signal from a transducer to digital
- Posted by sagar on June 26th, 2003
Hi,
I am excuting a project where a module involves measuring the water
pressure in a pipe. I have a transducer to convert the pressure to
electrial signal. I want a C code (that I will embed in a chip), which
will convert this electrical input to numerical(digital) output. this
digital signal will be transmitted by wireless.
Please help me with the code.
Thanks & Regards
- Posted by Vadim Borshchev on June 26th, 2003
sagar wrote:
Here is the function that will do the necessary conversions:
float electrical_to_numerical (unsigned short electrical)
{
return 1.0 * (float) electrical;
}
Pass the value of electrical signal to the function. It will return the
numerical value that you can transmit by wireless. Please note that the
return type "float" is essential because you are dealing with water pressure.
- Posted by Stef on June 26th, 2003
sagar wrote:
/**************
Pressure.c
Reads an analog signal from a pressure sensor and
transmits the calculated pressure by wireless transmitter.
Language: C
Processor: Generic
ADC: Generic
Pressure sensor: Generic
Output format: Generic
Wireless Transmitter: Generic
To adapt the progam to your specific requirements, please implement:
- ReadADC()
- ConvertToPressure()
- Format()
- TransmitByWireless()
- GENERIC_FORMAT
If you need help with this, please give more information.
**************/
#include <adc.h>
#include <pressuresensor.h>
#include <format.h>
#include <wireless.h>
int main(void)
{
int adc_value;
int pressure;
GENERIC_FORMAT output;
while(1)
{
adc_value = ReadADC();
pressure = ConvertToPressure(adc_value);
output = Format(pressure);
TransmitByWireless(output);
}
return 0;
}
HTH,
Stef
- Posted by CBFalconer on June 26th, 2003
Stef wrote:
You guys should be reported to the SPCCN. [1]
[1] Society for Protection against Cruelty to Clueless Newbies.
--
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
- Posted by Unbeliever on June 26th, 2003
"sagar" <karthiksagar@yahoo.com> wrote in message
news:75abcb2b.0306260118.624797b0@posting.google.c om...
A little more seriously than some of the other replies, I hope. If you're
asking this question in this manner, you are not yet quite ready for this
project. It's a little bit like asking please design me a piston so that I
can build a car.
You will be much better off using an off the shelf solution such as an
Advantech Adam 4017 analog input card and Adam 4500 radio modem. I'm sure
there are other similar solutions, this is just one off the top of my head.
Good Luck,
--
Alf Katz
alfkatz@remove.the.obvious.ieee.org
- Posted by Gary Kato on June 26th, 2003
Since we have no idea what hardware you are using, we really can't help very
much. You might want to read the book "Designing Embedded Hardware", especially
the chapter on "Analog".
Essentially, what you need is hardware called an Analog To Digital Converter
(ADC) to convert the signal from the transducer to a digital value. There are
separate chips which do this or it might be built into whatever microcontroller
you are using.