Bluetooth Lightsaber Guidance

Status
Not open for further replies.

marsthrax

Member
I've been working for a few months off and on to make a bluetooth enabled lightsaber. I've had some success, but I'm looking to make some changes that I hope will make it a little better. Right now, I'm using the NRF52 Bluefruit along with a Music Maker Feather Wing (https://www.adafruit.com/product/3436). My main issues there are that I have to use an SD card (which has an annoying tendency to pop out during installation in the hilt), and I'm not a huge fan of the audio library (I keep running into random issues where trying to start playback of a new file causes the device to either lock up or reboot). It also is a bit bulky because I need a separate breakout board for gyro/accelerometer/magentometer (https://www.adafruit.com/product/3463).

In doing more research, I found the props shield, which looks like it has just about everything I need (on board memory that is sufficient for my uses, along with the same motion sensors I'm currently using and ready to connect DotStar LEDs, which I'd like to move to for my emitter). However, the issue with going to Teensy is the lack of a good BLE option (as far as I can see). I'd need a separate shield for the BLE support (and I'm trying to move away from having another board). I'm considering the following, but I'm not sure if it is reasonable:

NRF52 Bluefruit - https://www.adafruit.com/product/3406
Teensy 3.x Feather Adapter - https://www.adafruit.com/product/3200
Teensy Props Shield - https://www.adafruit.com/product/3085
2 x 144/m DotStar LED Strip - https://www.adafruit.com/product/2241
3.7v/10A LiPo battery - http://www.thecustomsabershop.com/P...PCB-Protected-Rechargeable-Battery-P1282.aspx

My main questions are:
1) Can the feather adapter be used to interface the props shield with the feather? It looks like it is designed to use feather wings with a Teensy. I'm relatively new to this, so I don't know if there is a reason it couldn't be used the other way.
2) Does it look like the battery will be sufficient for running 2x 144/m DotStar LED strips? The 144/m is important to get an appropriate resolution for scrolling and a relatively solid color throughout the blade (at least based on what I've been reading from others who have done similar things with NeoPixels).

Any thoughts/comments on the proposed components, or gotchas you can see, would be greatly appreciated! Thanks!
 
I've been working for a few months off and on to make a bluetooth enabled lightsaber. I've had some success, but I'm looking to make some changes that I hope will make it a little better. Right now, I'm using the NRF52 Bluefruit along with a Music Maker Feather Wing (https://www.adafruit.com/product/3436). My main issues there are that I have to use an SD card (which has an annoying tendency to pop out during installation in the hilt), and I'm not a huge fan of the audio library (I keep running into random issues where trying to start playback of a new file causes the device to either lock up or reboot). It also is a bit bulky because I need a separate breakout board for gyro/accelerometer/magentometer (https://www.adafruit.com/product/3463).

In doing more research, I found the props shield, which looks like it has just about everything I need (on board memory that is sufficient for my uses, along with the same motion sensors I'm currently using and ready to connect DotStar LEDs, which I'd like to move to for my emitter). However, the issue with going to Teensy is the lack of a good BLE option (as far as I can see). I'd need a separate shield for the BLE support (and I'm trying to move away from having another board). I'm considering the following, but I'm not sure if it is reasonable:

NRF52 Bluefruit - https://www.adafruit.com/product/3406
Teensy 3.x Feather Adapter - https://www.adafruit.com/product/3200
Teensy Props Shield - https://www.adafruit.com/product/3085
2 x 144/m DotStar LED Strip - https://www.adafruit.com/product/2241
3.7v/10A LiPo battery - http://www.thecustomsabershop.com/P...PCB-Protected-Rechargeable-Battery-P1282.aspx

My main questions are:
1) Can the feather adapter be used to interface the props shield with the feather? It looks like it is designed to use feather wings with a Teensy. I'm relatively new to this, so I don't know if there is a reason it couldn't be used the other way.
Unfortunately that bluetooth adapter cannot be used with a Teensy. It has it's own processor that is similar to the Teensy 3.5/3.6 processors, except it is clocked lower and doesn't have the same amount of memory. All of the feather bluetooth products Adafruit sells have their own processor that you program, and are not made to be used with other processors. Adafruit does have other bluefruit boards that can be attached to the Teensy, just not a board that uses the feather mount directly.

