Go Down

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

Canobi

It keeps getting better and better! I like the placement of the switch vias a lot better now.

Still a few issues.

1) The ADXL335 doesn't appear to have a positive power source linked in directly from any rail. The silkscreen seems to suggest that you intend to bridge it to raw battery power with a jumper maybe? If so, that will blow it up; the GY-61 ADXL335 is a 3.3V device. It needs to be attached to the 3.3V rail somehow and only fed regulated voltage.
Sorry, my bad. I accidently used an older grab section to compile the new high res pic and the ADXL pin wasn't connected in that section.

Your almost correct about the link wire but actually the ADXL is attached to the regulated 3v3 rail as it should be, not the input terminal. It does look like it at a glance though.

In this grab I've traced over the ADXL's rail to show the tracks route from the 3v3 regulator:





2) This will work perfectly for a 3.3V Arduino variant, but will be incompatable with 5V Pro Mini or Nano. That's fine if that's what you intended, but 5V to the RAW pin will not power any standard arduino board. 5V will be under the dropout voltage of the arduino's on-board 5V regulator and it won't work.
Ah, I thought the 5v referred to the RAW pin's input voltage.

I made some more changes, lets see if I've nailed it this time....

The WT still retains a boosted 5v rail and regulated 3v3 power rail option as before and while the mini shares the latter 3v3 rail, a third rail has been added which is connected directly from the power input port to RAW for use with 7.4v supplies. It does have solder bridge pads like the others but they're bigger to make them easier to bridge using standard iron tips.





3) [nit]The silk screen on pin 13 should be "SDA" as it is the one-line serial data, not a serial clock. Same with the "CLK" on the WT588D.
No probs, that will only take a sec.



Just as a general comment, I've noticed that the power rail design meant to widen compatibility is adding some complexity that might be avoided if you simply made two distinct versions of the board.
This board is just one of four versions that support 1~4 LEDs, times that by the possible voltage combinations and the numbers of board variations suddenly get a bit unwieldy.

In reality, there's only two or three extra solder points involved which are seconds worth of work to do. The slight increase in complexity is in the layout which is neither here nor there as far as soldering goes.

Protonerd

It looks perfect.

On the silk screen I see "5V micro boost/buck", what IC do you use for the DC/DC? Did you find one which does not need extensive external components (coil, diode, cap etc.?).

JakeSoft

#467
Jan 18, 2016, 04:42 pm Last Edit: Jan 18, 2016, 05:02 pm by JakeSoft
Sorry, my bad. I accidently used an older grab section to compile the new high res pic and the ADXL pin wasn't connected in that section.

Your almost correct about the link wire but actually the ADXL is attached to the regulated 3v3 rail as it should be, not the input terminal. It does look like it at a glance though.

In this grab I've traced over the ADXL's rail to show the tracks route from the 3v3 regulator:





Ah, I thought the 5v referred to the RAW pin's input voltage.

I made some more changes, lets see if I've nailed it this time....

The WT still retains a boosted 5v rail and regulated 3v3 power rail option as before and while the mini shares the latter 3v3 rail, a third rail has been added which is connected directly from the power input port to RAW for use with 7.4v supplies. It does have solder bridge pads like the others but they're bigger to make them easier to bridge using standard iron tips.





No probs, that will only take a sec.


 

This board is just one of four versions that support 1~4 LEDs, times that by the possible voltage combinations and the numbers of board variations suddenly get a bit unwieldy.

In reality, there's only two or three extra solder points involved which are seconds worth of work to do. The slight increase in complexity is in the layout which is neither here nor there as far as soldering goes.
This is looking pretty good at first glance. I'll give it a more detailed look when I've got more time. Nice job, Canobi!

It looks like the spacing and maps for the buck converter could just as easily be an TO-220 style LDO. Is this the case?

Also, I totally agree that too many versions will become hard to maintain. To help minimize that, why not just make the 4-channel version and leave the other 3 FET slots empty if they are not needed? That way you only have one version to maintain.

MegaCorsair

Hi Jake, I'm still trying to Communicate one of the Wt588d to the arduino but i'm still failing... But I have one Question! I Found this:

https://github.com/ACDCLabs/WT588D

It's a Simple library for the WT588D soundchip breakout board. And there's a Thing called "Playsabersounds"

https://github.com/ACDCLabs/WT588D/blob/master/PlaySaberSounds/PlaySaberSounds.ino

