Hello everyone !
I work on a project that implies a MPU-6050, an Arduino Uno (and the Ethernet shield 2) and Labview (2019 version). My objective is to measure the angular speed of a rotating machine with the MPU-6050, and to send the datas to a computer through Ethernet. Then I use Labview to display this datas on a graph (also calculating and showing the angular acceleration), and write it on a txt file.
My problem is that I don't manage to receive the datas on Labview (I just get a line of 0 on the graph and the txt file, and it doesn't change when the machine is turning). I don't have any error message on Labview, so I guess I did something wrong on Arduino, so the datas aren't even sent (first time using Arduino, so it wouldn't surprise me either if I missed a point), even if I don't have any problem during the compilation.
In my tests, I put the same communication port (port 1000) and IP Adress in the Arduino and in the Labview code (so Labview knows where to search), and I modified the parameters of my computer to get a fix IP. But in any case I don't manage to get the datas on Labview ...
Can you help me to solve this problem and improve my Arduino program please ?
I join to my message the Arduino program and the Labview VI I used.
Thank you for your help !
Clément
Arduino code :
#include <Wire.h>
#include <I2Cdev.h>
#include <SPI.h>
#include <Ethernet.h>
#include <MPU6050.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 254, 142, 79);
IPAddress myDns(192, 254, 1, 1);
// On définit le port 1000
EthernetServer server(1000);
MPU6050 centrale;
//On initialise les variables de vitesse angulaire
uint16_t gx, gy, gz;
void setup() {
Ethernet.init(10);
// initialize the ethernet device
Ethernet.begin(mac, ip, myDns);
//Initialisation du MPU-6050 & définition de l'étendue de mesure
Wire.begin();
centrale.initialize();
centrale.setFullScaleGyroRange(250);
//Calibration des 3 axes du MPU-6050
centrale.setXGyroOffset(147);
centrale.setYGyroOffset(-2);
centrale.setZGyroOffset(4);
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// start listening for clients
server.begin();
}
void loop() {
// wait for a new client:
EthernetClient client = server.available();
//On mesure les vitesses angulaires dans les 3 axes
centrale.getRotation(&gx,&gy,&gz);
if (client.available() > 0) {
// Envoyer les données mesurées au client :
server.write(gy * (M_PI / 180));
server.write("\r \n");
}
}
ChatServer_MPU6050.ino (1.39 KB)