Go Down

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

Canobi

#705
Mar 05, 2016, 11:53 pm Last Edit: Mar 06, 2016, 12:05 am by Canobi
Embedding video was a hack in older versions of the forum software.
It is one of the many things that got broken after updating to the newest and beta SMF forum software, about a year ago.
Don't expect that to be fixed any time soon.
Shame, ah well, links it is then.

Thanks for clearing that up mas3


Canobi

Here's part 2.

https://youtu.be/k4tMNRgwcBI

Its a bit rough around the edges so apologies for that.

Please let me know if the quality sucks, it seems a bit hit n miss when I review at home, sometimes plays back in HD, other times it looks really compressed so unsure if it's just my bandwidth or not.


destructables

Hey guys, just a quick question.

I was searching some good speaker to put inside a hilt, and I found that somesurface tranduscer measure exactly 28mm in diameter (and they are 4ohms 3W).

Do you think those could be used to transform the outer surface of the hilt into the actual speaker (not mentionning it would also act as a rumble device) ?

[EDIT]
So I may answer to myslef by a yes, it can.
here are some examples :  https://www.youtube.com/watch?v=xC1GUSu1bLU
Ok, our surface is not the same (smaller) , but I'll take that as a proof of concept.
Tests needs to be made.

Furthermore, the blade could also be used as a speaker : I found some interesting devices that uses piezo electrics device and plexiglass to make fantastic speakers.
So applying a correct piezo speaker to the emiter might produce the same.


I'd been looking into one of those myself, as I'm modding an ultrasaber that as of right now has a solid pommel. If the transducer would work, that would save me from having to mill holes into the pommel.

neskweek

#708
Mar 08, 2016, 11:22 pm Last Edit: Mar 08, 2016, 11:30 pm by neskweek
I'd been looking into one of those myself, as I'm modding an ultrasaber that as of right now has a solid pommel. If the transducer would work, that would save me from having to mill holes into the pommel.
You still need those holes for safety issues : batteries can vent.

Old batteries, or defectuous battery, when you ask of them to much power start to heat.
This leads to some wearing effect. At some point this wear will make the battery leak. When they leak they vent gases.
If you have no holes in your hilt, those gases build up pression inside the hilt, until the hilt structure can take it anymore : in short term your hilt might explode.
If you don't believe look at articles on electonic cigarette exploding : some crappy designed of those stuff does not have venting holes.

So as I said earlier : YOU WANT HOLES ! ( even small ones ;) )


That brought me to talk another matter. I don't know if it had already been discussed in this thread, but does any of you monitor battery charge ?
You may also want to : if battery goes below a certain voltage, it simply dies, even if it is brand new.
Since arduino board are always on ....  
You'll find here a way to do so

destructables

You still need those holes for safety issues : batteries can vent.


So as I said earlier : YOU WANT HOLES ! ( even small ones ;) )

Makes me wonder why Ultrasabers doesn't have any vent holes in their sabers. It's a single milled tube. Maybe around where the switch is mounted?

neskweek

#710
Mar 09, 2016, 12:50 am Last Edit: Mar 09, 2016, 12:58 am by neskweek
Lots of industrials aren't well informed on battery venting risks....

OMG!! And they provide their device with trustfire (well named) batteries  :o  :o  :o

Well, then.... Battery venting is not that common, but hey... shit happens !

Protonerd

You still need those holes for safety issues : batteries can vent.

So as I said earlier : YOU WANT HOLES ! ( even small ones ;) )

You are rigth, we want holes. And saber hilts have them. I also own an UltraSabers, the pommel always has holes, because there is where you want to put your speaker, and very often the emitter has windows (although they might be blocked by the blade).


Quote
That brought me to talk another matter. I don't know if it had already been discussed in this thread, but does any of you monitor battery charge ?
You may also want to : if battery goes below a certain voltage, it simply dies, even if it is brand new.
Since arduino board are always on .... 
You'll find here a way to do so
I did try it, but later neglected the topic due to more pressing matters. But a very important point. The deep discharge is however a rare event, if the voltage drops below a critical point, the chips do not work any more, and that means they also do not consume much. If you supply through VIN, the LDO will also caese to work if the input voltage drops below 5V (not immediately, but sooner or later). After which no current will flow, or only a minimal leakage.
Apart from this, most sabers have kill keys. I.e. if you do not need your saber, you plug in the kill key, physically separating the battery from the electronics. So far I only have one saber where the electronics can really go into deep sleep, and I can keep the saber months in a row on the shelf wo/kill key and I can still wake it up. So with a chipset in deep sleep, the risk is minimized. I hope that the Atmegas can be put into deep sleep mode and woken up again easily.

