Prop Shield Beta Test

Status
Not open for further replies.
Can't you just add:
Code:
      SPI.setSCK(14); (SCLK connected on Teensy pin 14)
to your SPI code ?

@Paul,
any design reason to have the spi clk on pin13 and not pin14?
this way one cannot use I2S (i.e audio boards) together with the Prob shield.
 
Can't you just add:
Code:
      SPI.setSCK(14); (SCLK connected on Teensy pin 14)
to your SPI code ?

Sorry, I was referring to prop shield that is using pin13 for spi0_clk, while audio boards use pin13 for I2S0_RDX0 and pin14 for spi0_clk.
So you cannot use prop shield and audio board together.

There maybe other incompatibilities between audio board and prop shield, that is why I asked.
Also, I assume that Paul thought about this, but decided this way.
 
I'm not sure that the Pitch/Roll with Yaw problem lies with the Curie visualizer alone.
Last night I was Stripcharting the Heading, Pitch, & Roll outputs from both the NXP_Sensor_Fusion and Mahony AHRS algorithms.
It seems that the issue is also present there as well.

Yes, until yesterday, they were all wrong. I had copied the Madgwick's incorrect quaternion to angles code, because NXPSensorFusion wasn't working with the buggy visualizer.

NXPSensorFusion and Mahony are now fixed, and the visualizer provided with the library is correct. I'm going to update Madgwick right after I get caught up on answering forum threads, and with any luck I'll get Arduino to update their web page with their buggy visualizer.

I also sent a pull request which Adafruit merged, to fix their visualizer. Later today or this week I might try looking around the Arduino world to find other copies. This same wrong code seems to have been very widely copied over the last few years.
 
A question...
Are there speakers that do not affect the magnetometer?

:confused:

Or, as an alternative, can the algorithms work without using the magnetometer-data ?
How to use the amp without loooong cables ? Any ideas ?
 
Last edited:
A piezo speaker would not necessarily affect the magnetometer. There are "magnetically shielded" moving-coil speakers but I doubt they are 100% shielded.
 
New visualizer is wonderful! It has been a long day, installed Ubantu (very first time Linux attempt), installed Arduino and Teensyduino, Processing ( anyone know how to make an icon to run it instead of using "sh") Now I have Teensy programed and watching the Prop Shield twist and turn :)
 
A piezo speaker would not necessarily affect the magnetometer. There are "magnetically shielded" moving-coil speakers but I doubt they are 100% shielded.
Piezo speaker is a good idea. Keep in mind they don't work well below ~1kHz, so not hifi at all and far from ideal even for voice. And you are right, magnetic shielding of MC-speakers is not good enough for a compass to work near it. Even if the speaker had a good enough shielding, that shielding itself would also distort the earths magnetic field around it, so that wouldn't help _that_ much (although, I guess, you could calibrate against that).
 
The latest NXP Motion Sense library updates all seem to be working beautifully.
I get great results with the either NXP, Madgwick or Mahony AHRS filters.
Smooth and accurate motion with the visualizer.
It does seem to matter how the Prop Shield is oriented on power up.
I'm still trying to characterize this.
For me I get best results with +Y oriented North and the base flat when I power on the Teensy and Prop Shield.

I've created some additions to Ben's beautiful Prop Shield model in Processing to add a Teensy and headers.
(Thank you Ben and Paul)
Madgwick.JPG

The only puzzling thing is that I need to reverse YAW.
Also I needed to remove the ":" after the com port define on my Windows 10 PC.
Here is the Processing code:
Code:
import processing.serial.*;
Serial myPort;

float yaw = 0.0;
float pitch = 0.0;
float roll = 0.0;

void setup()
{
  size(600, 600, P3D);

  // if you have only ONE serial port active
  //myPort = new Serial(this, Serial.list()[0], 9600); // if you have only ONE serial port active

  // if you know the serial port name
  myPort = new Serial(this, "COM8", 9600);       // Windows "COM#:"
  //myPort = new Serial(this, "/dev/ttyACM0", 9600);  // Linux "/dev/ttyACM#"
  //myPort = new Serial(this, "/dev/cu.usbmodem1217321", 9600);  // Mac "/dev/cu.usbmodem######"

  textSize(24); // set text size
  textMode(SHAPE); // set text mode to shape

}

