Showing posts with label i2c. Show all posts
Showing posts with label i2c. Show all posts

03 March 2014

LightWalker 2.0

My first shot at LightWalker was way more involved and elaborate than I originally planned and definitely more involved on the hardware side than I thought I could deal with. But, it did actually work. Mostly.

I don't know how most people face difficult problems they've never handled before, but whether it's rebuilding an engine, repairing a hole I put in the wall, or something like LightWalker, I usually do it once just to figure out what the hell is going on and then immediately do it again to do it correctly. Now, I'm definitely still a noob when it comes to hardware and embedded stuff, so I'm not going to claim that I'm doing everything correctly here, but I do think it's a step in the right direction.

Main complaints from LightWalker 1.0
  • Difficulty producing desired results in the RGB color space
  • Lack of memory available
  • Limited frame rates possible with the Arduino Mega (ATmega2560)
  • Overall bulkiness of the unit
  • My own half-baked software design

So, here's LightWalker 2.0 so far:
Initial  build of LightWalker 2.0
  • Hardware
    • Teensy 3.1 (32-bit ARM Cortex m4, 72Mhz, 256Kb Flash, 64Kb RAM)
    • Schmartboard SMT to DIP board sporting a TI PCA9546A I2C multiplixer allowing communication to four ADXL345 ±16 g accelerometers
    • Bluefruit EZ-Link bluetooth
    • Electret microphone
  • Software
    • Moved away from Cool Neon and Chris De Vrie's TCL Arduino library for controlling lights and to FastLED 2.1
    • I also removed my MSEQ7 shield and am doing audio processing in software now. This allows me to do a bit of max/min adjustment on the fly instead of having to cover the microphone in hot glue to deal with being within a half mile of an 85k watt stereo.
This is currently all on a blank perf board and wire wrapped together. Not sure if I'm going to just throw some solder on top of it and call it good or re-do on a better breadboard PCB or what. And, this is also still controlled/configured by a revamped android application running on Android KitKat.

As you can see, this is way more compact than an Arduino mega with two shields and a separate bluetooth breakout board. Hell, the whole thing is smaller than the mega alone! But, the main advantage to this new unit is speed and lighting effects.

Before I get into the speed portion, I've gotta say that using FastLED to work in the HSV color space is amazing. I've only touched the surface of what you can do, but it is extremely simple to create smooth and subtle LED effects when working with HSV. You can easily create transitions between colors instead of just doing a hard switch from one to the other. And making things smooth and subtle is the name of the game when it comes to LEDs. Otherwise they hurt your eyeballs. 

Now for the speed thing. This is kinda interesting to me...


configuration/modeequalizer (fps)gravity* (fps)sparkle* (fps)pulse (fps)bubble* (fps)rainbow* (fps)zebra* (fps)
LightWalker 1.0, arduino, TCL877189316n/an/a
LW 2.0, arduino, fastLED 236715135162532
LW 2.0, arduino, fastLED 2.135715135162533
LW 2.0, teensy 3.1, FastLED 2988681173908573
LW 2.0, teensy 3.1, FastLED 2.1250124130465134123100
[Update] Note that all of these tests are done against a strand of 352 P9813 driven RGB LEDs (AKA Total Control Lighting)

Couple things to keep in mind:
  • The equalizer mode on the arduino is using hardware to calculate "loudness". The teensy configurations are using software to calculate the same. Obviously something is off with the equalizer stuff in 2.0 as the frame rate was chopped in half when it should have stayed the same or gone up. It's on my to-do list to look into it.
  • FastLED 2.0 does *not* officially support the P9813 chip that I'm using in my Cool Neon TCL strands, but I was able to port the 2.1 code for that chipset to the 2.0 release. That's what my FastLED 2 testing was run against. That was not an official FastLED 2 release.
  • The different modes obviously do a bunch of different lighting effects and some are more complex and slower than others.
  • The modes marked with an asterisk read data from four different accelerometers and perform calculations  on the data *for each frame*. This is why the pulse mode is so much quicker than the others, it is not reading any sensor data for it's effects.
Some conclusions
  • The obvious result is that it pays to be on the new hardware and on FastLED 2.1. Now hopefully 2.1 is officially released soon...
  • I think it's fairly interesting that the arduino based platform didn't benefit from the move to FastLED 2.1 from a speed perspective. The no-sensor-reading pulse mode did see about a 40% increase on the TCL -> FastLED 2 move, so my guess is that the sensor reading and calculations I'm doing are so slow on the arduino that the LED writing speed is negligible.
  • The 100+ average frame-rate is really really nice for doing smooth LED transitions and effects. I'm really happy to see this kind of improvement and am already adding new effects based on the new abilities.
The code is up at https://github.com/gerstle/LightWalker if you want to check it out. Think that's all I've got for now, but now that I have two full LightWalker controllers...