With neopixels, a very cool in-blade PLI (power level indicator) could be achieved. With green/yellow/red regions.

neskweek

#712
Mar 09, 2016, 04:57 pm Last Edit: Mar 09, 2016, 05:17 pm by neskweek
Atmega328 can be put in deep sleep mode. I tried with your design and it works. To wake it up you need to hit the hilt (like a clash) to generate the necessary  interrupt.

From what I could find on the net a normal/default deep sleep on those chips  needs 0,36mAh but with further tweaking lower consumption rates  can be achieved (some claims 1 to 4µA) 

source : http://www.gammon.com.au/forum/?id=11497

Protonerd

I found this one:
http://playground.arduino.cc/Learning/ArduinoSleepCode

And from here I visited the data sheet of the Atmega chips.It says that pin change interrupts on any of the PCINTx pins can be used to wake up the Atmega from any of the sleep modes. I.e. any of the 2 switches could also do the trick (theoretically, proof still pending :) )

The MPU6050 also has power management registers, some info can be found here:
http://playground.arduino.cc/Main/MPU-6050

The USB chip FT232RL has a so called USB suspend mode, but shame on me, I could not find in the datasheet how to drive the chip into that state...

neskweek

And from here I visited the data sheet of the Atmega chips.It says that pin change interrupts on any of the PCINTx pins can be used to wake up the Atmega from any of the sleep modes. I.e. any of the 2 switches could also do the trick (theoretically, proof still pending :) )
Well ... I only play 2 hours with LowPower library and this one doesn't seem to agree :P


JakeSoft

#715
Mar 10, 2016, 03:39 am Last Edit: Mar 10, 2016, 03:51 am by JakeSoft
Here is an early drop of the Universal Saber (USaber) library I've been working on. So far, only a few blades are supported but I have plans to support other hardware and blade types as I can find time to add them.

Blade Types:
CheapieBlade: Emulates the blade behavior of a cheap toy lightsaber!
SingleLedBlade: Basic one-LED blade with power up/down effects and random flicker!
StringBlade: A basic six-segment string blade.

No documentation yet, but here is some unit test code to show intended usage.

Code: [Select]

/*
 * SaberBlades.ino
 *  This will test lightsaber blades!
 
 *  Created on: Mar 8, 2016
 *      Author: JakeSoft
 */


#include "SingleLedBlade.h"
#include "CheapieBlade.h"
#include "StringBlade.h"

#define LED_PIN1 3
#define LED_PIN2 5
#define LED_PIN3 6
#define LED_PIN4 9
#define LED_PIN5 10
#define LED_PIN6 11

void TestBlade(IBladeManager* apBlade)
{
bool lPowerupComplete = false;
bool lPowerdownComplete = false;

apBlade->Init();

Serial.println("On()");
        apBlade->On();
delay(2000);

Serial.println("Off()");
apBlade->Off();
delay(2000);

Serial.println("PowerUp(2000)");
while(!lPowerupComplete)
{
apBlade->SetChannel(255, 0);
lPowerupComplete = apBlade->PowerUp(2000);
}
delay(1500);

Serial.println("PowerDown(2000)");
while(!lPowerdownComplete)
{
lPowerdownComplete = apBlade->PowerDown(2000);
}
delay(1500);

//Note: Testing flicker patterns is skipped if no patterns are supported
for(int lFlicker = 0; lFlicker < apBlade->GetFeatures().Flickers; lFlicker++)
{
Serial.print("Flicker pattern ");
Serial.println((int)lFlicker);

long lStartTime = millis();

//Turn on the blade
apBlade->On();

//Apply flicker for 5 seconds for
while(millis() - lStartTime < 5000)
{
apBlade->ApplyFlicker(lFlicker);
}

//Turn off the blade
apBlade->Off();

delay(1000);
}

//Test setting individual channels
for(int lChannel = 0; lChannel < apBlade->GetFeatures().Channels; lChannel++)
{
Serial.print("Channel ");
Serial.print(lChannel);
for(int lPower = 0; lPower <= 255; lPower++)
{
apBlade->SetChannel(lPower, lChannel);
apBlade->PerformIO();
delay(1);
}
delay(1500);
for(int lPower = 255; lPower >= 0; lPower--)
{
apBlade->SetChannel(lPower, lChannel);
apBlade->PerformIO();
delay(1);
}

apBlade->Off();
}

delay(1000);
}