void draw()
{
  serialEvent();  // read and parse incoming serial message
  background(200,200,255); // set background color
  lights();

  translate(width/2, height/2); // set position to centre
  scale(2);
  pushMatrix(); // begin object

  float c1 = cos(radians(roll));
  float s1 = sin(radians(roll));
  float c2 = cos(radians(-pitch));
  float s2 = sin(radians(-pitch));
  //float c3 = cos(radians(yaw));
  //float s3 = sin(radians(yaw));
  float c3 = cos(radians(-yaw));
  float s3 = sin(radians(-yaw));
  applyMatrix( c2*c3, s1*s3+c1*c3*s2, c3*s1*s2-c1*s3, 0,
               -s2, c1*c2, c2*s1, 0,
               c2*s3, c1*s2*s3-c3*s1, c1*c3+s1*s2*s3, 0,
               0, 0, 0, 1);

  drawPropShield();
  drawTeensy();
  drawText();
  //drawArduino();


  popMatrix(); // end of object

  // Print values to console
  print(roll);
  print("\t");
  print(-pitch);
  print("\t");
  print(yaw);
  println();
}

void serialEvent()
{
  int newLine = 13; // new line character in ASCII
  String message;
  do {
    message = myPort.readStringUntil(newLine); // read from port until new line
    if (message != null) {
      String[] list = split(trim(message), " ");
      if (list.length >= 4 && list[0].equals("Orientation:")) {
        yaw = float(list[1]); // convert to float yaw
        pitch = float(list[2]); // convert to float pitch
        roll = float(list[3]); // convert to float roll
      }
    }
  } while (message != null);
}

void drawArduino()
{
  /* function contains shape(s) that are rotated with the IMU */
  stroke(0, 90, 90); // set outline colour to darker teal
  fill(0, 130, 130); // set fill colour to lighter teal
  box(300, 10, 200); // draw Arduino board base shape

  stroke(0); // set outline colour to black
  fill(80); // set fill colour to dark grey

  translate(60, -10, 90); // set position to edge of Arduino box
  box(170, 20, 10); // draw pin header as box

  translate(-20, 0, -180); // set position to other edge of Arduino box
  box(210, 20, 10); // draw other pin header as box
}

void drawPropShield()
{
  // 3D art by Benjamin Rheinland
  stroke(0); // black outline
  fill(0, 128, 0); // fill color PCB green
  box(190, 6, 70); // PCB base shape

  fill(255, 215, 0); // gold color
  noStroke();

  //draw 14 contacts on Y- side
  translate(65, 0, 30);
  for (int i=0; i<14; i++) {
    sphere(4.5); // draw gold contacts
    translate(-10, 0, 0); // set new position
  }

  //draw 14 contacts on Y+ side
  translate(10, 0, -60);
  for (int i=0; i<14; i++) {
    sphere(4.5); // draw gold contacts
    translate(10, 0, 0); // set position
  }

  //draw 5 contacts on X+ side (DAC, 3v3, gnd)
  translate(-10,0,10);
  for (int i=0; i<5; i++) {
    sphere(4.5);
    translate(0,0,10);
  }

  //draw 4 contacts on X+ side (G C D 5)
  translate(25,0,-15);
  for (int i=0; i<4; i++) {
    sphere(4.5);
    translate(0,0,-10);
  }

  //draw 4 contacts on X- side (5V - + GND)
  translate(-180,0,10);
  for (int i=0; i<4; i++) {
    sphere(4.5);
    translate(0,0,10);
  }

  //draw audio amp IC
  stroke(128);
  fill(24);    //Epoxy color
  translate(30,-6,-25);
  box(13,6,13);

  //draw pressure sensor IC
  stroke(64);
  translate(32,0,0);
  fill(192);
  box(10,6,18);

  //draw gyroscope IC
  stroke(128);
  translate(27,0,0);
  fill(24);
  box(16,6,16);

  //draw flash memory IC
  translate(40,0,-15);
  box(20,6,20);

  //draw accelerometer/magnetometer IC
  translate(-5,0,25);
  box(12,6,12);

  //draw 5V level shifter ICs
  translate(42.5,2,0);
  box(6,4,8);
  translate(0,0,-20);
  box(6,4,8);  
}

