mpu_arduino talk to processing

XD hello everyone

i got a trouble for use the mpu6050 gyro
myport is "com3" and my gyro_arduino system send the data on it..i see them on serial monitor.
ok..

i use the processing program win32 bits but it never wants to recognise my arduino data on port usb com3
:stuck_out_tongue_closed_eyes:
does anyone use processing ?
may be he can help me .. ?? =(

best...

:roll_eyes: i give some of my config :

win xp 32bts
processing vers 2.0b8 for win 32

think u... :.

I've done a lot of processing-2- arduino / arduino-2-processing communications using hardware serial, software serial and bluetooth. Here's a few things to check. If none of this helps you then I'd be happy to help if I can and dig deeper. Look over these things...

make sure your baud rates match ...

when you setup your port in processing make sure you use either 'COM3' and not 'com3' (must be upper case) or you can use the port index number instead of COM3. For example if COM3 is the first port found by serial.list then the index number for that port is 0. the ports are zero indexed. next COM port would be index #1 and so on ...

:zipper_mouth_face: thanks very much relic..i verify this and it's ok, my arduino is now talking with my new test on the
jrowberg 's program (you know... the little plane... !!)
https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_DMP6/Processing/MPUTeapot.pde
my problem is that the plane won't move !!
i can see the values glinding down on the little windows under processing,but the little plane did not move an inch !!
:frowning:
i don't know why.... if you've got an idea....

can you post your code? especially how you are trying to communicate between processing and the mpu? sounds like some handshaking is needed :wink:

:grin: yep... here's my mpe processing code :
i 'v been conected on usb port 5 , 115200 bd speed , its talking good...but picture don't move...

import processing.serial.*;
import processing.opengl.*;
import toxi.geom.*;
import toxi.processing.*;

// NOTE: requires ToxicLibs to be installed in order to run properly.
// 1. Download from http://toxiclibs.org/downloads
// 2. Extract into [userdir]/Processing/libraries
//    (location may be different on Mac/Linux)
// 3. Run and bask in awesomeness

ToxiclibsSupport gfx;

Serial port;                         // The serial port
char[] teapotPacket = new char[14];  // InvenSense Teapot packet
int serialCount = 0;                 // current packet byte position
int aligned = 0;
int interval = 0;

float[] q = new float[4];
Quaternion quat = new Quaternion(1, 0, 0, 0);

float[] gravity = new float[3];
float[] euler = new float[3];
float[] ypr = new float[3];

void setup() {
    // 300px square viewport using OpenGL rendering
    size(300, 300, OPENGL);
    gfx = new ToxiclibsSupport(this);

    // setup lights and antialiasing
    lights();
    smooth();
  
    // display serial port list for debugging/clarity
    println(Serial.list());

    // get the first available port (use EITHER this OR the specific port code below)
    String portName = "COM5";
    
    // get a specific serial port (use EITHER this OR the first-available code above)
    //String portName = "COM4";
    
    // open the serial port
    port = new Serial(this, portName, 115200);
    
    // send single character to trigger DMP init/start
    // (expected by MPU6050_DMP6 example Arduino sketch)
    port.write('r');
}

void draw() {
    if (millis() - interval > 1000) {
        // resend single character to trigger DMP init/start
        // in case the MPU is halted/reset while applet is running
        port.write('r');
        interval = millis();
    }
    
    // black background
    background(0);
    
    // translate everything to the middle of the viewport
    pushMatrix();
    translate(width / 2, height / 2);

    // 3-step rotation from yaw/pitch/roll angles (gimbal lock!)
    // ...and other weirdness I haven't figured out yet
    //rotateY(-ypr[0]);
    //rotateZ(-ypr[1]);
    //rotateX(-ypr[2]);

    // toxiclibs direct angle/axis rotation from quaternion (NO gimbal lock!)
    // (axis order [1, 3, 2] and inversion [-1, +1, +1] is a consequence of
    // different coordinate system orientation assumptions between Processing
    // and InvenSense DMP)
    float[] axis = quat.toAxisAngle();
    rotate(axis[0], -axis[1], axis[3], axis[2]);

    // draw main body in red
    fill(255, 0, 0, 200);
    box(10, 10, 200);
    
    // draw front-facing tip in blue
    fill(0, 0, 255, 200);
    pushMatrix();
    translate(0, 0, -120);
    rotateX(PI/2);
    drawCylinder(0, 20, 20, 8);
    popMatrix();
    
    // draw wings and tail fin in green
    fill(0, 255, 0, 200);
    beginShape(TRIANGLES);
    vertex(-100,  2, 30); vertex(0,  2, -80); vertex(100,  2, 30);  // wing top layer
    vertex(-100, -2, 30); vertex(0, -2, -80); vertex(100, -2, 30);  // wing bottom layer
    vertex(-2, 0, 98); vertex(-2, -30, 98); vertex(-2, 0, 70);  // tail left layer
    vertex( 2, 0, 98); vertex( 2, -30, 98); vertex( 2, 0, 70);  // tail right layer
    endShape();
    beginShape(QUADS);
    vertex(-100, 2, 30); vertex(-100, -2, 30); vertex(  0, -2, -80); vertex(  0, 2, -80);
    vertex( 100, 2, 30); vertex( 100, -2, 30); vertex(  0, -2, -80); vertex(  0, 2, -80);
    vertex(-100, 2, 30); vertex(-100, -2, 30); vertex(100, -2,  30); vertex(100, 2,  30);
    vertex(-2,   0, 98); vertex(2,   0, 98); vertex(2, -30, 98); vertex(-2, -30, 98);
    vertex(-2,   0, 98); vertex(2,   0, 98); vertex(2,   0, 70); vertex(-2,   0, 70);
    vertex(-2, -30, 98); vertex(2, -30, 98); vertex(2,   0, 70); vertex(-2,   0, 70);
    endShape();
    
    popMatrix();
}

void serialEvent(Serial port) {
    interval = millis();
    while (port.available() > 0) {
        int ch = port.read();
        print((char)ch);
        if (aligned < 4) {
            // make sure we are properly aligned on a 14-byte packet
            if (serialCount == 0) {
                if (ch == '

and side MPU : (to follow...)) aligned++; else aligned = 0;
           } else if (serialCount == 1) {
               if (ch == 2) aligned++; else aligned = 0;
           } else if (serialCount == 12) {
               if (ch == '\r') aligned++; else aligned = 0;
           } else if (serialCount == 13) {
               if (ch == '\n') aligned++; else aligned = 0;
           }
           //println(ch + " " + aligned + " " + serialCount);
           serialCount++;
           if (serialCount == 14) serialCount = 0;
       } else {
           if (serialCount > 0 || ch == '


and side MPU : (to follow...)) {
                teapotPacket[serialCount++] = (char)ch;
                if (serialCount == 14) {
                    serialCount = 0; // restart packet byte position
                    
                    // get quaternion from data packet
                    q[0] = ((teapotPacket[2] << 8) | teapotPacket[3]) / 16384.0f;
                    q[1] = ((teapotPacket[4] << 8) | teapotPacket[5]) / 16384.0f;
                    q[2] = ((teapotPacket[6] << 8) | teapotPacket[7]) / 16384.0f;
                    q[3] = ((teapotPacket[8] << 8) | teapotPacket[9]) / 16384.0f;
                    for (int i = 0; i < 4; i++) if (q[i] >= 2) q[i] = -4 + q[i];
                    
                    // set our toxilibs quaternion to new data
                    quat.set(q[0], q[1], q[2], q[3]);

                    /*
                    // below calculations unnecessary for orientation only using toxilibs
                    
                    // calculate gravity vector
                    gravity[0] = 2 * (q[1]*q[3] - q[0]*q[2]);
                    gravity[1] = 2 * (q[0]*q[1] + q[2]*q[3]);
                    gravity[2] = q[0]*q[0] - q[1]*q[1] - q[2]*q[2] + q[3]*q[3];
        
                    // calculate Euler angles
                    euler[0] = atan2(2*q[1]*q[2] - 2*q[0]*q[3], 2*q[0]*q[0] + 2*q[1]*q[1] - 1);
                    euler[1] = -asin(2*q[1]*q[3] + 2*q[0]*q[2]);
                    euler[2] = atan2(2*q[2]*q[3] - 2*q[0]*q[1], 2*q[0]*q[0] + 2*q[3]*q[3] - 1);
        
                    // calculate yaw/pitch/roll angles
                    ypr[0] = atan2(2*q[1]*q[2] - 2*q[0]*q[3], 2*q[0]*q[0] + 2*q[1]*q[1] - 1);
                    ypr[1] = atan(gravity[0] / sqrt(gravity[1]*gravity[1] + gravity[2]*gravity[2]));
                    ypr[2] = atan(gravity[1] / sqrt(gravity[0]*gravity[0] + gravity[2]*gravity[2]));
        
                    // output various components for debugging
                    //println("q:\t" + round(q[0]*100.0f)/100.0f + "\t" + round(q[1]*100.0f)/100.0f + "\t" + round(q[2]*100.0f)/100.0f + "\t" + round(q[3]*100.0f)/100.0f);
                    //println("euler:\t" + euler[0]*180.0f/PI + "\t" + euler[1]*180.0f/PI + "\t" + euler[2]*180.0f/PI);
                    //println("ypr:\t" + ypr[0]*180.0f/PI + "\t" + ypr[1]*180.0f/PI + "\t" + ypr[2]*180.0f/PI);
                    */
                }
            }
        }
    }
}

void drawCylinder(float topRadius, float bottomRadius, float tall, int sides) {
    float angle = 0;
    float angleIncrement = TWO_PI / sides;
    beginShape(QUAD_STRIP);
    for (int i = 0; i < sides + 1; ++i) {
        vertex(topRadius*cos(angle), 0, topRadius*sin(angle));
        vertex(bottomRadius*cos(angle), tall, bottomRadius*sin(angle));
        angle += angleIncrement;
    }
    endShape();
    
    // If it is not a cone, draw the circular top cap
    if (topRadius != 0) {
        angle = 0;
        beginShape(TRIANGLE_FAN);
        
        // Center point
        vertex(0, 0, 0);
        for (int i = 0; i < sides + 1; i++) {
            vertex(topRadius * cos(angle), 0, topRadius * sin(angle));
            angle += angleIncrement;
        }
        endShape();
    }
  
    // If it is not a cone, draw the circular bottom cap
    if (bottomRadius != 0) {
        angle = 0;
        beginShape(TRIANGLE_FAN);
    
        // Center point
        vertex(0, tall, 0);
        for (int i = 0; i < sides + 1; i++) {
            vertex(bottomRadius * cos(angle), tall, bottomRadius * sin(angle));
            angle += angleIncrement;
        }
        endShape();
    }
}

and side MPU : (to follow...)

my arduino one code is too big to feet in forum page ..!!
:~
i make it to be readable..i come soon...

and here's my sketch .ino in my arduino one with the mpu 6050 card (int 0 pin 2 connected to "int"), sda,slc,3.3v gnd..

http://ieee.free.fr/ardui/dmp_revu.ino

compliant ?? :blush:

:relaxed: or if you got a simple processing exchange to mpu test with simple graphic it 'll be also right
many thanks..
i only want to understand wich datas are recognised by this pde programm
XD

:zipper_mouth_face: ok i close this topic...

my processing picture is good for the moment ...

i gone make a new post later because i try to understand how it works completely...

best....

[ thank to Close the post MR ADMIN]....many thanks to you... :fearful:

I wrote this for processing. You use a simple handshaking method on the Arduino side. The repository includes a test arduino sketch and a processing demo. no other libraries are needed. Auto finds the arduino COM port without declaring it.

load the .ino sketch FIRST, then run the processing demo :wink:

Hello Builders,

I've experienced the same problem as dr_no did.

But I've found the solution too. Go to MPU6050_DMP.ino in Arduino IDE, and make the following line a comment (//):

#define OUTPUT_READABLE_YAWPITCHROLL

meanwhile uncomment the following line:

//#define OUTPUT_TEAPOT

Compile and upload. Then start Processing, load MPUTeapot and start it.

I hope, this will help.

Tom

:wink: yes Tom...exactly.. , it's realy working good...

Relic 1974_ i test your sketch...realy good...very useful... :zipper_mouth_face:

many thanks to all... :grin: