Go Down

Topic: Arduino Lightsaber (Read 393332 times) previous topic - next topic

Canobi

#45
Sep 20, 2015, 10:33 pm Last Edit: Sep 22, 2015, 04:31 pm by Canobi
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 :)


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 :)




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.


<edit> making a few more small modifications.......

nphillips

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?

llluis

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.

Code: [Select]

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);
}

JakeSoft

#48
Oct 03, 2015, 04:43 pm Last Edit: Oct 03, 2015, 04:52 pm by JakeSoft
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

Code: [Select]

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?

JakeSoft

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

Code: [Select]

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.

billpealer

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!

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.

(Of course someone can correct me on this.)

JakeSoft

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.

Canobi

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.

raphax

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! :P

Canobi

#55
Oct 17, 2015, 02:52 pm Last Edit: Oct 18, 2015, 10:40 pm by Canobi
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:

http://www.fx-sabers.com/forum/index.php?topic=27166.0

kingale

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

JakeSoft

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.

kingale

Quote
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.

Quote
Turn on repeat mode
WT588D_Send_Command(0xF2);

//Begin playlist 0
WT588D_Send_Command(0x00);

JakeSoft

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.

Does the hum sound not play at all, or does it just not loop for you?

Go Up