Go Down

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

jonnieZG

yo is this true?

soldering irons have voltage? not just heat?  
*Anything* has voltage - either static, and/or noise picking up from the power line. When you walk around the room, pick a door-knob and a spark comes out - that's static electricity, thousands of volts. Enough to make your hand twitch and more than enough to burn a FET. Soldering iron, blenders, anything that you plug in a wall socket may and usually does pick a fraction of the 50/60Hz voltage from the power line. That's different than the static electricity, but also kills FETs. Modern FETs have a built-in protection, but nevertheless, I killed one recently because I forgot to short-circuit the pins before soldering...

Canobi

I like it!

How are you planning to test it?
I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code.

JakeSoft

I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code.
Ah, you need a "test pattern" program. I might be able to whip something up, I just need to find time to do it.

billpealer

#483
Jan 19, 2016, 08:07 pm Last Edit: Jan 19, 2016, 09:55 pm by billpealer
How do you plan to test it?

Canobi--
"I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code."
you could just send me one.  :) :)

l'll be glad to test it. :) see? you need cake.  cake=sumofparts, what you've been making is the pan. or maybe the oven. :p

between Illuis's One Line Serial Mode, code,..  Jake's code posted for ON/Off Bool AND WT programming videos (thanks again best tute on youtube btw)  and the Debounce Code i posted to trigger SW-200 sensors, with the actual WT code associated with it..  it's all here.

try it out Obiwan dude.  if you can make a circuit board you can copy/paste.

Actually we need some ADXL335 code posted.  jake?  you got a stepping stone?  there is only a 1000 Arduinio posts about the ADXL335 online, and not only that, it looks like any good analogRead Potentiometer code can migrate over with some testing and tweaks as well.  Just wondering if you had a scaled down "breadcrumb" like you tossed me for the Bool on/off code. yah?

i think from what i can tell, the only real trick with the ADXL is resting state.  at any given position, one or a blend of the axis will trigger 1g of data,.  so,..  what is that around 1g= analogRead(500);  ish?

so,..   if you mount the thing z axis flat, and y axis north (what i like to call NORMAL), then you hold your saber 100% vertical..  you'll pull XYZ of roughly, 390,500,390? because the Y axis is receiving 1 pure G of force,. AKA gravity. and Z and X are getting very little.  And from I am reading very little or ZERO, is actually closer to an analogRead of less than or =to 395. i don't have one in hand so i can't be sure.  when i get it, i will post the results, and like i did for the SW-200, post the WT trigger code. or at least my flavor of it. but other have posted the results of raw analogReads of the ADXL335 and i think my numbers are close. 

the trick is CHANGE. the analogRead just needs to change, on any axis by about +/-150, and if over 600, just repeat the swing sound because, that means you are spinning the blade, or figure-8-ing it etc. general grievous style   the ADXL335 is sensitive up to.. 3 Gs right?  i know i can swing harder than 3 g's.

ergo the importance of the clash spring sensor (button)

 i could of course be wrong about the above, my memory is no longer photogenic PinMode(3kids). in 3 weeks when my adxl comes in i will have more.

oh,..  update on lock up with no button.  it sounded wrong.  interrupting lock up with a swing worked..  but a single clash needs to decay or fizzle to hum. that was missing.  i think with some creative code you could still do it. you would need 2 sounds.  lock up, and a fizzle to hum sound.  so a single hit would trigger the clash sensor, then the ADXL would be pulling numbers over 500 on at least one axis, that would trigger a fizzle to hum,..  and if the the g's are substantial after 300ms or so- play more swing sounds.

i can make the gapless sounds if someone want to test this.  waiting for parts sucks.

anyone else have a working saber video to post? i am curious to who else has made some cake?





jshaw

The last of my electronic parts (swing and clash sensors, and speakers) arrived yesterday, but I still don't have my blade holder from The Graflex Shop, so I'm stuck not able to assemble things completely.   

I've toyed a bit with the code, but I also have the 32 pin USB programmable WTD module, so it's pinout is different from the one that everyone else is using, so I'm fighting with that. 

I did figure out the issue w/ my LEDs not being very bright.  It's because I was just driving them from my 3.3V Arduino directly, so they were only getting the minuscule amperage that it provides instead of 700Ma they want.  A simple 5V booster made it much brighter, but I need to use smaller boosters because the off-the-shelf model I grabbed is too large to fit 3 of them in my hilt for my tri-rebel.

billpealer

I've toyed a bit with the code, but I also have the 32 pin USB programmable WTD module, so it's pinout is different from the one that everyone else is using, so I'm fighting with that. 
can you send a link to this or the full model number? I use the 28p version. I posted a wiring diagram a while back.