void drawTeensy() { 
  /* Draw Teensy 3.x Board */
  translate(-77.5, -23, 10); // set position of Teensy 3.x
  stroke(40, 0, 60); // set outline colour
  fill(90, 0, 120); // set fill colour
  box(140, 6, 70); // draw Arduino board base shape
  
  /* Draw MCU */
  translate(20, -4, 0); // set position to other edge of Teensy box
  stroke(50, 50, 50); // set outline colour
  fill(0, 0, 0); // set fill colour
  box(40, 2, 40); // draw MCU
  
   fill(255, 215, 0); // gold color
  noStroke();

  //draw 14 contacts on Y- side
  translate(45, 4, 30);
  for (int i=0; i<14; i++) {
    sphere(4.5); // draw gold contacts
    translate(-10, 0, 0); // set new position
  }

  //draw 14 contacts on Y+ side
  translate(10, 0, -60);
  for (int i=0; i<14; i++) {
    sphere(4.5); // draw gold contacts
    translate(10, 0, 0); // set position
  }

  //draw 5 contacts on X+ side (DAC, 3v3, gnd)
  translate(-10,0,10);
  for (int i=0; i<5; i++) {
    sphere(4.5);
    translate(0,0,10);
  }
    
  /* Draw USB Cable */
  translate(-125, -6, -30); // set position
  stroke(40, 0, 60); // set outline colour
  fill(200, 200, 200); // set fill colour
  box(25, 8, 35); // draw USB Connector
  
  /* Draw Headers */
  stroke(0); // set outline colour to black
  fill(80); // set fill colour to dark grey

  translate(60, 19, 32); // set position to edge
  box(140, 21, 6); // draw pin header as box

  translate(0, 0, -64); // set position to other edge
  box(140, 21, 6); // draw other pin header as box
}

void drawText() {
  fill(130, 0, 0, 200);
  text("Madgwick", -50, 60, 30);
  //text("Mahony", -40, 60, 30);
  //text("NXP Motion Sense", -100, 60, 30);
  //text("TEENSY 3.1 &", -90, 60, 30);
  //text("PROP SHIELD", -90, 80, 30);
}
 
Since I have several Teensy's my COM it's over 40 actually, to get serial work I'm forced to use:
Code:
myPort = new Serial(this, Serial.list()[0], 9600);
Using
Code:
myPort = new Serial(this, "COM41", 9600);
not work on my wintel7/Processing3.0.2
 
Since I have several Teensy's my COM it's over 40 actually, to get serial work I'm forced to use:
Code:
myPort = new Serial(this, Serial.list()[0], 9600);
Using
Code:
myPort = new Serial(this, "COM41", 9600);
not work on my wintel7/Processing3.0.2

you may wanted to uninstall unused COM ports
HTML:
1. Right-click “Command Prompt” in Accessories and choose "Run as Administrator”

2. Enter “set devmgr_show_nonpresent_devices=1″ – without the quotes obviously

3. Enter “start devmgmt.msc”

4. In the box that opens, select “Show hidden devices” in the ‘view’ menu.

Now if you expand the section on COM ports, all the COM ports that have ever
 been created will be displayed, the non present ones being in grey. You can
 uninstall away anything that you don’t want (right click, select uninstall).
run as administrator seems important

I removed multiple times old COM ports of unused teensies (on win10)
 
Thanks, I know this, I also have a small app that do the same thing, but nice you posted the procedure, it can be useful for many users.
But I have really a lot of different opened projects and MCU's so my COM's will grow up in few days again, otherwise I will spend hours looking the infamous 'Installing new driver' every time I insert a new MCU!
 
I tried the updated OrientationVisualizer. Can't comment on the COM-Port syntax, but I had to negate yaw to -yaw like @Wozzy mentioned in post #333.
With the current state of the github repo:
Code:
float c1 = cos(radians(roll));
  float s1 = sin(radians(roll));
  float c2 = cos(radians(-pitch));
  float s2 = sin(radians(-pitch));
  float c3 = cos(radians(yaw));
  float s3 = sin(radians(yaw));

I experience two bugs: The visualized yawing of the board is inverted and there are instabilities (sudden "flipovers") when wiggling the board at about +90° and -90° pitch.

if I change that to
Code:
  pushMatrix(); // begin object

  float c1 = cos(radians(roll));
  float s1 = sin(radians(roll));
  float c2 = cos(radians(-pitch));
  float s2 = sin(radians(-pitch));
  [COLOR="#FF0000"]float c3 = cos(radians(-yaw));
  float s3 = sin(radians(-yaw));[/COLOR]
  applyMatrix( c2*c3, s1*s3+c1*c3*s2, c3*s1*s2-c1*s3, 0,
               -s2, c1*c2, c2*s1, 0,
               c2*s3, c1*s2*s3-c3*s1, c1*c3+s1*s2*s3, 0,
               0, 0, 0, 1);

  drawPropShield();
  //drawArduino();

  popMatrix(); // end of object

  // Print values to console
  print(roll);
  print("\t");
  print(-pitch);
  print("\t");
