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

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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

Re: C code for measuring Water pressure - converting the analog signal from a transducer to digital
Quoted text here. Click to load it

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.

Re: C code for measuring Water pressure - converting the analog signal from a transducer to digital
Quoted text here. Click to load it

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



Re: C code for measuring Water pressure - converting the analog signal from a transducer to digital
Quoted text here. Click to load it

You guys should be reported to the SPCCN. [1]

[1] Society for Protection against Cruelty to Clueless Newbies.

--
Chuck F ( snipped-for-privacy@yahoo.com) ( snipped-for-privacy@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
We've slightly trimmed the long signature. Click to see the full one.
Re: C code for measuring Water pressure - converting the analog signal from a transducer to digital

Quoted text here. Click to load it

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




Re: C code for measuring Water pressure - converting the analog signal from a transducer to digital
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.


Site Timeline