billpealer

Jshaw- you have to mean the 28pin 32m USB version.  Which I use.  See my diagram on like. Page 10 or was it 12? It has the chip diagram and how to wire it. I have looked and looked.  I can't find a 32 pin ver .... Anywhere ever.  Not waytronic.

jshaw

Jshaw- you have to mean the 28pin 32m USB version.  Which I use.  See my diagram on like. Page 10 or was it 12? It has the chip diagram and how to wire it. I have looked and looked.  I can't find a 32 pin ver .... Anywhere ever.  Not waytronic.
My bad, you are absolutely right! I'll look at your writing when I get a chance. Thanks for catching that, which explains why the manuals I read made no sense.

billpealer

#488
Jan 20, 2016, 04:03 am Last Edit: Jan 20, 2016, 02:45 pm by billpealer
Again... Anyone using an LED buck down driver for their LED with MOSFET PWM control?  I am buying another buck. Maybe mine is bad.  PWM with MOSFET + buck driver no workey. I have succeeded in getting PWM off raw power + MOSFET.   My driver... Not so much.    I suppose I fried my 2 MOSFETs with ambient voltage from the universe like warned about.  Doubt it.  Purgedsoul? Protonerd?  Bueller?

JakeSoft

#489
Jan 20, 2016, 04:06 am Last Edit: Jan 20, 2016, 04:06 am by JakeSoft
I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code.
Here is some basic test code for you, Canobi. It'll test all the I/O except for the accelerometer inputs. I couldn't think of an easy way to do that except maybe putting out the raw read values via serial.

This code will ramp up all 6 possible LEDs to full power and then ramp them down one at a time. See code for the order they go in, but it's more or less right around the pins on the Arduino in ascending order.

Then, once all the LEDs have been tested, it'll go into "button test mode". You can press the Activation switch, Aux switch, or bang the clash sensor to play three different sounds on the WT. Just program your WT588D in one-line serial mode to have three different sounds at 0x00, 0x01, and 0x02 so you'll know if the right sound is playing when you hit the switches.

All while this is happening, the main LED light will light up or go out to indicate the status of the BUSY signal from the WT588D. If you hear sound, but the light does not change state then probably something wrong with the busy signal on the WT.

Code: [Select]

/*
 * Pins_Canobi.h : Defines pinout for Canobi's 3-channel PCB.
 *
 *  Created on: Jan 8, 2016
 *      Author: JakeSoft
 */

#ifndef PINS_CANOBI_H_
#define PINS_CANOBI_H_

//General I/O Pins
#define CLASH_PIN 2 //Clash sensor interrupt pin
#define LED_RED_PIN 3 //PWM output for RED LED
#define LED_GREEN_PIN 5 //PWM output for GREEN LED
#define LED_BLUE_PIN 6 //PWM output for BLUE LED
#define ACTIVATE_PIN 7 //Activation switch
#define AUX_PIN 8 //Aux switch
#define LED_FOC_PIN 9 //Flash-on-clash LED (not implemented by JakeSoft SW)
#define ACCENT1_PIN 10 //Accent LED
#define ACCENT2_PIN 11 //Secondary Accent LED (not implemented by JakeSoft SW)

//Serial pins for WT588d Sound board
#define WT588D_BUSY 12 //Module pin "LED/BUSY"
#define WT588D_SDA 13 //Module pin for DATA

//Accelerometer Pins
#define AXDL335_X_PIN A0 //X axis
#define AXDL335_Y_PIN A1 //Y axis
#define AXDL335_Z_PIN A2 //Z axis
#define AXDL335_VCC_PIN A3 //Accel power (not used by Canobi's PCB)
#define AXDL335_GND_PIN A4 //Accel ground (not used by Canobi's PCB)

#endif /* PINS_CANOBI_H_ */

 

Code: [Select]

/*
 * SaberTest.ino : Tests saber I/O
 *
 *  Created on: Jan 19, 2016
 *      Author: JakeSoft
 */
 
#include "Pins_Canobi.h"

//Routine to send WT588D one-line serial commands
void WT588D_Send1(byte addr) {
    digitalWrite(WT588D_SDA, LOW);
    delay(5);

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

    digitalWrite(WT588D_SDA, HIGH);
    delay(10);
}

//Ramp up the LED then ramp it down
void TestLED(int PinNumber)
{
  //Ramp up the LED
  for(int LedPower = 0; LedPower < 255; LedPower++)
  {
    analogWrite(PinNumber, LedPower);
    delay(10);
  }
  
  //Ramp down the LED
  for(int LedPower = 255; LedPower > 0; LedPower--)
  {
    analogWrite(PinNumber, LedPower);
    delay(10);
  }
  
  //Ensure the the LED is fully off
  digitalWrite(PinNumber, LOW);
}

void setup()
{
  pinMode(LED_RED_PIN, OUTPUT);
  pinMode(LED_GREEN_PIN, OUTPUT);
  pinMode(LED_BLUE_PIN, OUTPUT);
  pinMode(LED_FOC_PIN, OUTPUT);
  pinMode(ACCENT1_PIN, OUTPUT);
  pinMode(ACCENT2_PIN, OUTPUT);
  
  pinMode(CLASH_PIN, INPUT);
  pinMode(ACTIVATE_PIN, INPUT);
  pinMode(AUX_PIN, INPUT);
  
  pinMode(WT588D_BUSY, INPUT);
  pinMode(WT588D_SDA, OUTPUT);
  
  pinMode(AXDL335_X_PIN, INPUT);
  pinMode(AXDL335_Y_PIN, INPUT);
  pinMode(AXDL335_Z_PIN, INPUT);
  
  //Set pull-up resistors for switches
  digitalWrite(CLASH_PIN, HIGH);
  digitalWrite(AUX_PIN, HIGH);
  digitalWrite(ACTIVATE_PIN, HIGH);
  
  //Run LED tests
  TestLED(LED_RED_PIN);
  TestLED(LED_GREEN_PIN);
  TestLED(LED_BLUE_PIN);
  TestLED(LED_FOC_PIN);
  TestLED(ACCENT1_PIN);
  TestLED(ACCENT2_PIN);

}

void loop()
{
  if(LOW == digitalRead(CLASH_PIN))
  {
    //Play a sound
    WT588D_Send1(0x00);
    
    delay(100);
    //Wait for user to let off the button
    while(LOW == digitalRead(CLASH_PIN)) {}
    
  }
  
  if(LOW == digitalRead(AUX_PIN))
  {
    //Play a sound
    WT588D_Send1(0x01);

    delay(100);    
    //Wait for user to let off the button
    while(LOW == digitalRead(AUX_PIN)) {}
  }
  
  if(LOW == digitalRead(ACTIVATE_PIN))
  {
    //Play a sound
    WT588D_Send1(0x02);
    
     delay(100);
    //Wait for user to let off the button
    while(LOW == digitalRead(ACTIVATE_PIN)) {}
  }
  
  //Use the primary blade LED to indicate the status of the BUSY pin
  if(HIGH == digitalRead(WT588D_BUSY))
  {
    //Dimmly light the primary blade LED
    analogWrite(LED_RED_PIN, 64);
  }
  else
  {
    //Turn the primary blade LED off
    digitalWrite(LED_RED_PIN, LOW);
  }

}

iamearlgrey

Not sure if I am adding anything or not. I've missed several pages since I began reading this thread.
I was looking at the pcb layout and messing around with it then i realized i need to cram into 1" i.d. pvc tube and the current design is still to big. This got me to think about alternate parts for the build.

Would the pololu step down regulator work for this. It is fairly inexpensive. Also, I first discovered arduino through building a multi rotor. Today I had the idea that maybe a flight controller could work for a saber board. It has an mpu6050 built right in as well as onboard 3.3v and 5v regulators and usb so no need for ftdi. not bad for $12 still too big for 1" i.d. but not for 1.25".
http://www.readytoflyquads.com/flip-mwc-flight-controller

and an alternative to the wt588d could be the dfrobot mp3 mini.
http://www.dfrobot.com/index.php?route=product/product&product_id=1121#.Vp75rrTtKQE

anyway, I still need to go through all of the posted code and see if I can cobble something. I'm still just using a virtual arduino to learn the basics.

Protonerd

Not sure if I am adding anything or not. I've missed several pages since I began reading this thread.
I was looking at the pcb layout and messing around with it then i realized i need to cram into 1" i.d. pvc tube and the current design is still to big. This got me to think about alternate parts for the build.

Would the pololu step down regulator work for this. It is fairly inexpensive. Also, I first discovered arduino through building a multi rotor. Today I had the idea that maybe a flight controller could work for a saber board. It has an mpu6050 built right in as well as onboard 3.3v and 5v regulators and usb so no need for ftdi. not bad for $12 still too big for 1" i.d. but not for 1.25".
http://www.readytoflyquads.com/flip-mwc-flight-controller

and an alternative to the wt588d could be the dfrobot mp3 mini.
http://www.dfrobot.com/index.php?route=product/product&product_id=1121#.Vp75rrTtKQE

anyway, I still need to go through all of the posted code and see if I can cobble something. I'm still just using a virtual arduino to learn the basics.
The dfrobot MP3 player is in fact the DFPlayer mini, the other MP3 player used in Arduino sabers beside the WT588d. BTW, the IC of the DFPlayer also has a 3.3V LDO, too bad it's not on the pinout.

Protonerd

As the design uses them to drive the WT at 5v (and eventually the mono amp) with a single 3.7v cell, I was planning on supplying them with the board.

Hmm, if planning on using a 7.4v system though, then a 5v LDO would be a good alternative for supplying 5v to the wt.


A1: I looked at that the other day as I had the same concerns. Turns out it's not actually necessary as it fits a 25mm ID hole mounted on its side but if I get enough of them, the manufacturer said they will ship them to me without the headers.

A2: The most I've seen is about 2A but they don't work the same as LDOs.

LDOs take a min/max voltage and output a fixed or adjustable regulated voltage lower than that received (due to the voltage drop).

A boost modules will take a min/max voltage in the same manner but the output voltage is usually always the same or higher than the input voltage. The current is also regulated but it's not clamped like an LDO, in this case the current any given boost converter can output is dictated by the input voltage.

Heres what the bumph says about the 5v .5A modules:

Input voltage 0.9 ~ 5V, output 5V
Maximum output current: 500 MA,
 
Start Voltage 0.9V, Output Current 10MA
 
INPUT 1-1.5V,      OUTPUT 5V 50-110MA;
INPUT 1.5-2V,      OUTPUT 5V 110-160MA;
INPUT 2-3V,         OUTPUT 5V 160-400MA;
INPUT above 3V,  OUTPUT 5V 400-500MA;


To the question of whether an LDO or a buck/boost (just my opinion).
- an LDO (low drop-out) is a type of voltage regulator where the input voltage can get close to the regulated output voltage with only a low drop of the regulated output voltage (i.e. even if the battery voltage comes close to 5V, the LDO is still outputting a voltage close to 5V). I prefer to use voltage regulator, but LDO somehow stuck. Huge advantage is that it's simple and for a few hundreds of mA you can even monolithically integrate it into IC's. That is why many IC's (FTDI for instance) have embedded LDO's you can use to supply other IC's. Yes, it may not be as efficient as a swicthed mode power supply (DC/DC, also called buck/boost), but you win more than what you loose due to the size and no switching noise. The lower efficiency comes from the fact that the power coming from the voltage difference between the input and output multiplied by the supplied current is wasted over the pass transistor (i.e. 7.4V input, 5V output, 200mA -> 2.4V*0.2=0.48W wasted).
- a buck/boost is a switched power supply, and relies on quite big external components (coil, diode, cap) to store the energy. Is more efficient, but BIG. It only makes sense if you really need juice, >1A let's say OR if you have a lower input voltage than the one you need. I'm also thinking about a hybrid circuit, where I use one single 3.7V cell type 18650 and "boost" it up to 5V only for the saber electronics, but supply the LED's still from the 3.7V directly. For that a small boost would suffice with max 500mA.
BTW, a boost does not regulate current, it just outputs (nearly) the same power as the input. It has less loss, but say if you want to boost 1V to 5V and get out 1A, you need to input a bit more than 5A (1V*5A*(1/efficiency) to reach 5V*1A). AFAIK the LDO also does not clamp, the current is limited by the pass transistor only.

So the only scenario I would consider a buck/boost over LDO is when the voltage has to be stepped up (for lack of an alternative), but that only for the less power hungry parts (MP3 player, movement sensors, uC). It would be nice to find one which could be integrated onto the board with minimal impact on the dimensions.

Canobi

The micro boost module is to power the WT at 5v using 3v7 as it doesn't seem to require a great deal of current and would have a bit of overhead and the PCB is routed to supply the LEDs directly from the battery.

I'm looking into boost iCs but there are a lot of datasheets to go through to find one suitable.

Canobi

Your most gratious Jake, thank you so much for taking the time to do that for me :D

I'll try and find time to make a few this w/e along with the MMA versions for DJWing79 for the purpose of field testing.

Since the new layout is based on your diagram Jake, it seems only fitting you should have one.

Bill, you have dibs on #2 since you had the initiative and guts to ask outright ;)

First person to post "I'll take one" has #3.


Drop me a PM with board setup preferences and addresses and I'll get them sent as soon as they're done.

Shipping is 5~7 days standard international and on lthe house, if you would prefer another method let me know in the PM and we can work out the details.

Go Up