In a more general sense, you can mount a prop shield and feather adapter on the same Teensy. I generally mount the Teensy on top of the Feather adapter, using long male header pins. I mount the Teensy with just the plastic separator to give clearance between the two boards. I use the feather stacking headers on the feather adapter to allow stacking other feather wings (lcd, motor, pwm, etc.) on top. With the pins underneath the Teensy, I then attach the prop shield. If you are careful about spacing, you should have enough length of the male header pin to mount the Teensy to a breadboard or prototype shield.
 
Unfortunately that bluetooth adapter cannot be used with a Teensy. It has it's own processor that is similar to the Teensy 3.5/3.6 processors, except it is clocked lower and doesn't have the same amount of memory. All of the feather bluetooth products Adafruit sells have their own processor that you program, and are not made to be used with other processors. Adafruit does have other bluefruit boards that can be attached to the Teensy, just not a board that uses the feather mount directly.

In a more general sense, you can mount a prop shield and feather adapter on the same Teensy. I generally mount the Teensy on top of the Feather adapter, using long male header pins. I mount the Teensy with just the plastic separator to give clearance between the two boards. I use the feather stacking headers on the feather adapter to allow stacking other feather wings (lcd, motor, pwm, etc.) on top. With the pins underneath the Teensy, I then attach the prop shield. If you are careful about spacing, you should have enough length of the male header pin to mount the Teensy to a breadboard or prototype shield.

