Code for fluid flow analysis; pressure :: PAID project

Hi everyone :slight_smile:

Your help will be very much appreciated!

I am currently doing a project that involved taking pressure readings from four 30psi pressure transducers.
These pressures are to be read from 4 different sections of my circuit to measure the fluid dynamics of the system.

Could you please help with the code.

I would also like the code to log the data into the computer from all four sensors simultaneously.

Thank you very much

The details of my sensors are
Output: Linear voltage output 0.5V ~ 4.5V. Output 0 psi 0.5V, output 15psi 2.5V, output 30psi 4.5V.

So all this code has to do is take regular readings of the sensors, and print it to the Serial console for the PC to read? Or am I missing something?

wvmarle:
So all this code has to do is take regular readings of the sensors, and print it to the Serial console for the PC to read? Or am I missing something?

Yes to read them all the same time and print(and store) to PC.
Thanks.

Same time is impossible; there's only one ADC so it'll be about 110 us after the other; after that the readings are sent to the PC as a single string.

What sampling rate do you want?

Any specific format the PC expects the values to appear in?

It is fine if the readings are taken at 110us after the other... I'm sure that it is possible to adjust for the delay when I have the data.. could the resolution be as high as sampling every 2milliseconds.

My 4 sensors are of this specification.

30 psi
Input: 0-30 psi
Output: 0.5V~4.5V linear voltage output.
Accuracy: within 2% of reading (full scale).

The aim of the project is to read the pressure changes (in mmHg) and plot the graphs onto excel and use it to calculate the gradient of pressure change.

[The sensors are connected to a network of tubes that contain water, I will be agitating the flow of water and investigate how it changes the pressure, think of it as a fluid dynamics study, but looking at pressure.]

Is writing the data obtained from the sensors to an SD card (say as a CSV file which you could later import into something like Excel) an acceptable solution?

6v6gt:
Is writing the data obtained from the sensors to an SD card (say as a CSV file which you could later import into something like Excel) an acceptable solution?

Yes that will be an acceptable solution.

Thanks.

So I wasn't missing something and it's really that simple.

void setup() {
  Serial.begin(115200);
}

void loop() {
  static uint32_t lastMicros;
  if (micros() - lastMicros > 2000) {
    lastMicros += 2000;
    uint16_t readings[4];
    readings[0] = analogRead(A0);
    readings[1] = analogRead(A1);
    readings[2] = analogRead(A2);
    readings[3] = analogRead(A3);
    Serial.print(readings[0]);
    Serial.print(",");
    Serial.print(readings[1]);
    Serial.print(",");
    Serial.print(readings[2]);
    Serial.print(",");
    Serial.println(readings[3]);
  }
}

Sensors connected to A0-A3; all the calculations to get the actual pressure can be done easily in the spreadsheet. Do make sure your Serial speed is at least 115200 bps to keep up. Every 2 ms a reading; CR for line separation; comma for value separation.

How accurately did you want this timed? 2000ms on an arduino that isn't equipped with a crystal is not really going to be 2000ms. If you are only interested in the current reading and want that updated at least every 2000ms, then cool. But if you want to track the amount over time, then you'll need a real-time clock (RTC). They're not expensive, but it is some extra programming.

The pressure transducers - is it just a matter of reading a voltage, or you you have to communicate with these things using some sort of protocol? If so, does the manufacturer supply a library with which to do it? I2C? SPI? A model number or link to the datasheet would be a good idea.

You say you want help with the code. Do you mean that you have some code and you want help with it, or do you mean that you want help in that you need someone to code this thing?

Having said all that - reading some sensors and then logging it to an SD card is totally do-able, as would be doing something with wifi and http.

This project was over a long time ago.

cedarlakeinstruments:
This project was over a long time ago.

I've often been curious about what goes on in the background when a 'job' is posted here, especially when the OP does not come back, after having received a number of suggestions as to how to proceed.
I guess in this case, the OP received one or a number of PMs soliciting the work.

Me too :slight_smile:

In this case, I completed the project for OP. But I think it's a fair guess that a week after something has been posted, that either someone is working on it "offline" or the OP went elsewhere. At least, that's been my experience when trying to follow up on stuff that's more than a few days old. Note that most of the requesters have very low post numbers, so they tend to not have been on the site for a long time.