How is this works? I Read the code but its confuses me this part:

Quote
void loopOnAllSounds(void)
By the way, I get a Dfplayer Mini and I have read a little ago a code for that and the MPU6050 for stinky1... That Code is Work perfectly? Because if it works , I'll try to get one MPU6050

Code: [Select]
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>

MPU6050 accelgyro;
int16_t ax, ay, az;    // define accel as ax,ay,az
int16_t gx, gy, gz;    // define gyro as gx,gy,gz
int16_t px, py, pz;    // previous accel settings
long x, y, z;
long accel;         // calc accel

int inPin = 9;         // the number of the input pin
int outPin = 10;       // the number of the output pin
int ledPin = 11;

int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

int track = 20;
int prev = 20;

boolean state = false; // the current state of the circuit

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 500;   // the debounce time, increase if the output flickers
long looptime = 0;     // the last time the loop was played
long gtime = 0;

SoftwareSerial mySerial(0, 1); // RX, TX

void setup()
{
  Wire.begin();              // join I2C bus
  //Serial.begin(38400);       // initialize serial communication
  //while (!Serial);           // wait for Leonardo enumeration, others continue immediately
  Serial.println("INIT");
  accelgyro.initialize();

  Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
 
  mySerial.begin(9600);
  mp3_set_serial(mySerial);  //set Serial for DFPlayer-mini mp3 module

  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  reading = digitalRead(inPin);
  accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);   // read measurements from device

  if(millis() - gtime > 500) {
    x=px-ax; y=py-ay; z=pz-az;
    x=abs(x); y=abs(y); z=abs(z);
    accel = (x+y+z);
    px = ax; py = ay; pz = az;

    if(state && accel > 15000) {
      mp3_play(random(31,34));
        //analogWrite(outPin, 255); delay(100);
        //analogWrite(outPin, 50); delay(100);
        //analogWrite(outPin, 255); delay(100);
        //analogWrite(outPin, 200); delay(100);
      looptime = millis()-2000;
    }

    Serial.print(gx);Serial.print(" ");Serial.print(gy);Serial.print(" ");Serial.println(gz);
    Serial.println(accel);

    gtime = millis();
  }
 
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (!state) {
      digitalWrite(ledPin, HIGH);
      looptime = millis();
      mp3_play(1);
      for(brightness = 0; brightness < 200; brightness++) {
        analogWrite(outPin, brightness);
        delay(16);
      }
      state = true;
    } else {
      mp3_play(2);
      for(brightness = 200; brightness > -1; brightness--) {
        analogWrite(outPin, brightness);
        delay(7);
      }
      digitalWrite(ledPin, LOW);
      state = false;
    }
    time = millis();   
  }

//  if (state && millis() - looptime > 4000) {
//    while (track == prev) {
//      track = random(21,24);     
//    }
//    mp3_play(track);
//    prev = track;
//    looptime = millis();
//  }
 
  previous = reading;
}

Protonerd

If interested how to program the MPU6050, I copied parts of my code dealing with that module in this thread: https://forum.arduino.cc/index.php?topic=361566.0

From the above post it looks like my code leaks anyway. It's nothing magic, probably very similar to JakeSoft's code with the ADXL335, using different thresholds to detect saber movement types like swing, clash etc.

Remaining challenge is to code a Clash sensor, using thresholds works well, but you have to extremely bring down the loop time to avoid a lag between clash event and start of corresponding FX. There is also a motion interrupt feature, but it's not straightforward, I work on it and give an update when ready.

Canobi

It looks perfect.

On the silk screen I see "5V micro boost/buck", what IC do you use for the DC/DC? Did you find one which does not need extensive external components (coil, diode, cap etc.?).
If only..

I use micro buck modules. This one is 5v .5A and is approx 10.8mm x 10.8mm square:



Once the mono amps have arrived I'll move on to the 1A version as the amp will use about 600mA on its own:


MegaCorsair

#471
Jan 19, 2016, 02:19 am Last Edit: Jan 19, 2016, 02:29 am by MegaCorsair
Too Many Codes and things  :smiley-roll-blue:
I think I gonna just wait for your tutorial with all step :'(

Canobi

This is looking pretty good at first glance. I'll give it a more detailed look when I've got more time. Nice job, Canobi!
Thanks Jake :)



