LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real-Time Gait Sensor analysis using TCP

I am currently creating a tcp server vi to receive information data from a circuit with esp8266 and mpu6050 to display all 6 data parameters on one 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.37"; // Change to your LabVIEW TCP server IP address const int serverPort = 61762; // 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 sensor 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; } } // Format the data string String dataToSend = String("AccelX:") + String(a.acceleration.x, 2) + ", AccelY:" + String(a.acceleration.y, 2) + ", AccelZ:" + String(a.acceleration.z, 2) + ", GyroX:" + String(g.gyro.x, 2) + ", GyroY:" + String(g.gyro.y, 2) + ", GyroZ:" + String(g.gyro.z, 2) + ", Temp:" + String(temp.temperature, 2); // Send the data to LabVIEW 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
 
0 Kudos
Message 11 of 30
(660 Views)

I am currently creating a tcp server vi to receive information data from a circuit with esp8266 and mpu6050 to display all 6 data parameters on one 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.37"; // Change to your LabVIEW TCP server IP address
const int serverPort = 61762; // 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 sensor 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;
}
}

// Format the data string
String dataToSend = String("AccelX:") + String(a.acceleration.x, 2) +
", AccelY:" + String(a.acceleration.y, 2) +
", AccelZ:" + String(a.acceleration.z, 2) +
", GyroX:" + String(g.gyro.x, 2) +
", GyroY:" + String(g.gyro.y, 2) +
", GyroZ:" + String(g.gyro.z, 2) +
", Temp:" + String(temp.temperature, 2);

// Send the data to LabVIEW
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 12 of 30
(659 Views)

StephenJohn_1-1713013076610.png

 

I am currently creating a tcp server vi to receive data from a circuit with esp8266 and mpu6050 to display all of its 7 gait parameters on one waveform chart but keep getting errors. Please help

0 Kudos
Message 13 of 30
(641 Views)

StephenJohn_0-1713126336014.png

How to adjust this VI to read several parameters from an esp8266/mpu6050 circuit to display on one waveform chart via TCP.

0 Kudos
Message 14 of 30
(629 Views)

StephenJohn_0-1713126766010.png

How to modify this VI to display several gait parameters from an esp8266/mpu6050 circuit on one waveform chart via TCP?

0 Kudos
Message 15 of 30
(613 Views)

Regarding multiple plots, this is from the LabVIEW Help:


Displaying Multiple Plots on Waveform Charts

To pass data for multiple plots to a waveform chart, you can bundle the data together into a cluster of scalar numeric values, where each numeric represents a single point for each of the plots.

If you want to pass multiple points per plot in a single update, wire an array of clusters of numeric values to the chart. Each numeric represents a single y value point for each of the plots.

You can use the waveform data type to create multiple plots on a waveform chart. Use the Build Waveform function to plot time on the x-axis of the chart and automatically use the correct interval between markers on the x-scale of the chart. A 1D array of waveforms that each specify t0 and a single-element Y array is useful for plotting data that is not evenly sampled because each data point has its own time stamp.

If you cannot determine the number of plots you want to display until run time, or you want to pass multiple points for multiple plots in a single update, wire a 2D array of numeric values or waveforms to the chart. By default, the waveform chart treats each column in the array as a single plot. Wire a 2D array data type to the chart, right-click the chart, and select Transpose Array from the shortcut menu to treat each row in the array as a single plot.

Refer to the labview\examples\Controls and Indicators\Graphs and Charts\Waveform Graphs and Charts\Waveform Graphs and Charts.lvproj for examples of the waveform chart.


cordm_1-1713155838836.png

 

 

What error do you get for the TCP connection?

 

You cannot use TCP read with bytes to read <0. That part is also mentioned in the other thread. Use CRLF mode with a sufficient byte count as mentioned before.

 

The scan from string format string does not match the format you send from arduino.

 

(You can create a snippet by selecting the relevant block diagram parts and choosing Edit->Create Snipped from Selection)

 

0 Kudos
Message 16 of 30
(607 Views)

Hi John,

 


@StephenJohn wrote:

How to adjust this VI to read several parameters from an esp8266/mpu6050 circuit to display on one waveform chart via TCP.


Apparently this VI will do just that…

Do you have any specific problems with this VI?

 

Please stop asking the same question in several threads: stick with your own thread and keep information in one place!

Best regards,
GerdW


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

StephenJohn_0-1713210348565.png

I used this VI to display multiplots on the waveform chart of the data but error 85 came up. The data is in this format: 1.2,1.4,1.5,5.7,4.6,6.5,7.8.

StephenJohn_1-1713210476386.png

 

0 Kudos
Message 18 of 30
(577 Views)

Can you show what is received by TCP read? Probe the wire or add a string indicator.

0 Kudos
Message 19 of 30
(562 Views)

Good day,

Please note that the data received by the tcp read is in this format: .0,0.0,0.0,0.0,0.0,0.0,36.5. And the error 85 keeps showing up. Please help.

 
 
 
 
 
 
 
 
 

 

 

 

 
 
 
 
 
 
 
 
 
 
 
 
 

 

 
 

 

0 Kudos
Message 20 of 30
(431 Views)