C code for measuring Water pressure - converting the analog signal from a transducer to digital

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

Reply to
sagar
Loading thread data ...

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.

Reply to
Vadim Borshchev

/************** 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 #include #include #include

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

Reply to
Stef

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.
     USE worldnet address!
Reply to
CBFalconer

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

snipped-for-privacy@remove.the.obvious.ieee.org

Reply to
Unbeliever

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.

Reply to
Gary Kato

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.