LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need assistance with noise filtering on my digital pressure sensor project


I’m working on assembling a digital pressure gauge, and I’ve run into a problem with the noise-filtering stage. I’m using an Arduino Uno R3 to read the data, and then I apply filtering in LabVIEW. However, the filtering doesn’t seem to work at all — it has no noticeable effect. At certain moments the readings suddenly drop to zero, and sometimes they spike unexpectedly, as shown in the pictures.

The pressure sensor I’m using is the MPS20N0040D, and I’m digitizing the signal with an HX711 module set to a gain of 32.

If anyone can help me figure out what’s causing these issues, I would really appreciate it.

Thank you.

image (2).png

llimpaull_0-1765458989955.png

 

image (3).png

llimpaull_0-1765460104665.png

 

image (4).png

image (1).png

    

0 Kudos
Message 1 of 29
(294 Views)

Most here cannot open LabVIEW 2025 VIs. To get better help, i recommend to "save for previous" (e.g. LabVIEW 2019) and attach again.

 

(Why are your charts so messed up? Each has a different size, axis formatting is all over the place)

 

0 Kudos
Message 2 of 29
(244 Views)

here you are 
sorry for messed up im noobie in labview 

0 Kudos
Message 3 of 29
(210 Views)

Remove the bytes at port property node, use a number larger than you would expect for the serial read (maybe 1024) and make sure you are using println, not print in the Aduino code.

 

You are not framing/terminating the data correctly so whatever is on the port is being read at who knows when. Using Println() will append new line and carriage return. By default, VISA configure port will look for a carriage return character for framing.

0 Kudos
Message 4 of 29
(192 Views)

Your problem is not with the noise filtering, but with the serial communication. Since we don't know you instrument, we cannot help, but I would recommend to start paying attention to the following talk

 

You are reading whatever is in the port buffer using "bytes at port" even though your communication is configured with a termination character. Your processing does not depend if there are zero or N bytes at port and it seems often you get nothing because the instrument is slow. Do you have a manual?

 

 

 

Why are you hiding the scrollbars on the front panel???

0 Kudos
Message 5 of 29
(183 Views)

This is the code I use for Arduino. How should I modify my block diagram? I didn't quite catch that correctly 

#include <HX711.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// ----------- HARDWARE ----------
const byte HX_DATA_PIN = 3;
const byte HX_SCK_PIN  = 2;

const byte PUMP_PIN    = 8;
const byte VALVE_PIN   = 9;
const byte BUTTON_PIN  = 7;

#define RELAY_ON  LOW
#define RELAY_OFF HIGH

LiquidCrystal_I2C lcd(0x27, 16, 2);
HX711 hx;

const float slope_mmHg_per_count = 4.32664e-05f;
const long  rawOffset            = 136011L;

const float TARGET_PRESSURE = 180.0;
const float STOP_PRESSURE   = 40.0;

enum State { IDLE, INFLATE, DEFLATE };
State state = IDLE;

float readPressure() {
  long raw = hx.read();
  return slope_mmHg_per_count * (raw - rawOffset);
}

void setup() {
  pinMode(PUMP_PIN, OUTPUT);
  pinMode(VALVE_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  digitalWrite(PUMP_PIN, RELAY_OFF);
  digitalWrite(VALVE_PIN, RELAY_ON);

  lcd.init();
  lcd.backlight();
  lcd.clear();
  lcd.print("System Ready");

  hx.begin(HX_DATA_PIN, HX_SCK_PIN);
  hx.set_gain(32);

  Serial.begin(9600);
}

void loop() {
  // Read pressure with control on sampling rate (10 Hz)
  float P = readPressure();

  // *** فقط فشار خام روی سریال ***
  Serial.println(P);

  switch(state) {

    case IDLE:
      digitalWrite(PUMP_PIN, RELAY_OFF);
      digitalWrite(VALVE_PIN, RELAY_ON);

      lcd.setCursor(0, 0);
      lcd.print("IDLE        ");
      lcd.setCursor(0, 1);
      lcd.print("P: ");
      lcd.print(P, 0);
      lcd.print(" mmHg   ");

      if (digitalRead(BUTTON_PIN) == LOW) {
        delay(50);
        if (digitalRead(BUTTON_PIN) == LOW) {
          lcd.clear();
          lcd.print("Inflating...");
          state = INFLATE;
        }
      }
      break;

    case INFLATE:
      digitalWrite(VALVE_PIN, RELAY_OFF);
      digitalWrite(PUMP_PIN, RELAY_ON);

      if (P >= TARGET_PRESSURE) {
        digitalWrite(PUMP_PIN, RELAY_OFF);
        lcd.clear();
        lcd.print("Deflating...");
        state = DEFLATE;
      }

      lcd.setCursor(0,1);
      lcd.print("P: ");
      lcd.print(P, 0);
      lcd.print(" mmHg   ");
      break;

    case DEFLATE:
      digitalWrite(VALVE_PIN, RELAY_ON);
      digitalWrite(PUMP_PIN, RELAY_OFF);

      if (P <= STOP_PRESSURE) {
        lcd.clear();
        lcd.print("Done, Waiting");
        state = IDLE;
      }

      lcd.setCursor(0,1);
      lcd.print("P: ");
      lcd.print(P, 0);
      lcd.print(" mmHg   ");
      break;
  }

  // Control the sampling rate by adding a delay (10 Hz sampling rate)
  delay(100); // Delay of 100 ms = 10 Hz sampling rate
}
0 Kudos
Message 6 of 29
(173 Views)

Thank you for your time. I just started working with LabVIEW a few days ago, and I don’t know much about it. I watched the video up to a point, but it was too advanced for me, and I didn’t understand much. I didn’t hide the scrollbars; I just cropped them because I didn’t think they were important. Now, what should I do to prevent it from reading zero data and remove it? Another issue I’m facing is with measuring my pulse rate using a sensor. Even with that, it still can’t detect it. Could this be related to the fact that it sometimes reads zero, or is the problem coming from somewhere else? If I need to change the block diagram, please explain simply so I can understand what to do. Thank you

0 Kudos
Message 7 of 29
(165 Views)

Remove the bytes at port property node. Wire 1000 to the serial read bytes to read input.

 

The serial read will read data until:

  • The timeout value is reached,
  • The number of bytes read is equal to the input,
  • or the termination character is read

By default, "Visa configure port" sets the line feed character as the termination character. When you use Serial.PrintLn() in Arduino, it sends the data, a carriage return and a line feed (\r\n). 

0 Kudos
Message 8 of 29
(151 Views)

I extracted this data from the Arduino using CoolTerm. I first connected the cuff loosely to detect normal noise, and then I placed it on my arm to capture both the noise and the pulse together. Now, I want to analyze it using LabVIEW to measure systolic and diastolic pressure using the Mean Arterial Pressure (MAP) method. However, I'm stuck and unable to proceed with training the system to distinguish between the pulse and the noise.

Download All
0 Kudos
Message 9 of 29
(143 Views)

It looks like you are getting a bunch of 0's in your data because you are not reading it correctly from the Arduino. Remove the wait and the bytes from port property node. Also do you really need to write nothing to the port before reading it?

 

 

0 Kudos
Message 10 of 29
(130 Views)