Arduino Lightsaber

Ok, I will watch for that. :slight_smile:

Thanks! It's interesting you should ask that. I'm working on integrating an ADXL335 3-axis accelerometer right now.

Jakesoft, your video is awesome. Just a couple of doubts.

Did you programmed the accelerometer to work as an interrupt?
If so, how did you managed to get the WT588D to work without the delay functions?

kingale:
Jakesoft, your video is awesome. Just a couple of doubts.

Did you programmed the accelerometer to work as an interrupt?
If so, how did you managed to get the WT588D to work without the delay functions?

I find your lack of faith disturbing. :wink:

Seriously, though, polling for acceleration data at a rate of ~10ms seems to be enough for accurate swing sensing in the experimentation I've done, so no interrupt needed for that. The mechanical clash sensor is still present in the design and is on an interrupt for crisp, immediate clash response.

For reference, here is a link to the latest breadboard video with the accelerometer added:

hello friend, very good your project, like some help because I am doing a similar, would like to contact? andrecruzchagas@gmail.com

thanks

-------Note: the boards contained in this post are now obsolete and links to them have been removed, though for continuity the remainder of the poast has been left largely unedited. New and improved versions are imminent and links to them will be posted once they have passed the field test phase-------

Great thread jakesoft, your a very cool dude for sharing your code with everyone.

As it happens, I've recently finished working on some circuit artwork for an almost identical setup (although it didn't start out that way). Funnily enough I've only been working on the hardware aspect and hoped to find some software for it later. It was my ever tightening word searches for relevant code which eventually brought me here.

I think I'm going to join in with your sharing spirit and leave links below to download the folders that contains all of the circuit artwork for anyone who wishes to etch their own.

I have amended the below information to reflect recent updates and additions I have made the layout.

I have updated the design to incorporate all elements onto one PCB so have adjusted the following system description (and a few other things in this post) to match the updates.

There are now two PCB variants which I'm releasing for public use, one for direct speaker driving via the PWM output and one for external amplification via the DAC output.

Note: Sorry, no code to go with them yet. I am attempting to tackle it but coding isn't my area of expertise so can't say when it will be included.

Here is the new brief description of the system.

  1. PSU section.

A 5v fixed LM1117 SOT-223 regulator has been placed on the input rail so any wall wart can be used with output voltages ranging from 5~12v.

Following that is an integrated Li-Po charging circuit using the MCP73833-AMN-UI IC which has been balanced to work with a 3.7v 2.3Ah RCR123A cell.

The positive rail from the charger IC has been made open circuit and solder pads added for an "isolator" switch to disconnect it from the battery when not charging to prevent any reverse voltage issues from occurring which may harm the charger IC.

The CR123A cell itself sits in a PCB mountable holder which is situated on the blank side of the PCB and has a direct rail via a power mosfet to a single 3v 1w LED and a footprint for a 2w resistor has been placed in series with it.

This system uses two 5v devices which are the pro mini and WT588D. As such I've included 5v .5A micro boost buck module footprints to both variants and routed them in parallel in order to provide them both with the correct Vf and current (links to the module can be found in the BOM contained in the folder).

Footprints for mounting both an arduino pro mini and WT588D-16p have been included on both variants for easy assembly using standared straight header pins.

