Prop Shield Beta Test

Status
Not open for further replies.
Seriously all I need to do is make APA102 LEDs work with the teensy so should I wait or use the OCTOWS2811 shield? I don't need the gyro or the sound amplifier.
Hi 3D Joy, the octows2811 adapter is set up for three wire leds (such as ws2811/12/b) where data and clock are fed down the same line. APA102 leds are four wire where clock and data are separate wires. Sorry if I have misunderstood.
 
FWIW - Mine works.
I've put hours on my AMP and it is working well from +/- 0.5W speaker and headphone. it is fully socketed to a T_3.2.
@defragster, can you please clarify, exactly how to use the AMP connections? treat me like I don't have a clue (guess what, I don't have a clue). I would like to test the AMP with led output at the same time.
 
Michael, do you mean the 5DCG pin area when you say APA102 connection?
Regarding your test on 'neopixels', was this from the 5DCG pins?

Yes, I meant the 5DCG pins at the back of the shield (with the USB connection being on the top) that bring out pins 11 and 13 translated to VIN (normally 5v), and are presumably there for APA102 (dotstar) lights. I will try it later with wires properly soldered in place to see if I can use the lights on it.
 
Yes, I meant the 5DCG pins at the back of the shield (with the USB connection being on the top) that bring out pins 11 and 13 translated to VIN (normally 5v), and are presumably there for APA102 (dotstar) lights. I will try it later with wires properly soldered in place to see if I can use the lights on it.
I hooked up my dotstar there. What I did was to solder in breakout pins to those 4 pins, then used a servo extension cable, where on one end I swapped the Red and yellow pins in a connector. Plugged one end onto the DCG (not 5 pin), and plugged other end into connector of Dotstar (after I moved it to the input side of the strand). Again not on VCC pin... My dotstar also had power wires coming out, so I hooked it up using the adafruit connector: https://www.adafruit.com/products/368
And power mine with a 5v 4amp wall wart that came with one of my Odroid Xu4's. This all appears to work fine. Note: the strand test also appeared to work without power connected to the strand but the leds were pretty dim...

I have also been tempted to try using a Neopixel instead of a dotstar. But as the external memory also uses the same SPI lines, with a different chip select, not sure if one could get both to work.
 
@defragster, can you please clarify, exactly how to use the AMP connections? treat me like I don't have a clue (guess what, I don't have a clue). I would like to test the AMP with led output at the same time.

@mortonkopf :: Hopefully this does it - I tried it and it worked - was too simple . . .

The AMP pins are the ones on the USB end. The +/- (PLUS/MINUS) inner two pins go to corresponding speaker lines ( I saw 8ohm speaker requirement ) - or to the Active/GND lines on a set of headphones. (These +/- are inside and not used with the outer 5V and GND for simple audio speaker connect.)

Once you have the physical connection you have to enable the electrical drive on those pins in the sketch with Pin_5 Output High - my use on Talkie here:

Code:
 pinMode(5, OUTPUT);
 digitalWrite(5, 1);//Enable Amplified. 
// analogReference(INTERNAL); // drop volume level :: OPTIONAL

If you can't get that to work let Paul know ASAP . . . I just now understand why 'AMP' is on the silkscreen - I read it and used it but never associated it to the label, same for pin_7 and LED - makes sense now. My board has been surely abused as I put wire ends in and out of +/- with no solder too many times on the live circuit and no problems so my board is robust and functional - like all my Teensy's so far way too much loose wire fondling on the live board and no damage yet.

{ < Message to our Sponsor > :: Paul good work on the silk screen TOP and BOTTOM. I was thinking of the end pins - but now see the noted items above in context after days of use - A card/sheet would really tie all that together. }

Paul: Outside the AMP pins are 5V and GND - What's the idea there? Are those for feeding in power to drive the LED's at the other end? Are they common to VIN?
 
Are they common to VIN?

Yes, the 5V pins on both ends are connected to each other and to the Teensy's Vin pin.

Edit:
The AMP pins are the ones on the USB end. The +/- (PLUS/MINUS) inner two pins go to corresponding speaker lines ( I saw 8ohm speaker requirement ) - or to the Active/GND lines on a set of headphones. (These +/- are inside and not used with the outer 5V and GND for simple audio speaker connect.)
Be aware that you should not use the amp output as an input to any active circuitry, because it is a bridged amp configuration. This includes Headphones with noise cancelling, bluetooth and cordless headphones. Basically anything that has either a power input or a battery is not suitable.

Edit2:
When I saw "Led" on the silkscreen I searched for an led in the schematic for a good minute before I realised. Maybe change the Pin description to 5Vbuf or something? Or it was clear to everyone and I was just a bit slow on the uptake :cool:

Edit3: :rolleyes:
I updated the rolling average gyro test program. I will add rolling standard deviation once I remember how to do that recursively and without a 1000-member array. I *plan* to expand this to the accel and mag once it works for gyro and I'll propably change the data types from float to the original raw integers. My intention is to build a useful troubleshooting tool to pinpoint problems with the IMU sensors. Comments and commits welcome

-Ben
 
Last edited:
Thinking out loud, about magnetometer and calibration,

I have played around a little, with a couple of IMUs. As I mentioned, I have an Adafruit BNO055 on one of my boards, which I am just starting to experiment with.

But before this, I have a Sparkfun Razor IMU that was on one of my Hexapods, that I was (will be again soon) running ROS on. I have seen some reports of people having issues getting the magnetometer to calibrate. If I remember correctly the Ros wiki for it, had you do the calibration after you mounted your IMU on your Robot.

I know another person had better luck with hers when she printed a 3d stand and moved the Razor a few inches away from the rest of her electronics and servo motors.

So might be interesting to do some tests to see how much some of the other stuff influences the data, like if the Audio amp is active or you are running the Leds.

Again just thinking out loud.
 
@Paul - pin 2 on octows2811 adaptor seems to be interfered with when also using the prop Shield. I have swapped out the prop shield with attached T3 and replaced with solo T3 and the adaptor runs rainbow seamlessly. Only Pin2 seems to be affected.
 
@Paul - pin 2 on octows2811 adaptor seems to be interfered with when also using the prop Shield. I have swapped out the prop shield with attached T3 and replaced with solo T3 and the adaptor runs rainbow seamlessly. Only Pin2 seems to be affected.

IIRC, on the schematic pin 2 is used by the i2c devices on the prop shield connecting the INT1 pins. I presume this is so the i2c devices can signal if there is I/O available which you can use attachInterrupt to get notified immediately. I tended to use pin 2 as a general switch, since the normal tactical switch is 0.3" long, and would connect directly to ground.
 
Yes, thank you for the link. I remembered it made use of binomial expansion. I'll also rewrite the mean calculation, I have a feeling the current rather crude implementation is prone to rounding errors. OTOH, the data rate from the sensors is slow enough to calculate with double precision... I don't know yet how I'll do this.
IIRC, on the schematic pin 2 is used by the i2c devices on the prop shield connecting the INT1 pins. I presume this is so the i2c devices can signal if there is I/O available which you can use attachInterrupt to get notified immediately. I tended to use pin 2 as a general switch, since the normal tactical switch is 0.3" long, and would connect directly to ground.
I don't see many applications where you'd need both the Prop Shield and the OctoWS adaptor in the same project. I think the days of the WS8211 leds are coming to an end, the new APA102s are much easier to use (IMHO) and can be connected to the Prop Shield directly.

@defragster: thanks for the data dump, yes I can see what I was looking for. Your gyro recovers, mine introduces offset after shaking. That seems to be the cause for the odd behaviour of my Prop Shield.
 
Last edited:
In terms of APA102's supplanting WS2812B's, I dunno. Right now, you can't get things like rings in APA102 format, but for use with the prop shield, it might be rare to use the octows2811 shield as well. One use case might be a big light display that needs some sound using the amplifier.

Also, so far, you don't see things like rings or separate leds in the APA102 format (but for those, you would likely just hook it to the prop shield directly, and not use the octows2811).
 
@Ben - Glad it helped ... if only to show your test was sane and my hardware worked. Would it help to have a millis() runtime indicator on each line for reference? With that I could have saved the whole text file with just a list of timestamps for notes - instead of cutting a few lines - losing context in notepad as I hit "F5" for the time stamp.

@MM - you can buy bulk 5x10 sheets of APA102's at Amazon, and Adafruit has just a few non-linear things so far.
 
@MM: I see your point. Just to be clear, I didn't mean to sound offensive. It's sometimes hard to not sound harsh without nonverbal communication, like in a forum. :)
 
Well, seeing as this is Beta Testing, I put the octows2811 adaptor with the shield as thats what someone might want to do. Best to head these things off at the pass, and put it up in clear bold lettering on the prop Shield page that this is not a solution. Its difficult to determine now how users may have thought of a potential solution to a project brief. Actually, I am enjoying a bit of mix and match, it is giving some ideas.

Re the apa102 vs ws2811, different beasts, both at the moment with a strong role on the 'spectrum' of leds.

Right, back to the workbench.
 