[COLOR="#FF0000"]  print(-yaw);[/COLOR]
  println();
then both bugs no longer show up!

I'd like to remind/inform you all that my choice of having the 3D models non-USB end (Where the 5V buffers are) facing to the right on the monitor with no rotation was an entirely random decision. So when fiddling around with swapping/inverting axis keep in mind the orientation of the boards virtual representation has a "random" initial orientation.
 
You need the latest NXPMotionSense and MahonyAHRS libraries from Pauls GitHub to make it work, not just the new *.ino

@Paul: Please add
Code:
//reset position to zero
  translate([COLOR="#FF0000"]-76.5,4,10[/COLOR]);
to the end of drawPropShield(). I realized that failing to do so will offset subsequent drawSomething() calls because the position is only reset by the beginning of each draw() call.

EDIT: I'm sorry the translate() numbers were wrong, now it's corrected!
 
Last edited:
Yesterday I changed the calibration data format. The calibration app's source was updated last night on github. I still need to build new binaries. Going to improve a few things in the GUI first, and try to fix the crashing on macintosh.

I've seen the "config error FXOS8700" problem a few times. You need to power cycle. The FXOS8700 gets stuck sometimes, and so far I haven't managed to find out why and what to do to get it unstuck without power cycling. Another issue on my to-do list.

The orientation visualizer needs a heading/yaw reset button. A fixed translate isn't the right way, unless everyone in the world orients their monitors in the same geomagnetic direction. But we can assume all monitors are vertical with respect to gravity seen by the accelerometer, so a reset button should only affect yaw/heading.

Edit: also on my to-do list is making sure all these libs and programs are following the same NED right hand rule convention...
 
Last edited:
I've seen the "config error FXOS8700" problem a few times. You need to power cycle. The FXOS8700 gets stuck sometimes, and so far I haven't managed to find out why and what to do to get it unstuck without power cycling. Another issue on my to-do list.

It may not be related, but I added a I2C bus reset
Code:
        // change pin mux to digital I/O
        pinMode(sda,INPUT);
        pinMode(scl,OUTPUT);
        digitalWrite(scl,HIGH);

        int16 count=0;
        while(digitalRead(sda) == 0 && count++ < 10)
        {
            digitalWrite(scl,LOW);
            delayMicroseconds(5);       // 10us period == 100kHz
            digitalWrite(scl,HIGH);
            delayMicroseconds(5);
        }
to my code, to force all I2C devices to reset.
 
They'll be start shipping Monday. Sometime tomorrow I'm going to publish the product pages and ask for feedback here.

Several distributors should start stocking them next week too. :)
 
They'll be start shipping Monday. Sometime tomorrow I'm going to publish the product pages and ask for feedback here.

Several distributors should start stocking them next week too. :)
Congratulations!

Sorry I have not been able to do as much testing here as I would like to have... Too busy with some other Teensy projects.
Is there a complete set of Libraries/programs, that we should all download and test before Monday?

Kurt
 
The orientation visualizer needs a heading/yaw reset button. A fixed translate isn't the right way, unless everyone in the world orients their monitors in the same geomagnetic direction. But we can assume all monitors are vertical with respect to gravity seen by the accelerometer, so a reset button should only affect yaw/heading.

I did something quite similar to this today:

https://github.com/Ben-Rheinland/NX...ientationVisualiser/OrientationVisualiser.pde

Run this, let the visualizer window be in focus (klick somewhere inside the window) and hit "h" on your keyboard.

-Ben
 
They'll be start shipping Monday. Sometime tomorrow I'm going to publish the product pages and ask for feedback here.

Several distributors should start stocking them next week too. :)
great, now we need a Teensy with the right footprint that has build-in Floating point!
 
Bummed out: not been free to do any testing but been keeping up with this thread and reading as much code as I can... finally sat down tonight in front of my desktop to start with some physical testing and my power pack starts smoking as soon as I turn in on! New power pack, turn it on and Teensy starts smoking :(
 
Status
Not open for further replies.
Back
Top