/**
 * The setup function is called once at startup of the sketch
 */
void setup()
{
  Serial.begin(9600);
}

/**
 * The loop function is called in an endless loop
 */
void loop()
{

Serial.println("\nTesting CheapieBlade");
IBladeManager* lpBlade = new CheapieBlade(LED_PIN1);
TestBlade(lpBlade);
delete lpBlade;

Serial.println("\n\nTesting SingleLedBlade");
lpBlade = new SingleLedBlade(LED_PIN1);
TestBlade(lpBlade);
delete lpBlade;

Serial.println("\n\nTesting StringBlade");
lpBlade = new StringBlade(LED_PIN1, LED_PIN2, LED_PIN3,
                                  LED_PIN4, LED_PIN5, LED_PIN6);
TestBlade(lpBlade);
delete lpBlade;

delay(5000);

}



Comment out the blade types you aren't interested in or, create your own derived class to implement your own custom solution.

I'm hoping this will be step towards standardization that will allow many contributors to supply cross-compatible code for some really gee-wiz lightsaber projects. Try it out and let me know what you guys think. MTFBWY.

neskweek

#716
Mar 10, 2016, 05:36 pm Last Edit: Mar 10, 2016, 06:00 pm by neskweek
Ok boys (and girls).

I nailed agressive power save mode with wake up via PCINT interreupts (other PIN than D2 and D3) :

Code: [Select]

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/interrupt.h> 


timeToDeepSleep = millis();


setup(){
// your stuffs
// Aux button (for example)
PCMSK0 |= (1 << PCINT4); // set PCINT4 (PIN 12) to trigger an interrupt on state change
// Main button (for example)
PCMSK2 |= (1 << PCINT20); // set PCINT20 (PIN 4) to trigger an interrupt on state change
//your stuffs
}


loop{

//Your stuffs
timeToDeepSleep = millis();
deepSleep();
//Your stuffs

}

void deepSleep() {

if (millis() - timeToDeepSleep >= DEEP_SLEEP) {
Serial.println(F("Powersave mode"));
delay(20);


set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
noInterrupts ();
// timed sequence follows

// enables the sleep bit in the mcucr register
sleep_enable();

// disable ADC
byte old_ADCSRA = ADCSRA;
ADCSRA = 0;

// turn off various modules
power_all_disable ();



//Reduce processor frequency
byte oldCLKPR = CLKPR;
CLKPR = bit(CLKPCE);
CLKPR = clock_div_256;

// turn off brown-out enable in software
MCUCR = bit (BODS) | bit(BODSE);  // turn on brown-out enable select
MCUCR = bit(BODS);   // this must be done within 4 clock cycles of above
// guarantees next instruction executed
// sleep within 3 clock cycles of above
interrupts ();
sleep_cpu ();

PCIFR |= bit (PCIF0) | bit(PCIF1) | bit(PCIF2); // clear any outstanding interrupts
PCICR |= bit (PCIE0) | bit(PCIE2); // enable pin change interrupts

sleep_mode();

// THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
// cancel sleep as a precaution
sleep_disable();
CLKPR = oldCLKPR;
power_all_enable ();
ADCSRA = old_ADCSRA;
CLKPR = bit(CLKPCE);
CLKPR = clock_div_1;
interrupts ();
delay(20);Serial.println(F("Normal mode"));delay(20);
timeToDeepSleep = millis();
}
}



// the followingis not needed if you use SoftwareSerial library or other libraries making use of those interruptes
#if defined(PCINT0_vect)
ISR(PCINT0_vect)

// No need to put stuff in there to make you out of sleep mode

}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
#endif



I've got one problem tho... My ampmeter isn't accurate enough to catch those reading.
It can't read below 200mA :P

If you use main button to make your device wake up, you'll need to press it twice to ignite the saber.

destructables

Here is an early drop of the Universal Saber (USaber) library I've been working on. So far, only a few blades are supported but I have plans to support other hardware and blade types as I can find time to add them.

