LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real-Time Gait Sensor analysis using TCP

I am currently working on a gait sensor analysis system. I am using a circuit with esp8266 and mpu6050. The data from the sensor must be wirelessly transmitted via TCP protocol to labview to display 10 gait parameters on one waveform chart in real-time. Please see the VI that I have been working on, however I need advice on whether I am going in the right direction with my approach in order to move forward.

0 Kudos
Message 1 of 30
(961 Views)

Hi Stephen,

 


@StephenJohn wrote:

Please see the VI that I have been working on


Which VI?

 

When attaching your VI I recommend to downconvert the VI before uploading (File->Save for previous).

I prefer LV2019, others may like LV2021 or older…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 30
(941 Views)

I am currently creating a tcp server vi to receive information data from a circuit with esp8266 and mpu6050 to display one gait parameter on a waveform chart. Firstly I programmed the esp8266 using the following code and a connection failed output: 

#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_MPU6050.h>

// Wi-Fi credentials
const char* ssid = "Galaxy A32960C";
const char* password = "sqzl3356";

// LabVIEW TCP server address and port
const char* serverAddress = "192.168.108.98"; // Change to your LabVIEW TCP server IP address
const int serverPort = 34908; // Change to your LabVIEW TCP server port

WiFiClient client;
Adafruit_MPU6050 mpu;

void setup() {
  Serial.begin(115200);
  delay(100);

  // Connect to Wi-Fi
  Serial.println();
  Serial.println("Connecting to WiFi");
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  Serial.println("\nWiFi connected");

  // Initialize MPU6050
  if (!mpu.begin()) {
    Serial.println("Sensor init failed");
    while (1)
      yield();
  }
  Serial.println("Found an MPU-6050 sensor");
}

void loop() {
  // Read accelerometer data
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  // Connect to the LabVIEW TCP server if not connected
  if (!client.connected()) {
    Serial.print("Connecting to ");
    Serial.print(serverAddress);
    Serial.print(" on port ");
    Serial.println(serverPort);
   
    if (client.connect(serverAddress, serverPort)) {
      Serial.println("Connected to server");
    } else {
      Serial.println("Connection failed");
      return;
    }
  }

  // Send accelerometer X data to LabVIEW
  String dataToSend = String(a.acceleration.x, 1); // Convert float to String with one decimal place
  client.println(dataToSend);

  // Debug message to verify data sent over network
  Serial.print("Sent data to server: ");
  Serial.println(dataToSend);

  delay(1000); // Adjust delay as needed
}
 
On the labview end, I have created a VI with the following blocks in order: tcp create listener, tcp wait on listener, tcp read, scan from string, string to number then waveform chart. Please help me to figure out a way to get the circuit to successful connect to labview to display data as required.
0 Kudos
Message 3 of 30
(850 Views)

If you get "Connection failed" log entries it could mean for example

- the listener port in LabVIEW is incorrect

- the IP address of the LabVIEW server is incorrect

- a firewall is preventing an incoming connection

 

Here is what the VI should look like:

 

snip.png

 

0 Kudos
Message 4 of 30
(835 Views)

What are good ways to rectify these issues that may arise:

If you get "Connection failed" log entries it could mean for example

- the listener port in LabVIEW is incorrect

- the IP address of the LabVIEW server is incorrect

- a firewall is preventing an incoming connection

0 Kudos
Message 5 of 30
(819 Views)

Please note that I am tasked with a gait sensor analysis system. It will consist of seven circuits each containing a battery, mpu6050 and esp8266 each measuring 10 gait parameters to connect to a labview server vi to display gait parameters on waveform charts, one chart for each circuit. How to create this VI?

0 Kudos
Message 6 of 30
(814 Views)

Which function is connected to the waveform block?

0 Kudos
Message 7 of 30
(805 Views)

Hi Stephen,

 


@StephenJohn wrote:

Which function is connected to the waveform block?


Are you asking for "which function delivers the data for the waveform chart"?

It's a function to convert a string (pink wire) into numeric data (orange wire), so you should look inside the string palette…

 

Btw. it's a snippet in the previous message! You can drag&drop snippets into a block diagram as they actually contain code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 30
(782 Views)

@StephenJohn wrote:

What are good ways to rectify these issues that may arise:

If you get "Connection failed" log entries it could mean for example

- the listener port in LabVIEW is incorrect

- the IP address of the LabVIEW server is incorrect

- a firewall is preventing an incoming connection


- use the same port number on the Arduino side (where it says "// Change to your LabVIEW TCP server port" in the source code) and on the LabVIEW side (the little blue box at the beginning of my snippet)

- find out the IP address of your LabVIEW-server and change it in the source code (where it says "// Change to your LabVIEW TCP server IP address")

- also make sure arduino and server are connected to the same network

- If you have Windows Defender Firewall, search for "allow apps" in start menu, which leads you here and allow LabVIEW to communicate. There should have been a prompt when you try listening for network connections with LabVIEW though. If you use anything else, check with your IT guys.

cordm_0-1712911233585.png

 


@StephenJohn wrote:
Please note that I am tasked with a gait sensor analysis system. It will consist of seven circuits each containing a battery, mpu6050 and esp8266 each measuring 10 gait parameters to connect to a labview server vi to display gait parameters on waveform charts, one chart for each circuit. How to create this VI?

You will have one loop that waits for incoming connections. Upon client connect, use start asynchronous call to launch a VI that handles the communication. That VI sends received to a display VI, by e.g. using a queue. The display VI can be the one that contains the incoming connection listener.

 


@StephenJohn wrote:
Which function is connected to the waveform block?

Frac/exp string to numer. If you download the image (using the download button - right click saving does not work, at least not in firefox), you can drag it onto your block diagram and have it decoded into LabVIEW nodes. It is called a snippet, because it contains LabVIEW metadata.

You send a string like "1.2\r\n" over the TCP connection. .println appends \r\n to the string, which is why I used CRLF mode for TCP read.

0 Kudos
Message 9 of 30
(771 Views)

How to modify this VI to display 6 parameters on the one waveform chart?

0 Kudos
Message 10 of 30
(751 Views)