The pressure sensor / temperature sensor on the prop shield seems to work OK.
I used the "MPL3115A2 Barometric Pressure Sensor Library Example Code" from Nathan Seidle/Sparkfun, modified to do some averaging and print out one point every 10 seconds. The pressure reads about 4 millibar lower than the nearby airport reports. Here is a plot of 18 hours of pressure & temp data covering from 10:30 pm last night to 4:30 pm this afternoon. Sensor was indoors; in the morning we opened the windows, causing more temperature fluctuations.
Kst%u00252B-%u00252BCGPress-Temp-1.csv%u00252B3192016%u00252B44327%u00252BPM.jpg
 
Last edited:
Finally got some time today to bring up the prop shield.

String of 72 APA102 LEDs working just fine on the LED output.

Took me too long to realize that I needed to solder another pin for the DAC output to get to shield. Sound is playing but is substantially quieter than I expected. Looking into this now...
 
Well it had to be done -- https://github.com/GremlinWrangler/SaberSounds is a try at doing live synth of a light saber like effect, complete with strike/clash detection. None of this is very pretty but currently the biggest issue is that the audio is easily missable in a quiet room at a foot away from the speaker, so much quieter than those cheesy greeting cards. Unsure if this is my speaker being poorly matched to the amp, or the class D amp just can't do much with the fairly bass heavy audio I'm generating.
 
@GW - Just for reference - How loud is it if you try the Talkie library? on my .5W 8ohm speaker it was over driving it at some points and certainly seemed louder than needed within a foot - To keep it down I was using
analogReference(INTERNAL); // drop volume level
- It powered my headphones fine in either case - they have a volume knob and I turned it down.

Note: With the non-blocking edits made - if you had a finite number of clips (properly formatted) you could just dump them out and cycle between them as you saw fit.
 
My TestGyroscope program has evolved into something useful and is now called SensorStatistics.ino (GitHub link).

Code:
//TODO add description here
//DONE other 8 sensor readings
//TODO "outer loop" to log last n results
//DONE calculate measured mag strength sqrt(mx^2+my^2+mz^2) and add to stats
//DONE calculate measured acceleration strength and add to stats.

#include <NXPMotionSense.h>

NXPMotionSense imu;
const int ledPin = 13;
int ledState = LOW;
elapsedMillis ledMillis = 0;
//elapsedMillis serialMillis = 0;

void setup() {
  Serial.begin(115200);
  while (!Serial) ; // wait for serial port open
  imu.begin();
  pinMode(ledPin, OUTPUT);
  Serial.println("SensorStatistics.ino version 0.1");
  Serial.println("T = time in milliseconds");
  Serial.println("All other lines: First value is mean,");
  Serial.println("second value is variance.");
  Serial.println("Each reading is calculated from 1000 sensor samples.");
  Serial.println("AMag and MMag are absolute magnitude of acceleration");
  Serial.println("vector and magnetic field vector respectively.");
}

int dataCount = 0;
double mean[11];		//means of ax, ay, az, gx, gy, gz, mx, my, mz, accMag, magMag;
double variance[11];	//variances of ax, ay, az, gx, gy, gz, mx, my, mz, accMag, magMag;


void loop() {
  int data[9];			//sensor readings of ax, ay, az, gx, gy, gz, mx, my, mz;
  double accMagnitude;	//Magnitude of acceleration vector
  double magMagnitude;	//Magnitude of magnetic field vector
  double delta;
  
  if (imu.available()) {
    imu.readMotionSensor(	data[0], data[1], data[2],	\
							data[3], data[4], data[5],	\
							data[6], data[7], data[8]	);
	
	//calculate acceleration and magnetic field magnitudes
	accMagnitude = sqrt( pow(data[0],2) + pow(data[1],2) + pow(data[2],2) );
	magMagnitude = sqrt( pow(data[6],2) + pow(data[7],2) + pow(data[8],2) );
	
	//if this is the first round, initialize the arrays
	if (dataCount == 0) {
		for (int i=0; i<11; i++) {
			mean[i] = 0.0;
			variance[i] = 0.0;
		}
	}
	dataCount++; //It's important to do increment _before_ the following computations!
	
	//Update statistics data
	for (int i=0; i<9; i++) {
		delta = data[i] - mean[i];
		mean[i] += delta / dataCount;
		variance[i] += delta * (data[i] - mean[i]); //this accumulates delta^2.
									// Final division by sample count is done
									// after all samples have been collected
	}
	
	delta = accMagnitude - mean[9];
	mean[9] += delta / dataCount;
	variance[9] += delta * (accMagnitude - mean[9]);
	
	delta = magMagnitude - mean[10];
	mean[10] += delta / dataCount;
	variance[10] += delta * (magMagnitude - mean[10]);
	
	//print heartbeat every 50 samples
	if (dataCount % 50 == 0) {
		Serial.print(".");
	}
	
	// if 1k values have been sampled,
	// finish calculations and print results
	if (dataCount >= 999) {
		for (int i=0; i<11; i++) {
			variance[i] /= (dataCount -1);
		}
		
		printStats();
		dataCount = 0;
	}
  }

  
  /*
  // print a time stamp every 20 seconds
  if (serialMillis >= 20000) {
	  serialMillis -= 20000;
	  Serial.print("T    ");
	  Serial.println(millis());
	  Serial.println("");
  }*/
  
  // blink Led
  if (ledMillis >= 1000) {
	ledMillis -= 1000;
	if (ledState == LOW) digitalWrite(ledPin, ledState = HIGH);
	else digitalWrite(ledPin, ledState = LOW);
  }
}

