Go Down

Topic: Code for fluid flow analysis; pressure :: PAID project  (Read 766 times) previous topic - next topic

ezekieldinama

Jul 25, 2019, 02:17 am Last Edit: Jul 25, 2019, 02:18 am by ezekieldinama
Hi everyone :)

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.

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?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ezekieldinama

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.

wvmarle

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?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ezekieldinama

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.]

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?

ezekieldinama

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.

wvmarle

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

Code: [Select]

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.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

PaulMurrayCbr

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.
http://paulmurraycbr.github.io/ArduinoTheOOWay.html

cedarlakeinstruments

Electronics and firmware/software design and assistance. No project too small

6v6gt

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.


cedarlakeinstruments

Me too :-)

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.
Electronics and firmware/software design and assistance. No project too small

Go Up