Sitting under the pro mini is an LP2992 3v3 250mA fixed voltage regulator which provides the correct voltage to the MMA8452Q accelerometer sitting up front (the MMA8452Q has two level shift resistors on board so didn't need to add any on the circuit).

The devices on/off state control pin has been tied to the arduino in order to take advantge of this function. It could have been tied to the input pin but would have drawn current even when everything else was asleep which is inefficient so opted for this setup instead.

PWM variant sound:

This board breaks out the PWM + - pins of the WT588D for direct speaker driving and is a little shorter than the DAC variant overall.

DAC variant sound:

The WT588D's DAC output along with the voltage output from a second micro 5v boost buck (rated @1A) have been broken out to drive an external amplifier up to 3w. This does however mean that the PCB is a bit longer overall than the PWM variant.

Note: Although it looks like the SMD stuff is suited for a higher skill level, it's totally possible to solder them all on by hand.

The trick is to wet one of the the pads with a smidgen of solder first. Not enough to make a mound as it needs to be pretty flat but thicker than just tinning.

Slather on some flux or rosin once the pad has cooled (I like no clean liquid flux) and carfully put the component in place taking care to note it's orientation should it have one.

The iron should be set to a mid/high temp if you have that level of control and then using a pair of tweezers, hold the componant in position while you place the tip of the iron (with a little pressure) onto the IC leg resting on the pre soldered pad for two seconds and let cool.

In the case of 0805s, the tip wants to be partly on the pad and partly against the componamt terminal to allow the solder to flow underneath it a little. The solder should have a nice slope leading from the top of the chip to the edge of the pad rather like a quarter pipe. Don't panic if you over do it a little but just be sure to check for short circuits.

It will now be stuck firmly enough for you to finish the job without holding it.

Lastly, I've only gingerly started to look at learning c++ due to numerical dyslexia. Unlike it's more obvious cuosin, this one likes to occasionally do random things to numbers and letters (not often but reading also sufferes) which can sometimes go unnoticed.

For most areas of my life it's just an annoyance but it doesn't take a genius to realise that this is really bad news for coding. Just thinking about having to track down a dodgy digit in 100 lines of code brings the phrase "needle in a haystack" springing to mind but in my case, this time it really means it.

But, rather than put a request out there for free help to write code, I'd be up for trading a PSU board with all the SMD components pre-soldered if anyone would like to help me out (I have just enough parts to let one go), or even better, knock heads with someone in order to come up with a definitive "home brew" hilt fx package for everyone.

I nearly collapsed when I found out how much purpose made hilt fx boards were on their own (like the Biscotte) let alone having one fitted. I know some people will only see the object and not the money but that kind of pricing totally takes the pi**

Just in case anyone is interested I've attached a pic of the lightsaber I'm making too.

Whoa, hey that is pretty similar to my setup! I like the core logic board. I made almost exactly the same thing out of strip board on my last build! I wish I had the skills to make something more like your version.

You seem to have exactly the opposite strengths to my own. When it comes to the software, I'm literally a pro. The Arduino libraries are so well documented that I can usually figure out how to do what I want pretty easily in code, but I'm weak on the hardware side. I understand circuit theory, but I have to read up a lot on components and stuff when I do a project. The thought of etching circuit boards with exotic chemicals is daunting to me, but may not be for others.

Nice contribution to the thread. Thanks for sharing!

JakeSoft:
Whoa, hey that is pretty similar to my setup! I like the core logic board. I made almost exactly the same thing out of strip board on my last build! I wish I had the skills to make something more like your version.

You seem to have exactly the opposite strengths to my own. When it comes to the software, I'm literally a pro. The Arduino libraries are so well documented that I can usually figure out how to do what I want pretty easily in code, but I'm weak on the hardware side. I understand circuit theory, but I have to read up a lot on components and stuff when I do a project. The thought of etching circuit boards with exotic chemicals is daunting to me, but may not be for others.

Nice contribution to the thread. Thanks for sharing!

Hey, no problem :slight_smile:

Actually, do you fancy a trade?

Board layout and fabrication is fun for me and I'd happily make you some boards up at my expense in return for some of your coding.

Talking of board layout. An unexpected update for the design app I use has allowed me to consolidate all the elements together on one board :slight_smile:

I'm designing a couple more as this one isn't generic enough to let loose on the public. One will be for direct PWM speaker driving via the WT588D, the other will have an output port for external amplification and include the 5v 1A boost buck module.

making a few more small modifications.......

Great project, JakeSoft! I've actually started my own saber project, but am struggling with the accelerometer code. Do you have your sketch published anywhere, or would you be willing to share some snippets of yours that detail the accelerometer readings?

JakeSoft:
How did you get the one-line serial mode to work? I sort of had the opposite experience to what you had: I tried 1-line mode first but then abandoned it when SugarBombs posted working 3-line code.

Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

void WT588D_Send1(byte addr) {
    digitalWrite(wt_scl, LOW);
    delay(5);

    for(int i = 0; i < 8; i++)  {
        digitalWrite(wt_scl, HIGH);
        if(bitRead(addr, i)) {
            delayMicroseconds(600);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(200);
        } else {
            delayMicroseconds(200);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(600);
        }
    }

    digitalWrite(wt_scl, HIGH);
    delay(100);
}

llluis:
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

void WT588D_Send1(byte addr) {

digitalWrite(wt_scl, LOW);
    delay(5);

for(int i = 0; i < 8; i++)  {
        digitalWrite(wt_scl, HIGH);
        if(bitRead(addr, i)) {
            delayMicroseconds(600);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(200);
        } else {
            delayMicroseconds(200);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(600);
        }
    }

digitalWrite(wt_scl, HIGH);
    delay(100);
}

Hey, that's helfpul! I can't wait to try this out. Two less wires to connect up. If I'm not mistaken, this may actually even be faster than 3-line mode because the delays are much shorter. So, potentially less time with the Arduino locked up on sending the commands. Well, assuming that last 100ms delay isn't really necessary. Is it?

llluis:
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

void WT588D_Send1(byte addr) {

digitalWrite(wt_scl, LOW);
    delay(5);

for(int i = 0; i < 8; i++)  {
        digitalWrite(wt_scl, HIGH);
        if(bitRead(addr, i)) {
            delayMicroseconds(600);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(200);
        } else {
            delayMicroseconds(200);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(600);
        }
    }

digitalWrite(wt_scl, HIGH);
    delay(100);
}

I can confirm that this code has the awesome sauce. I tried it out and it worked right away. To improve performance, the last 100ms delay can be reduced to 2ms and it still seems to work just fine.

Jake, your diagram shows the Vcc pins from the sound board and the arduino connected. yet you have both units receiving raw power as well. The Ardunio pro mini has an integrated regulator to take up to 12v of unregulated power. And they recomend to use the Vcc pin only if you have regulated power. and you do have a v regulator in your specs, not on the diagram tho. So,.. What gives? why connect the Vcc AND the raw inputs? And also why short the Vcc's tween the 2 units? What model N MOSFETs di you use to drive your LEDs? please and thanks!

Hi billpealer, the 5V on the RAW pin is powering the Arduino Pro Mini. This then get regulated to 3.3V by the on board regulator. Because of this, VCC acts as an output sourcing 3.3V, which supplies 3.3V to the VCC on the WT588D. VCC on the WT588D powers the flash chip (3.3V) the VDD powers the WT588 chip itself.

(Of course someone can correct me on this.)

purgedsoul:
Hi billpealer, the 5V on the RAW pin is powering the Arduino Pro Mini. This then get regulated to 3.3V by the on board regulator. Because of this, VCC acts as an output sourcing 3.3V, which supplies 3.3V to the VCC on the WT588D. VCC on the WT588D powers the flash chip (3.3V) the VDD powers the WT588 chip itself.

That's about right. There are many ways to wire this so it'll work, but I did notice that higher voltages on the VDD pin make it louder, so that probably is powering the WT588D chip.

It's a bit clunky, but as it's my first schematic, it'll do for now.

I'm also going to make another version and swop out the accelerometer for the one mentioned earlier.

Arduino fx system - Canobi.pdf (734 KB)

Hello! Mosfet its only to turn on the Saber LED (Luxeon, cree..) right? Because the arduino output is 500mah and we need more ?

The sensor SW 18020p and SW 200D can be read with arduino right? and sensing to the WT588D chip play a sound ?

Thankyou! Waiting to my order on ebay! :stuck_out_tongue:

Hi raphax

I can answer a couple of those.

Yes, the arduino only controls the mosfet gate, the LED is powered directly from the battery.

Clash sensors function in the same way as any pushbutton but have different activation parameters.

Here is some interesting info I found regarding the SW18020p and how it works:

Have you tried using the accelerometer's "tap" function with a high threshold instead of the clash sensor?

kingale:
Have you tried using the accelerator's "tap" function with a high threshold instead of the clash sensor?

Yeah, I did try something like that. It even worked in so far as it would detect clash events correctly. However, the response time was way too slow. There was noticeable lag between the impact and when the LED would flash and the clash sound would play. Putting a clash sensor on an interrupt is still the easiest way that I've found to get good performance without having to overthink the code too much.

I am running a Pro Mini at 8MHz, though, so maybe the 16 MHz version would close the gap so it wasn't too noticeable. It's also possible that someone may able to come up with code that's better at managing the accelerometer data at a higher rate than mine does; I only poll for data approximately every 10 ms.
You may have better luck, so by all means, go ahead and try it. Let us know how it works out.

I am running a Pro Mini at 8MHz, though, so maybe the 16 MHz version would close the gap so it wasn't too noticeable. It's also possible that someone may able to come up with code that's better at managing the accelerometer data at a higher rate than mine does; I only poll for data approximately every 10 ms.
You may have better luck, so by all means, go ahead and try it. Let us know how it works out.

I tried using the tap function with the mma845x and a 16Mhz arduino nano. I didn't experience any lag, so you were right. The problem was when i combined the code and tried to use the WT588D in three line mode with the set up. I used an interrupt as an on/off switch but when i turned it on, the accelerometer went crazy and started sending multiple "tap" signals... I also tried to isolate the button and the problem continued. So maybe it's a code issue.

Jakesoft, just another question. I'm having issues getting a background hum to work. I used the repeat mode you shared before in the time loop but still no hum.

Turn on repeat mode
WT588D_Send_Command(0xF2);

//Begin playlist 0
WT588D_Send_Command(0x00);