Mearing flow rate

Hi. I'm new to arduino. I wondering anyone could help me in this programming. I have liquid flow sensor and it will give a PWM when water is flowing through. But how can I program the board to show the flow rate to an excel file?

The PulseIn function will get you the PWM detail. You can write the data to a file on an SD card if you have the hardware, or send it to a PC running a program that will push it to a file. Processing is often used for this purpose although you can write the receiving program in your language of choice or use a terminal program that can capture input to file.

There is an Excel add-on that enables you to add data received via a serial port to the current document, so you can see live data in tables and charts etc.

If you only want to save the data to analyse later, it would be easier to write it to a text file in CSV format. On Windows, you can use Gobetwino to write data from the Arduino to a file on the PC.

I've have edited the code and it looks like this. int x = 0; int row = 0; int pulsePin = 2; unsigned long counter = 0; unsigned long duration = 0; //unsigned long timeout = 1000000; // in microseconds

void setup() { Serial.begin(128000); // opens serial port, sets data rate to 9600 bps Serial.println("CLEARDATA"); pinMode(pulsePin, INPUT); digitalWrite(pulsePin, HIGH); }

void loop() { duration = pulseIn(pulsePin, HIGH); //Serial.print("LABEL,Time,X,sin x,row, Duration,Pulse started before the timeout"); if (duration == 0) { Serial.println("LABEL,Time,X,sin x,row, Duration,Pulse"); Serial.print("DATA,TIME,"); //Printing time and command to send data Serial.print(x); //Data x Serial.print(","); //Send value of x to excel Serial.print(sin(x*PI/180)); //Data sin x Serial.print(","); //Send value sin x to excel Serial.print(row); //Data row Serial.print(","); //Send value of row to excel Serial.print(counter); //Data counter Serial.print(","); //Send value of row to excel Serial.println("no pulse"); //Data duration Serial.print(","); //Send value of row to excel row++; //next row x++;

if (row > 20) //Let it run for 20 cells { row=1; Serial.println("ROW,SET,2"); //means go back to row 2 in excel } delay(1000); } else { counter++; Serial.println("LABEL,Time,X,sin x,row, Duration,Pulse"); Serial.print("DATA,TIME,"); //Printing time and command to send data Serial.print(x); //Data x Serial.print(","); //Send value of x to excel Serial.print(sin(x*PI/180)); //Data sin x Serial.print(","); //Send value sin x to excel Serial.print(row); //Data row Serial.print(","); //Send value of row to excel Serial.print(counter); //Data counter Serial.print(","); //Send value of row to excel Serial.println("Got pulse"); //Data duration Serial.print(","); //Send value of row to excel row++; //next row x++;

if (row > 20) //Let it run for 20 cells { row=1; Serial.println("ROW,SET,2"); //means go back to row 2 in excel } delay(1000); //Delay one second } } it is able to send to the excel file through PLX-DAQ however it cannot sense the pulse when 5V is applied at the input. Where could the problem be at?

arduinowarrior123: it cannot sense the pulse when 5V is applied at the input.

What value does pulseIn() return?

Are you definitely applying a LOW/HIGH/LOW pulse to the relevant input pin [u]during the call to pulseIn/u?

How long is the pulse you are applying?

arduinowarrior123:

Serial.begin(128000); // opens serial port, sets data rate to 9600 bps

The comment doesn’t agree with the action.

115200 is a supported baud rate ...

robtillaart: 115200 is a supported baud rate ...

The code says 128000, but the comment says 9600 bps. Which is it supposed to be?

Technically speaking an Arduino can perfectly send at 500000 or 230400 or 345600 and non standard baudrates as long as the other end can cope with it.

The build in serial monitor of the IDE can only handle "standard baud rates".

arduinowarrior123: Hi. I'm new to arduino. I wondering anyone could help me in this programming. I have liquid flow sensor and it will give a PWM when water is flowing through. But how can I program the board to show the flow rate to an excel file?

A link to your 'flow sensor' might be useful. Many flow meters output a pulse train where one counts the pulses to measure the flow rate, say 1,000 pulses per liter, rather then use a PWM signal where the resultant measured duty cycle is the measurement of the flow rate. So be sure you understand how your specific flow sensor actually works before looking for a arduino coding solution.

Lefty