void printStats() {
	Serial.println("");
	
	Serial.print("T      ");
	Serial.println(millis());
	
	Serial.print("AX     ");
	Serial.print(mean[0], 5);
	Serial.print("   ");
	Serial.println(variance[0], 5);
	
	Serial.print("AY     ");
	Serial.print(mean[1], 5);
	Serial.print("   ");
	Serial.println(variance[1], 5);
	
	Serial.print("AZ     ");
	Serial.print(mean[2], 5);
	Serial.print("   ");
	Serial.println(variance[2], 5);
	
	Serial.print("GX     ");
	Serial.print(mean[3], 5);
	Serial.print("   ");
	Serial.println(variance[3], 5);
	
	Serial.print("GY     ");
	Serial.print(mean[4], 5);
	Serial.print("   ");
	Serial.println(variance[4], 5);
	
	Serial.print("GZ     ");
	Serial.print(mean[5], 5);
	Serial.print("   ");
	Serial.println(variance[5], 5);
	
	Serial.print("MX     ");
	Serial.print(mean[6], 5);
	Serial.print("   ");
	Serial.println(variance[6], 5);
	
	Serial.print("MY     ");
	Serial.print(mean[7], 5);
	Serial.print("   ");
	Serial.println(variance[7], 5);
	
	Serial.print("MZ     ");
	Serial.print(mean[8], 5);
	Serial.print("   ");
	Serial.println(variance[8], 5);
	
	Serial.print("AMag   ");
	Serial.print(mean[9], 5);
	Serial.print("   ");
	Serial.println(variance[9], 5);
	
	Serial.print("MMag   ");
	Serial.print(mean[10], 5);
	Serial.print("   ");
	Serial.println(variance[10], 5);

	Serial.println("");
}

The Program calculates the mean and variance of the 9 sensor values and of the magnitudes of acceleration and magnetic field strength.
In an ideal, noise free world, with perfect sensors and with the prop shield being stationary, all variances would be zero, and the magnitudes of acceleration and magnetic field strength would be independent of prop shield orientation. The gyro readings would be all zero, both mean and variance.

This is a sample output from my prop shield (which has a suspected broken gyro). T is a millis() timestamp:
Code:
T      1150063
AX     -7637.22122   182.69951
AY     -1277.98999   83.55501
AZ     355.83183   101.10195
GX     -19.12713   17.90066
GY     14.48048   37.11360
GZ     -2.34635   19.14245
MX     913.69469   79.64517
MY     -195.30831   91.81868
MZ     931.63063   103.74820
AMag   7751.59396   181.01568
MMag   1319.50707   95.08322

The calculation is performed on the raw integer values provided by the sensors, so for conversion to SI units you need to multiply by:
Code:
#define G_PER_COUNT            0.0001220703125f  // = 1/8192
#define DEG_PER_SEC_PER_COUNT  0.0625f  // = 1/16
#define UT_PER_COUNT           0.1f
(Source: NXPMotionSense.h)

The algorithms used do not suffer from catastrophic cancellation when doing the float math and don't require to keep all readings in an array[SampleSize].

So I hope this sketch can give information on the data quality the sensors provide and help with troubleshooting.

Maybe those numbers can be plugged into NXPMotionSense/SensorFusion.cpp to provide even better accuracy and offset cancellation?
 
Hi Ben,

Good stuff,

Thought I would run it and see what type of results I get... Not sure if this helps or not.

Code:
T      548469
AX     -643.66767   52.81129
AY     1215.78378   49.13958
AZ     8315.81181   111.01866
GX     -11.18619   11.80698
GY     13.84985   6.06160
GZ     -7.45946   4.52115
MX     529.05205   50.22975
MY     153.87087   66.25686
MZ     -531.27027   75.43389
AMag   8428.83546   109.93706
MMag   765.47336   62.74468
 
Status
Not open for further replies.
Back
Top