Blade Types:
CheapieBlade: Emulates the blade behavior of a cheap toy lightsaber!
SingleLedBlade: Basic one-LED blade with power up/down effects and random flicker!
StringBlade: A basic six-segment string blade.

No documentation yet, but here is some unit test code to show intended usage.

Code: [Select]

/*
 * SaberBlades.ino
 *  This will test lightsaber blades!
 
 *  Created on: Mar 8, 2016
 *      Author: JakeSoft
 */


#include "SingleLedBlade.h"
#include "CheapieBlade.h"
#include "StringBlade.h"

#define LED_PIN1 3
#define LED_PIN2 5
#define LED_PIN3 6
#define LED_PIN4 9
#define LED_PIN5 10
#define LED_PIN6 11

void TestBlade(IBladeManager* apBlade)
{
 bool lPowerupComplete = false;
 bool lPowerdownComplete = false;

 apBlade->Init();

 Serial.println("On()");
        apBlade->On();
 delay(2000);

 Serial.println("Off()");
 apBlade->Off();
 delay(2000);

 Serial.println("PowerUp(2000)");
 while(!lPowerupComplete)
 {
 apBlade->SetChannel(255, 0);
 lPowerupComplete = apBlade->PowerUp(2000);
 }
 delay(1500);

 Serial.println("PowerDown(2000)");
 while(!lPowerdownComplete)
 {
 lPowerdownComplete = apBlade->PowerDown(2000);
 }
 delay(1500);

 //Note: Testing flicker patterns is skipped if no patterns are supported
 for(int lFlicker = 0; lFlicker < apBlade->GetFeatures().Flickers; lFlicker++)
 {
 Serial.print("Flicker pattern ");
 Serial.println((int)lFlicker);

 long lStartTime = millis();

 //Turn on the blade
 apBlade->On();

 //Apply flicker for 5 seconds for
 while(millis() - lStartTime < 5000)
 {
 apBlade->ApplyFlicker(lFlicker);
 }

 //Turn off the blade
 apBlade->Off();

 delay(1000);
 }

 //Test setting individual channels
 for(int lChannel = 0; lChannel < apBlade->GetFeatures().Channels; lChannel++)
 {
 Serial.print("Channel ");
 Serial.print(lChannel);
 for(int lPower = 0; lPower <= 255; lPower++)
 {
 apBlade->SetChannel(lPower, lChannel);
 apBlade->PerformIO();
 delay(1);
 }
 delay(1500);
 for(int lPower = 255; lPower >= 0; lPower--)
 {
 apBlade->SetChannel(lPower, lChannel);
 apBlade->PerformIO();
 delay(1);
 }

 apBlade->Off();
 }

 delay(1000);
}

/**
 * The setup function is called once at startup of the sketch
 */
void setup()
{
  Serial.begin(9600);
}

/**
 * The loop function is called in an endless loop
 */
void loop()
{

 Serial.println("\nTesting CheapieBlade");
 IBladeManager* lpBlade = new CheapieBlade(LED_PIN1);
 TestBlade(lpBlade);
 delete lpBlade;

 Serial.println("\n\nTesting SingleLedBlade");
 lpBlade = new SingleLedBlade(LED_PIN1);
 TestBlade(lpBlade);
 delete lpBlade;

 Serial.println("\n\nTesting StringBlade");
 lpBlade = new StringBlade(LED_PIN1, LED_PIN2, LED_PIN3,
                                  LED_PIN4, LED_PIN5, LED_PIN6);
 TestBlade(lpBlade);
 delete lpBlade;

 delay(5000);

}



Comment out the blade types you aren't interested in or, create your own derived class to implement your own custom solution.

I'm hoping this will be step towards standardization that will allow many contributors to supply cross-compatible code for some really gee-wiz lightsaber projects. Try it out and let me know what you guys think. MTFBWY.
Jake, I don't know you personally. But I want to hug you. Seriously.

...was that weird for me to say? Okay I'm just gonna go and sit over here and watch this thing run sample into perpetuity while I get office work done.

JakeSoft

Jake, I don't know you personally. But I want to hug you. Seriously.

...was that weird for me to say? Okay I'm just gonna go and sit over here and watch this thing run sample into perpetuity while I get office work done.
Haha! I'm glad it's working for you.

martinmerlino

hello everyone:) can anyone make a skecth from this picture. thanks :)

Go Up