28 May 2013

She has a heart

This is not quite everything I wanted to get accomplished this weekend, but I did make some solid progress. All the electric components are soldered and working! In the process, I realized that I know nothing about soldering. Best lesson? Keep your soldering iron tip clean!

It took me quite a while to get everything drawn out and even longer to get it all soldered and working, but it was a great learning experience and super fun.

This is the entire unit... arduino, i2c multiplexing shield, equalizer shield, bluetooth breakout board, 4 ADXL 345 accelerometers, and an electret microphone. Only things missing from the shot are the 450 LED pixel points, the 6v 12Ah sealed lead-acid battery, and another battery to run this unit (I'm going to run the lights and controller off of separate batteries).

LightWalker's guts.



This is the i2c multiplexing shield with TCA9548A i2C switch. It allows me to hook up the 4 accelerometers that all have the same i2c hardware address to a single i2c line. The board can handle up to 8 units with the same address, so maybe I should do a spider for next year?
The big trick here was that I hooked up my SCL and SDA lines to where they were printed on the board but failed to realize that the board didn't connect those to the arduino's analog 4 and 5 pins like my board needed. I think newer boards would work through the stackable headers and the SCL and SDA holes printed on the board. Once I realized I was working with an older setup and re-routed them, all was good.


bottom of the i2c multiplexing shield
top of the i2c multiplexing shield















Here's the equalizer shield. I'm only using one of the  MSGEQ7 chips on here for a single audio channel, so it's kind of overkill, but it does give me a nice stackable shield and pins to hook the microphone and bluetooth to.


equalizer shield w/
electret microphone














And, just for completeness, the arduino compatible shield from seeedstudio...

the seeedstudio arduino
compatible board I'm using


19 March 2013

multiplexing working!

The TCA9548A soldered onto a
Schmartboard w/ male pins
Surfing, scuba diving, swimming with turtles, and downing boat drinks in Hawaii must go a long way towards making one smart and productive cause I've only been back from Hawaii for 24 hours and I've already finished a book (Something Wicked This Way Comes), got 8 hours of sleep, worked for 8 hours, ate two tacos, and gotten my multiplexing chip working!

I posted a while back about getting the TCA9548A I2C multiplexing chip and the Schmartboard and just now finally got it all soldered up and tested it out. The soldering was ridiculously easy for a chip this size. Got to hand it to Schmartboard for finding a slick, easy to use design. Literally took me 10 minutes from start to finish including heating up the iron and soldering a test chip. In retrospect, I should have soldered female connections onto this board or even gotten the Schmartboard arduino shield, but I'm definitely a noob and this is what happens. It'll work for now.

The longest part of the whole ordeal was figuring out how to wire the thing up, but in the end, I got it all working and was even able to hookup two ADXL-345 accelerometers to it and get readings from both. Again, the main point of this chip is that I want to hook 4 accelerometers up to my board over I2C but all the accelerometers have the same I2C address hardcoded. So, with the TCA9548A, I can control which one I'm talking to at any point in time.

Here's the sample Arduino sketch I threw together to demo things:
#include <Wire.h>
#include <ADXL345.h>
#include <SPI.h>
#include <TCL.h>

#define TCA9548AADDR 0x74 //1110100

// For now, one object works...
ADXL345 adxl;
unsigned long lastStatus = millis();
double xyz[3];
 
void setup()
{
    Serial.begin(9600);

    Wire.begin();

    Serial.print("initing adxl0...");
    selectI2CChannels(0x1);
    adxl.powerOn();
    Serial.println("done");

    Serial.print("initing adxl1...");
    selectI2CChannels(0x2);
    adxl.powerOn();
    Serial.println("done");
}
 
void loop()
{
    unsigned long currentTime = millis();
    bool printStatus = false;

    if (currentTime > (lastStatus + 500))
    {
        printStatus = true;
        lastStatus = currentTime;
    }

    selectI2CChannels(0x1);
    adxl.getAccelemeter(xyz);
    if (printStatus)
        printXYZ("ONE");
 
    selectI2CChannels(0x2);
    adxl.getAccelemeter(xyz);
    if (printStatus)
        printXYZ("TWO");
}
 
void selectI2CChannels(int channels) 
{
    Wire.beginTransmission(TCA9548AADDR);
    Wire.write(channels);
    Wire.endTransmission();  
}

void printXYZ(char label[])
{
    Serial.print(label); Serial.print(": ");
    Serial.print(xyz[0]); Serial.print(",");
    Serial.print(xyz[1]); Serial.print(",");
    Serial.println(xyz[2]);
}
Credit for being able to figure out the code and switch between the two accelerometers should go to Kerry Wong as the basis for my test is from his blog.

I'm pretty excited about things at this point, they are really starting to come together. I think I'm past due for a cool video update showing a lot of what I've done come together. Back with that as soon as I can...