It looks like the spacing and maps for the buck converter could just as easily be an TO-220 style LDO. Is this the case?
Not quite, the map would need to be changed for it to fit. TO-220 pins are 2.75mm pitch and the buck pin spacing is 1.27mm pitch.

What did you have in mind?



Also, I totally agree that too many versions will become hard to maintain. To help minimize that, why not just make the 4-channel version and leave the other 3 FET slots empty if they are not needed? That way you only have one version to maintain.
I agree, it would be the easiest way to do things.

billpealer

This is clearly more than the gyro code. This looks like an entire sketch which won't work without the MPU6050.h header file. Provided you had that, then maybe some examples could be gleaned from this code.
"it's an older code, but it check out."

billpealer

Important note on handling FETs: FETs (MOSFETs) are very sensitive components and are very easy to damage if you are not properly grounded. It is also likely that you'll burn it (electrically, not thermally) with your soldering iron. You'll now you did it if you notice that you cannot properly fade your LED: with a healthy MOSFET the light goes linearly up from 0 to 100%, while on a burnt one the LED will start lighting up at about 75% of PWM input level. Therefore, it is necessary to wrap all 3 pins with a piece of naked wire short-circuiting all pins, while you are soldering it. Once all the components are in place, you can wrap-off the short-circuiting wire.
yo is this true?

soldering irons have voltage? not just heat?   

Canobi

#475
Jan 19, 2016, 03:13 am Last Edit: Mar 08, 2016, 07:34 pm by Canobi
Last one before I hit the sack:



Note: Obsolete

JakeSoft

Thanks Jake :)



Not quite, the map would need to be changed for it to fit. TO-220 pins are 2.75mm pitch and the buck pin spacing is 1.27mm pitch.

What did you have in mind?
I'm just thinking about where to source those buck converters. I don't know where to find them and I'm probably not alone. However, TO-220 LDO regulators are sold by just about every electronics site known to man and are therefore easy to find and cheap. The buck converter has a lot of advantages, such as better efficiency, so I'm not saying to ditch it entirely, but it's not as approachable for a novice shopping for parts. Do you plan to pre-install them or offer them as part of a kit? I'm only suggesting that the option to add an LDO might make it more user friendly. Space looks kind of tight in that area of the board... not really much room to add three new vias. Hmm... well, just a thought. Maybe for another revision or version.

A few questions:

Q1: Also, are you planning to re-solder the pins on the second buck unit you posted such that it will lie flat instead of sticking up lengthwise on the pins? It looks like standing up like that might cause clearance issues.

Q2: How much current can you get out of a buck that size? I mean, how high do they go? I've been working with LDOs that can source 4 or 5 amps as long as your battery is strong enough. How does it compare? As I said earlier, I'm not that familiar with them. Please educate me.

JakeSoft


Kwissus

Thanks everyone for putting together this threadzilla of evolving information!

No really, I mean it.

Registered to share what I've spent too many hours last night on compiling while going through this thread:

Googe Sheet Link

Completely untested, sourced as cheap as possible for building 10 lightsabers.
It is missing some compontents that every budding sabersmith should have lying around anyway (resistors, npn transistors if you want the constant current solution that was posted on the last page).

Cost is $10.43 for each lightsaber, but you would need to pony up for a programmer for the arduino pro mini, and possibly for the WT588D.

Canobi

I'm just thinking about where to source those buck converters. I don't know where to find them and I'm probably not alone. However, TO-220 LDO regulators are sold by just about every electronics site known to man and are therefore easy to find and cheap. The buck converter has a lot of advantages, such as better efficiency, so I'm not saying to ditch it entirely, but it's not as approachable for a novice shopping for parts. Do you plan to pre-install them or offer them as part of a kit? I'm only suggesting that the option to add an LDO might make it more user friendly. Space looks kind of tight in that area of the board... not really much room to add three new vias. Hmm... well, just a thought. Maybe for another revision or version.
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.


A few questions:

Q1: Also, are you planning to re-solder the pins on the second buck unit you posted such that it will lie flat instead of sticking up lengthwise on the pins? It looks like standing up like that might cause clearance issues.

Q2: How much current can you get out of a buck that size? I mean, how high do they go? I've been working with LDOs that can source 4 or 5 amps as long as your battery is strong enough. How does it compare? As I said earlier, I'm not that familiar with them. Please educate me.
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;


Go Up