Thanks for the reply. I'm a little confused by the response, but maybe I wasn't clear. My understanding is that the props shield doesn't have an on board processor (normally you would use a Teensy as you describe). I'm trying to use the Adafruit feather described above in place of a Teensy (purely to get compact BLE support...if there is a better way to do that going the Teensy route, instead of Adafruit feathers, I'm all ears). My understanding is that the feather teensy adapter linked above is used more like how you describe: to allow a Teensy to interface with Feather wings/shields. I'm trying to determine if you can go the other way (i.e., use a feather as my main processor, and use the adapter to mount a Teensy shield, specifically the props shield in this case).

Does that make sense, or did I misunderstand your response?
 
Thanks for the reply. I'm a little confused by the response, but maybe I wasn't clear. My understanding is that the props shield doesn't have an on board processor (normally you would use a Teensy as you describe). I'm trying to use the Adafruit feather described above in place of a Teensy (purely to get compact BLE support...if there is a better way to do that going the Teensy route, instead of Adafruit feathers, I'm all ears). My understanding is that the feather teensy adapter linked above is used more like how you describe: to allow a Teensy to interface with Feather wings/shields. I'm trying to determine if you can go the other way (i.e., use a feather as my main processor, and use the adapter to mount a Teensy shield, specifically the props shield in this case).

Does that make sense, or did I misunderstand your response?

I didn't really consider using the Prop shield without a Teensy. If you are using the Bluetooth NRF52 chip, note that it does not have a DAT (digital to analog converter) to do sound output. So, you wouldn't be able to use the speaker output of the prop shield directly. You might be able to feed a PWM pin into a capacitor to simulate a DAT pin for even lower quality audio output.

Also note, 2 of the pins that the prop sield uses are not brought out by the feather adapter:
  • Pin 2: used as the interrupt pin for the motion sensors;
  • Pin 7: use to enable the level shifter for the WS2812B and APA102 LEDs.
 
I didn't really consider using the Prop shield without a Teensy. If you are using the Bluetooth NRF52 chip, note that it does not have a DAT (digital to analog converter) to do sound output. So, you wouldn't be able to use the speaker output of the prop shield directly. You might be able to feed a PWM pin into a capacitor to simulate a DAT pin for even lower quality audio output.

Also note, 2 of the pins that the prop sield uses are not brought out by the feather adapter:
  • Pin 2: used as the interrupt pin for the motion sensors;
  • Pin 7: use to enable the level shifter for the WS2812B and APA102 LEDs.

Gotcha, makes sense. I might just try it and see what happens. I don't think the interrupt pin will be a huge deal for me (right now I'm just checking it in my loop), but Pin 7 might. Is it enabled by default, or would I need access to that pin in order to enable the 5v line for the APA102 LEDs? I guess I could jump it if necessary, but it would be nice not to have to.

Alternatively, perhaps it is cleaner/easier to just use the Bluefruit LE UART (https://www.adafruit.com/product/2479) instead and just go straight to Teensy instead of the NRF52 feather. It doesn't get away from having another board, but it sounds like it would make it easier to use the props shield.
 
Alternatively, perhaps it is cleaner/easier to just use the Bluefruit LE UART (https://www.adafruit.com/product/2479) instead and just go straight to Teensy instead of the NRF52 feather. It doesn't get away from having another board, but it sounds like it would make it easier to use the props shield.

Or possibly use the SPI version of the bluetooth BLE device: https://www.adafruit.com/product/2633.

Note, from scanning the pages, it looks like neither of the devices support traditional bluetooth 3.x (traditional bluetooth and BLE are completely different), so make sure whatever you are using to control the light saber talks BLE.

FWIW, I haven't played with bluetooth in awhile, and my phone at the time was only traditional bluetooth. I did have some things I wanted to do with bluetooth, so I have both the UART and SPI versions as well as the HC-05 devices I used previously, all waiting for me to get motivated to use them. :D
 
Or possibly use the SPI version of the bluetooth BLE device: https://www.adafruit.com/product/2633.

Note, from scanning the pages, it looks like neither of the devices support traditional bluetooth 3.x (traditional bluetooth and BLE are completely different), so make sure whatever you are using to control the light saber talks BLE.

FWIW, I haven't played with bluetooth in awhile, and my phone at the time was only traditional bluetooth. I did have some things I wanted to do with bluetooth, so I have both the UART and SPI versions as well as the HC-05 devices I used previously, all waiting for me to get motivated to use them. :D

Yep, I know. I am planning to use BLE (my phone supports it, and I've been using it in my current build). The goal is allow for configuration over BLE (changing sound fonts, blade color), as well as to get sensor information out (orientation/clash detection, hopefully to enable some interesting phone app features). I'm more of a software guy, so after I have a working build I want to focus on a phone app. Is there a significant advantage to SPI over UART? It seems like SPI allows me to use interrupts (which is nice), but UART doesn't?
 
Yep, I know. I am planning to use BLE (my phone supports it, and I've been using it in my current build). The goal is allow for configuration over BLE (changing sound fonts, blade color), as well as to get sensor information out (orientation/clash detection, hopefully to enable some interesting phone app features). I'm more of a software guy, so after I have a working build I want to focus on a phone app. Is there a significant advantage to SPI over UART? It seems like SPI allows me to use interrupts (which is nice), but UART doesn't?

Under Teensy, you would need to use either Serial1 or Serial2, since those 2 UARTs have an 8 byte buffer for receiving characters when interrupts are disabled. In addition, you would need to use hardware flow control to prevent the Teensy from sending data when the bluetooth device is not ready to receive it and vice versa. The CTS pin on the Teensy is fixed depending on the serial device (pin 18/A4 or 20/A6 for Serial1 and pin 23/A9 for Serial2). The RTS pins on the Teensy can be any pin (and you would need to swap these when hooking up the BLE device). You have to configure the Serial device to use hardware flow control. If you only have a little bit of data, you probably can do without flow control on the UART device, but it isn't recommended.

With SPI, you don't have to worry about getting the UART speed correct. So, to my way of thinking, there is less fiddling to get the SPI stuff correct, assuming you use the right pins (by default, you want 13 [SCLK], 12 [MISO], and 11 [MOSI], plus other pins for CS, IRQ, RST).
 
It seems like SPI allows me to use interrupts (which is nice), but UART doesn't?

UART is probably best for BLE. It's simpler and Teensy has buffering for both reading and writing.

Since you're using Dotstar (APA102) LEDs, I would not recommend using another SPI device if you can avoid it. The prop shield does have an enable pin which you can use to make this work if really needed, but best to just keep things simple. If you aren't using any other SPI chips or boards, you can just leave the LEDs enabled.

If you were using NeoPixel (WS2812B) LEDs, your choice on the BLE might be different, depending on which library you choose for the LEDs. With Adafruit NeoPixel library and with the default WS2812B driver in FastLED, interrupt are blocked while updating the LEDs. That's very undesirable if you have a UART BLE module that might decide to send you data during the LED update. You choice on the software side would be to instead use the WS2812Serial library, or use FastLED's driver for WS2812Serial. The downside is WS2812Serial uses much more memory, which generally isn't an issue on Teensy 3.2, but it can limit you on Teensy LC. The hardware approach would be to use a SPI BLE module, which puts you in control of when the communication happens between the BLE & Teensy.

Fortunately, APA102 / Dotstar LEDs don't have these special timing requirements. Updating the LEDs doesn't disable interrupts, so you're able to receive incoming data from the UART BLE. I just mentioned this issue mostly for folks who might later find this thread and happen to have WS2812B LEDs.
 
All good information, thanks both of you for the details. Are there any significant advantages to the Neopixels over the Dotstars? I looked at the Dotstar comparison (https://learn.adafruit.com/adafruit-dotstar-leds/overview), and it seems like the only applicable down side is that it takes 4 wires instead of 3. They seem to be more popular in general though.

It sounds like Dotstars make more sense (no need to disable interrupts, actually slightly cheaper, let me use UART instead of SPI, making it simpler). So aside from the extra control line, I don't see any real down side. Is there anything I'm missing before I bite the bullet? Along those lines, are there any issues with driving 2x 144/m Dotstar (or NeoPixel) strips through the props shield with a 3.7v/10A/3200mAh battery?
 
All good information, thanks both of you for the details. Are there any significant advantages to the Neopixels over the Dotstars? I looked at the Dotstar comparison (https://learn.adafruit.com/adafruit-dotstar-leds/overview), and it seems like the only applicable down side is that it takes 4 wires instead of 3. They seem to be more popular in general though.

It sounds like Dotstars make more sense (no need to disable interrupts, actually slightly cheaper, let me use UART instead of SPI, making it simpler). So aside from the extra control line, I don't see any real down side. Is there anything I'm missing before I bite the bullet? Along those lines, are there any issues with driving 2x 144/m Dotstar (or NeoPixel) strips through the props shield with a 3.7v/10A/3200mAh battery?

There are a few minor advantages to neopixels over dotstars:
  • You can get Neopixels in some formats that Dotstars don't provide, such as rings, small matrix, etc.
  • I don't recall if dotstars can officially run at 3.5v or if you need 5v (the normal neopixels can run at 3.5-5.5v, so you can power them directly off of a lipo battery without having to do level shifting). For 288 LEDs, you may have to worry whether the battery can support that much power. Typically I find for indoor settings, I tend to keep the light levels real low (max of 30 for the R, G, and B levels summed together). For 64 LEDs, this translates to about 75ma.
  • If you need white light, there are RGBW neopixels where the 4th LED is white of a specific color temp. Note you can't intermix RGB and RGBW leds in the same string.

There are of course downsides:
  • The big one is having a very narrow timing window, which tends to mean the Teensy has to disable interrupts while it is writing the string;
  • There are now multiple makers of neopixels, and even the main maker has varied things over time, so you may have color compatibility issues if you combine strands from different manufacturers. I've also had some issues with 3rd party WS2812B and WS2813 LEDs where things don't just work right (the Adafruit neopixels have always worked for me, providing I feed the neopixels 3.5v or level shifted 5v of power).
 
There are a few minor advantages to neopixels over dotstars:
  • You can get Neopixels in some formats that Dotstars don't provide, such as rings, small matrix, etc.
  • I don't recall if dotstars can officially run at 3.5v or if you need 5v (the normal neopixels can run at 3.5-5.5v, so you can power them directly off of a lipo battery without having to do level shifting). For 288 LEDs, you may have to worry whether the battery can support that much power. Typically I find for indoor settings, I tend to keep the light levels real low (max of 30 for the R, G, and B levels summed together). For 64 LEDs, this translates to about 75ma.
  • If you need white light, there are RGBW neopixels where the 4th LED is white of a specific color temp. Note you can't intermix RGB and RGBW leds in the same string.

There are of course downsides:
  • The big one is having a very narrow timing window, which tends to mean the Teensy has to disable interrupts while it is writing the string;
  • There are now multiple makers of neopixels, and even the main maker has varied things over time, so you may have color compatibility issues if you combine strands from different manufacturers. I've also had some issues with 3rd party WS2812B and WS2813 LEDs where things don't just work right (the Adafruit neopixels have always worked for me, providing I feed the neopixels 3.5v or level shifted 5v of power).

Makes sense. For my case, the strip is all I care about, and I assume the fact that AP102s (as far as I have read) require 5V shouldn't matter because the prop shield has a 5V pin intended for that. Is there a max current I can put through that pin? The battery I'm using is 10A, and if I'm understanding everything correctly (forgive me, I haven't done much with electronics before this project) the max draw on 244 APA102s at full white would be just shy of 15A (so I won't be able to do that, which is fine). Since it is a 3200mAh battery, presumably I could get ~1 hour of continuous runtime if I keep everything at less than 20% brightness (50 or less). That would put me at about 3A continuous drive.
 
On a semi-related note, is there a fritzing file for the prop shield? I've been looking, but can't find one. I was hoping to diagram it out to make sure the connections all made sense.
 
Status
Not open for further replies.
Back
Top