Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: jameskirk on Aug 11, 2014, 05:34 am

Title: Klingon Proton Collector
Post by: jameskirk on Aug 11, 2014, 05:34 am
Hello all
I have recently acquired a Klingon Proton Collector or Power Leech...
I would like to add electronics to make it just like it was in the movie...
Here is a Pic for reference...
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/Star-Trek-IV-The-Voyage-Home-Photon-Collector-4_zps3d3bc388.jpg)

and a couple of videos...
http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PhotonCollectorMockup_zps760aef8c.mp4

(http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PhotonCollectorMockup_zps760aef8c.mp4)
http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PhotonCollectorPrototypeI_zpsa771477e.mp4 (http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PhotonCollectorPrototypeI_zpsa771477e.mp4)
http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PowerLeech1_zps3fc34c0c.mp4
(http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PowerLeech1_zps3fc34c0c.mp4)
http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PowerLeech2_zps9989f0de.mp4
(http://vid1078.photobucket.com/albums/w495/jamestkirk1864/PowerLeech2_zps9989f0de.mp4)

Any help would be greatly appreciate it...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: fungus on Aug 11, 2014, 10:15 am
Looks easy enough from the electronics side...

But...what's inside it? Does it have LEDs? Battery compartment? What?? How much space is there?


Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 11, 2014, 03:47 pm
I have not seen the actual insides of the original but you can see thru the holes in the back in this pic from the original...
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/Star-Trek-IV-The-Voyage-Home-Photon-Collector-3_zps9b429f0a.jpg)
It has LEDs...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: fungus on Aug 11, 2014, 04:15 pm

I have not seen the actual insides of the original but you can see thru the holes in the back in this pic from the original...


We need to know about the one you've actually got, not the original.

Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 12, 2014, 01:32 am
Sorry here is some pic's of my Prop...

(http://i1078.photobucket.com/albums/w495/jamestkirk1864/4440e739-4345-4509-9926-416e1bc81769_zps33f33c2b.jpg)

(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140811_190645_zps2d3q9cvs.jpg)

(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140811_190620_zpshbunrvoi.jpg)

You can pull the handle off to put the battery pack in...

(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140811_190318_zpseyecsyy6.jpg)

Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: Simpson_Jr on Aug 12, 2014, 01:09 pm
It's hard to tell how much space you've got, about two 9v batteries would be nice.
Looking at the pictures it seems... enough for at least a few coincells, 6 leds, 6 resistors and a Mini (http://arduino.cc/en/Main/ArduinoBoardMini), Pro Mini (http://arduino.cc/en/Main/ArduinoBoardProMini), Micro (http://arduino.cc/en/Main/ArduinoBoardMicro) or Nano (http://arduino.cc/en/Main/ArduinoBoardNano).

The first two boards are the smallest, but need an external USB-breakout board to program them.
Unfortunately the product pages of these boards don't specify size, each pin on a connector is placed 0.1 inch from the next though.


Next part, how would you like to control/configure your leech ?
You could for example use a power switch to start the (standard programmed) routine, which requires access to a pc when you want to change settings. Looking at the original leech, you may also be able to include some switches/potentiometers to adjust settings without the need of a PC.

Most of the functions needed are described in the first two sections of the built-in tutorial of Arduinos IDE by the way, it shouldn't be too difficult to get a working proto(n)-type ;-)
Title: Re: Klingon Proton Collector
Post by: fungus on Aug 12, 2014, 08:37 pm

It's hard to tell how much space you've got, about two 9v batteries would be nice.
Looking at the pictures it seems... enough for at least a few coincells, 6 leds, 6 resistors and a Mini (http://arduino.cc/en/Main/ArduinoBoardMini), Pro Mini (http://arduino.cc/en/Main/ArduinoBoardProMini), Micro (http://arduino.cc/en/Main/ArduinoBoardMicro) or Nano (http://arduino.cc/en/Main/ArduinoBoardNano).


If this is your first Arduino project you could do far worse than get a "protosnap":

http://www.ebay.com/sch/i.html?_nkw=protosnap

This has a small Arduino, a programmer and some other stuff all connected together for learning. You can build the circuit and get it working then break the pieces apart and put just the bits you need inside the leech.

For power you can use 2xAAA batteries (or 2xAA, or 3xAAA, whatever) plus a 5V voltage booster (http://www.ebay.com/sch/i.html?_nkw=5v+dc+boost+pfm).

After that all you need is a few LEDs (http://www.ebay.com/sch/i.html?_nkw=rectangle+diffused+red+leds) and some matching resistors.
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 12, 2014, 11:54 pm
If you can squeeze in 3 x AAA, you won't need to boost the voltage to 5V, it will almost certainly work fine with just the cells.

http://www.ebay.co.uk/itm/1-2-3-4-6-8-x-AA-AAA-23A-9V-Battery-Holder-Snap-On-Connector-Enclosed-Box-Switch-/180814661762?pt=UK_BOI_Electrical_Components_Supplies_ET&var=&hash=item2a1964c882

I guess you will also need a piezo sounder. These are small and flat, so won't take up much space at all.

http://www.ebay.co.uk/itm/Piezo-Element-Sounder-Sensor-Trigger-Drum-Disc-Transducer-Various-Sizes-amount-/111180207482?pt=LH_DefaultDomain_3&var=&hash=item19e2db557a

Once you have the sketch working on your Uno, you can upload it into an attiny85

http://www.ebay.co.uk/itm/1-2-5-10-PCS-Original-ATMEL-DIP-8-ATTINY85-20PU-Tiny85-20PU-IC-Chip-NEW-/191092048934?pt=UK_BOI_Electrical_Components_Supplies_ET&var=&hash=item2c7df94426

Paul
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 13, 2014, 12:34 am
Paul
What would I need a piezo sounder for???
Also you put the wrong link in for it...



I guess you will also need a piezo sounder. These are small and flat, so won't take up much space at all.

http://www.ebay.co.uk/itm/1-2-3-4-6-8-x-AA-AAA-23A-9V-Battery-Holder-Snap-On-Connector-Enclosed-Box-Switch-/180814661762?pt=UK_BOI_Electrical_Components_Supplies_ET&var=&hash=item2a1964c882


Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 13, 2014, 12:50 am
Yes, sorry, I have corrected the link.

The sounder is to make beep noises like in the movie!
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 13, 2014, 03:28 am
OK I have a Nano V3.0 ATmega 328, ATTiny 85... I can get a UNO if need be...
Can you help me out with the code I need to make it do what it needs to do???
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 13, 2014, 11:43 pm
Yes I will help. But I will not do all the work for you.

You will not need an Uno. I just assumed that would be what you already had. Nano 3 will be fine. You will not need the tiny85 until later. Use the Nano to get the sketch and circuit working on breadboard first.

Do you have the Arduino ide installed and working? Do you have the "blink" sketch uploaded and running?
Title: Re: Klingon Proton Collector
Post by: dave-in-nj on Aug 14, 2014, 01:44 pm
list every output. 

the X pattern could be 2 pins, if they are always lighting in pairs.

the lights under the cutouts near the handle.  are they multi color or just one color.  do they change as the proton storage chambers fill ?

the yellowish one furthest from the handle does appear to get brighter as the chambers fill.

but that looks like 4 total pins out plus the noise of the unit

the photo of the back of the original unit appears to have a switch and three pots.

start with whatever arduino you are most comfortable programming with.

look at blink without delay
add in the sketch to

Code: [Select]

// set the LED with the ledState of the variable:
    digitalWrite(ledPin1, ledState);
    digitalWrite(ledPin2, -ledState);


this should have one of the X sides light and the other to be off, and they will forever be opposite

you have to declare ledPin1 and ledPin2 in the sketch

Title: Re: Klingon Proton Collector
Post by: dave-in-nj on Aug 14, 2014, 01:58 pm

Yes I will help. But I will not do all the work for you.



PaulBR, 

For the 4 LED's of the X in series.  one could put them in series, and have a pin connected to the center point between the 2 pairs.  then change the pin from input (light the pair of LED's connected to the 5V and then change the pin to an output (light the LED pair connected to the ground.

that would save a pin on the '85.

what do you think ?

would need to have the other two LEDs on a shared pin, using analogout to fade-up the leds.
one pin for the sound and one for the on/off switch... or do we still have room on the '85




Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 14, 2014, 05:37 pm

For the 4 LED's of the X in series.  one could put them in series, and have a pin connected to the center point between the 2 pairs.  then change the pin from input (light the pair of LED's connected to the 5V and then change the pin to an output (light the LED pair connected to the ground. that would save a pin on the '85.


Not quite. You are probably correct in saying they can be in series. As long as they are red, their forward voltage will probably be less than 2V. Two (low value, e.g. 68R) series resistors will be needed. But if the Arduino pin is set to Input, the leds will glow very dimly or probably not at all. However, if the pin it set as output and high, one pair of leds will light and if output and low, the other pair will light.


would need to have the other two LEDs on a shared pin, using analogout to fade-up the leds.
one pin for the sound and one for the on/off switch... or do we still have room on the '85


The tiny85 has 5 usable pins. Up to three can be analog inputs. Up to 2 can be analog (PWM) outputs. I don't see a need to use a pin for on/off - just have a switch cut power to the chip.

Pins usage:
1 digital output for "X" leds
1 PWM output for "filling/full" led
1 digital output for piezo sounder
1 analog input for "fill level" control

Michael has not said how he wants to control the "fill level" of the device. Options could be:

1. The collector builds up to "full" after a fixed timed interval after switch-on.
2. a hidden pot could be adjusted by slight-of-hand
3. a thermistor could be used so that if he device is placed on a central heating radiator, or a stone wall hot from the sun, the device would act like it is filling as the temperature rises.

Title: Re: Klingon Proton Collector
Post by: dave-in-nj on Aug 15, 2014, 02:18 am
I hope the OP can get the blink without delay to work with the two LED's   it should be pretty easy.

as for the dual use of a pin..... just thinking out loud.....
if one has an LED and POV, it might be possible to check the voltage on that pin.    if a switch were also connected, it might be possible to read that value.   not sure how that POV output would work with the time it would take to read the switch.

I think the switch is used to lock the displays in place after the unit has filled.

I was thinking a hall sensor.  it would start to capture when the unit was over metal, like a stud finder.  that way you could move it around on a wall unit it was able to start capturing.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 15, 2014, 09:00 pm
OK fellas
This is what I have...
http://i1078.photobucket.com/albums/w495/jamestkirk1864/6137e1c4-005a-4dfd-9160-de7a5e24d5ef_zpse7c035ec.jpg (http://i1078.photobucket.com/albums/w495/jamestkirk1864/6137e1c4-005a-4dfd-9160-de7a5e24d5ef_zpse7c035ec.jpg)

I have resistors just tell me what I need...
The Arduino is a Nano V 3.0 ATmega 328 5v-12v
The LED's Forward Voltage 2v Forward Current is 20mA...
I'm not new to this but I don't know a whole lot...
Ask me to wire a house or build a computer i'm on it...
So please tell me what you would like me to do...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 15, 2014, 10:05 pm
OK Michael, here's how I suggest you wire the "X"  of 4 leds. Use any digital Arduino pin for now.

The resistors shown were calculated like this:

We will have 5V across 2 leds in series, plus a resistor. Each led drops 2V, leaving 1V to be dropped by the resistor.

We want 20mA to flow through the pair of leds and the resistor, so by Ohm's law R = V / I = 1 / 0.02 = 50 Ohms.

Nearest common resistor value (above, for safety) would be 56R.
Title: Re: Klingon Proton Collector
Post by: C-F-K on Aug 15, 2014, 10:51 pm

Hello all
I have recently acquired a Klingon Proton Collector or Power Leech...
I would like to add electronics to make it just like it was in the movie...

Any help would be greatly appreciate it...
Thanks
Michael


First of all: Awesome!

Second: You want the LED's and the sound, but how do you want to controll the "proton mode"?
Just a hidden switch on the back (Easy) or the already mentioned thermistor (Little harder for a starter)? Even wireless is an option but first try to make it work the easy way and then work your way up!

We can suggest it all, but what do YOU want/think/need/desire?

We can help you with advice or suggestions, but don't forget that you will have to do some work on your own (But us already-addicts think thats most of the fun!)
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 16, 2014, 12:02 am
Michael, I'm having second thoughts about my suggested circuit. The problem is, if running on batteries, e.g. 3 x AAA, the voltage will be lower than 5V and will drop further still as the batteries drain. With the 2 leds in series, when the voltage drops below 4V, the leds may refuse to light up at all.

So I think connecting the leds in parallel would be wiser after all. See updated diagram. I have re-calculated the series resistors. As the leds are now in parallel, we can only afford to allow 10mA through each, to avoid overloading the Arduino pins. This should still be plenty bright enough. As only one led, plus its series resistor, will be dropping 5V, the resistor must now drop 3V.

R = V / I = 3 / 0.01 = 300 Ohms. Nearest common value is 330R.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 16, 2014, 01:36 am
Is it possible to use a 9v battery???
Would that be easier or harder???
Also the thought of the hall sensor would be cool...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 16, 2014, 09:04 am
A 9V battery would be easy enough while using the Nano. It has a built-in regulator. You would connect the battery to the Vin/RAW. Battery life will not be very good. 9V batteries do not have a large capacity, and the regulator will waste four ninths of that energy. With AA/AAA cells, you would bypass the regulator by connecting them to the Vcc/5V pin. Its important not to exceed 5.5V when bypassing the regulator, or the Arduino could be damaged. For example 4 non-rechargeable AA/AAA would be 6V, too much, whereas 4 rechargeable would be less than 5.5V even when freshly charged.

Using the tiny85 would be more difficult with a 9V battery. You would have to add a regulator to your circuit. This could be as simple as a 78L05 regulator (3 pins) and a couple of caps. But, as mentioned, four ninths of the battery's energy gets wasted.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 21, 2014, 05:05 am
I just want you to check this out before I hook it up...
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140820_220602_zpsgnlh0ue6.jpg)
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 21, 2014, 08:36 am
Sorry Michael, from that angle and with all those flying leads, I can't really tell what's connected to what. If you use short straight leads flat to the breadboard and take the picture from directly above, I might have a chance.

Having said that, looking at the 2 leds nearest the camera, I think it looks right as far as I can tell. If the other 2 are the same, you should be reasonably safe to connect up.

Here's an example of how I like to work on breadboard. Its a much more complicated circuit but I hope you get what I mean.

http://forum.arduino.cc/index.php?topic=188135.msg1392372#msg1392372

Have you got the Arduino software installed yet and uploaded a sketch? You shold be able to use the "blink" sketch from the examples menu to test your 4 leds. Just change the pin number in the sketch to match the one you have connected on the breadboard.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 22, 2014, 12:08 am
Here is some more pic's...
Hope these help...
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140821_164637_zpshjfdxwa4.jpg)
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140821_164616_zps3kb2qub2.jpg)
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140821_164610_zpsjfifzrfu.jpg)
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140821_164549_zpsoczescpn.jpg)
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140821_164534_zpstniyamot.jpg)
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140821_164525_zpsopdslfwe.jpg)

Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 22, 2014, 11:39 am
That was more than enough pics!

Ok, the leds look ok. The power connections from the Nano need fixing. Use the 5V pin, not Vin. Use the GND pin on that same side of the Nano, or if you prefer, both GND pins. Have another look at my pic on that link.

The common practice is to use black wire for GND, red for +V, and other colours for other signals.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 22, 2014, 07:03 pm
Can you help me out with the sketch???
I don't know how to even start one...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 22, 2014, 07:40 pm
Like I said before:

You shold be able to use the "blink" sketch from the examples menu to test your 4 leds. Just change the pin number in the sketch to match the one you have connected on the breadboard.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 24, 2014, 03:36 am
OK I got it up and running...
I have 1 problem tho...
I hooked everything up to your diagram but I couldn't get it to run only the first LED would only light up so
I had to use 2 Pins D3 and D4...
I have 2 sketch's that will run now Slow and Fast...
Here is the links...
Slow
http://vid1078.photobucket.com/albums/w495/jamestkirk1864/20140823_210609_zpslghn2fbj.mp4 (http://vid1078.photobucket.com/albums/w495/jamestkirk1864/20140823_210609_zpslghn2fbj.mp4)
Fast
http://vid1078.photobucket.com/albums/w495/jamestkirk1864/20140823_210712_zpsdqv6g8m0.mp4 (http://vid1078.photobucket.com/albums/w495/jamestkirk1864/20140823_210712_zpsdqv6g8m0.mp4)

Here is a pic of the new layout...
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/20140823_212938_zpsxb9hv8am.jpg)
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 24, 2014, 11:46 am
Good work Michael!

But it should have worked fine with just one digital pin. If I get time later I will set it up on my breadboard to show you. You do know leds only work if plugged in the right way around?

What next? Do you have a pot (potentiometer/trimmer/variable resistor)? You could wire that up to an analog input as a temporary replacement for the hall sensor/thermistor and use it to vary the flashing speed.
Title: Just wondering ...
Post by: Paul__B on Aug 24, 2014, 02:12 pm
Why are we using an Arduino to do the job of a NE555?

:~
Title: Re: Just wondering ...
Post by: PaulRB on Aug 24, 2014, 02:39 pm

Why are we using an Arduino to do the job of a NE555?

:~



Michael wants some beep tones, some fading leds and a thermistor, hall sensor or something. This is just the first step. The plan is to use a tiny85 for the final version.
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 24, 2014, 04:03 pm
Michael, how about one of these hall sensors:

http://www.ebay.co.uk/itm/HALL-EFFECT-SENSOR-SIP-3-1301-Part-A1301EUA-T-/350819442998?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item51ae77e136

They should be easy to use, just connect the leads to 0V, 5V and an analog input on the Arduino. The reading from analogRead() should be around 512 when no magnetic field is present, but will rise above that or fall below it when north or south poles of magnets are detected.
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 24, 2014, 08:43 pm
Hi Michael, here is the circuit with the 4 leds using only one Arduino pin:

http://youtu.be/LAaBVV0uHVc

And next with a pot to control the speed:

http://youtu.be/jUOlHL1nZZg
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 24, 2014, 10:54 pm
Paul what sketch did you use for that???
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 24, 2014, 11:09 pm
Is there a way to have it blink at one rate for so long then blink at another rate for so long in the same sketch???
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 24, 2014, 11:34 pm

Paul what sketch did you use for that???


This is just the "blink" example sketch with a couple of adjustments:
Code: [Select]
/*
  Blink
Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 2;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  int d = analogRead(A1);
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(d);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(d);               // wait for a second
}
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 24, 2014, 11:36 pm

Is there a way to have it blink at one rate for so long then blink at another rate for so long in the same sketch???


Yes, all perfectly do-able.
Title: Re: Klingon Proton Collector
Post by: Paul__B on Aug 25, 2014, 01:12 am

Is there a way to have it blink at one rate for so long then blink at another rate for so long in the same sketch???
Thanks
Michael

Hey, we are dealing with a microprocessor here, it's no slouch.

If you program it to do so, it can do hundreds of different patterns before breakfast.   :D
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 25, 2014, 01:34 am
The reason I ask this is we wouldn't need a pot to adjust the lights if
we can have it speed up after a certain amount of time...
Can we still use the Piezo speaker to make sound for it???
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: dave-in-nj on Aug 25, 2014, 05:24 am
thread started on the 11th.

yes,, yes and yes again.

you have have the lights blink the lights get bright (the other lights, not just the X ones)
have the X lights blink faster or slower
have the sound increase in pitch or volume. as you please
all at the same time.

you missed what others offered.  adding a HALL sensor, a metal detctor really, so if you put the unit on drywall, it will blink slow, but when it 'finds' a metal stud or nail it will start blinking faster.

and yes.. you have have it blink faster and faster until the chambers fill.

There are lots of ways to use a sensor that it has to 'find' some thing.   I like needing power such as a wire in a wall,

all these are possible, and there have already been code provided.

now it is time you grabbed the bull by the horns and start learning how to program.
as you learn, you will figure out what external senors you want and what speed you want and how you want to control it.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 25, 2014, 06:46 am
What I read about hall sensors is that you have to use a magnet to
make them work that's why I was steering away from them...
Even the videos I have seen about hall sensors say you need a magnet...
I'm doing this slow so I can learn it i'm not a fast learner when it comes to this...
Plus we haven't discussed about the other 2 LED's yet...
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 25, 2014, 09:46 am
A hall effect sensor will detect wires inside a wall where there is a current flowing. Any current creates a magnetic field around it and the hall sensor will pick this up.

They can also be used to detect metal (ferous) objects. What you do is fix a small magnet in place next to the hall sensor. This will give a certain reading. Then if a large ferous object comes close, it will affect the magnetic field produced by the magnet, and the sensor reading will change.

If you just want the proton collector to fill up based on a simple timer for now, I can write you a simple sketch to get you started, based on the blink sketch. But you must make the effort to understand the sketch and not be afraid to learn by experimenting with it. I don't want you to become reliant on me or anyone else here to write all your sketches for you.
Code: [Select]
/*
  Klingon Proton Detector Sketch
*/

int xleds = 2;
int xledDelay = 1000; // Controls the rate of the X-leds flashing

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(xleds, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(xleds, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(xledDelay);               // wait for a second
  digitalWrite(xleds, LOW);    // turn the LED off by making the voltage LOW
  delay(xledDelay);               // wait for a second
 
  xledDelay -= (xledDelay - 50) / 50; //increase the flashing speed a little
}


But first things first. See if you can get the X leds running from a single digital output on your breadboard.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 25, 2014, 04:34 pm
I did get it running with a single output...
The boards i'm using only has one power/ground rail on each side...
I ordered a new board... also I found out why it wasn't working with only
one pin the power rail on my board must have a break in the board
because it wasn't powering the LED's...
I'm using another board that I have so it works now...
I'll try the new sketch to see how that works out...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 25, 2014, 08:18 pm
http://youtu.be/_AHS8KmIZeY
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 26, 2014, 12:10 am
OMG that was awesome...
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 26, 2014, 01:48 am
You're welcome!

Code: [Select]
/*
 Klingon Proton Collector Sketch
*/

int xleds = 2;
int levelled = 10;
int spkr = 4;
int xledDelay = 1000; // Controls the rate of the X-leds flashing

// the setup routine runs once when you press reset:
void setup() {                
 // initialize the digital pin as an output.
 pinMode(xleds, OUTPUT);
 pinMode(levelled, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
 analogWrite(levelled, map(xledDelay, 1000, 0, 0, 255));
 digitalWrite(xleds, HIGH);   // turn the LED on (HIGH is the voltage level)
 tone(spkr, 1000, 50);
 delay(xledDelay);               // wait for a second
 digitalWrite(xleds, LOW);    // turn the LED off by making the voltage LOW
 tone(spkr, 2000, 50);
 delay(xledDelay);               // wait for a second
 
 xledDelay -= (xledDelay) / 50; //increase the flashing speed a little
}
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 26, 2014, 11:53 pm
Well I got it hooked up kinda messy on this board...
It will be better when I get the new stuff in the mail...
Here's the link...
https://www.youtube.com/watch?v=jc9WCtTIx0Q (https://www.youtube.com/watch?v=jc9WCtTIx0Q)
Next is to program it to the ATTiny85...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 28, 2014, 01:06 am

Next is to program it to the ATTiny85...


I made a little vid for you. Sorry, some of the screen shots are blurred!

http://youtu.be/bVIOAWCRuwg

Detail of circuit below.
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 28, 2014, 11:06 pm
Well, I've got the whole KPC thing running on the tiny85.

Not without problems though. The reason is, I'm pretty sure, because of things called timers. Timers, as you would expect, allow the chip to measure short periods of time. In the sketch that we have running on the Nano uses a total of 3 timers:

1. for use by the tone() function, which uses a timer to create a particular pitched tone
2. for use by the analogWrite() function, which uses a timer to create the PWM signal to fade the leds
3. for use by the delay() function, which uses a timer to time each millisecond pause

The mega328 chip on the Nano has 3 timers. But the tiny85 only has 2! As a result, the tone() function would not work on the tiny.

So I had to write an extra function to make a beep.

http://youtu.be/t4QpinL3Pt0

You see a strange pulsating effect on the fading leds on this video. It looks cool, but unfortunately you don't see it with the naked eye. Must be to do with the frame rate of the camera vs the PWM frequency.

Code: [Select]
/*
 Klingon Proton Collector Sketch
*/

int xleds = 4;
int levelled = 1;
int spkr = 0;
int xledDelay = 1000; // Controls the rate of the X-leds flashing

// the setup routine runs once when you press reset:
void setup() {                
 // initialize the digital pin as an output.
 pinMode(xleds, OUTPUT);
 pinMode(levelled, OUTPUT);
 pinMode(spkr, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
 analogWrite(levelled, map(xledDelay, 1000, 0, 0, 255));
 digitalWrite(xleds, HIGH);   // turn the LED on (HIGH is the voltage level)
 beep(50, 50);
 delay(xledDelay);               // wait for a second
 digitalWrite(xleds, LOW);    // turn the LED off by making the voltage LOW
 beep(25, 100);
 delay(xledDelay);               // wait for a second
 
 xledDelay -= (xledDelay) / 50; //increase the flashing speed a little
}

void beep(byte d, byte l) {
 
 byte v;
 noInterrupts();
 for (byte i=0; i<l; i++) {
   digitalWrite(spkr, v);
   delayMicroseconds(d);
   v = !v;
 }
 interrupts();
}  


I said earlier I did not want to do it all for you, but it turns out I have. Hope its been an interesting introduction to Arduino for you, it entertained me for a couple of hours. Let us know how you get on and any problems you encounter.

Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 29, 2014, 04:41 am
As far as the capacitors on your board I can't get the .1J63
can I use these instead???
http://www.ebay.com/itm/100-x-0-1uF-50V-Ceramic-Disc-Capacitors-Free-Shipping-/280968355990?pt=LH_DefaultDomain_0&hash=item416b04e096 (http://www.ebay.com/itm/100-x-0-1uF-50V-Ceramic-Disc-Capacitors-Free-Shipping-/280968355990?pt=LH_DefaultDomain_0&hash=item416b04e096)
Also what size of capacitor is the black one you are using???
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 29, 2014, 07:35 am
Yes, any 0.1uF cap will be fine.

The anti-reset cap was a 10uF, but the value is not critical. Probably anything 1uF or above would work.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 30, 2014, 04:23 am
Here is a short clip of the programmed chip...
Not the final just the test...
http://vid1078.photobucket.com/albums/w495/jamestkirk1864/20140829_215605_zps635ee5c6.mp4 (http://vid1078.photobucket.com/albums/w495/jamestkirk1864/20140829_215605_zps635ee5c6.mp4)
Can I program the chip with the board the way it is or do I need to
move it back to the other board and program it to the final version???
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 30, 2014, 09:09 am
If I understand what you're asking, then yes you can upload the final kpc sketch to the tiny85 now, then move the tiny85 to the other board and connect it up to the xleds, speaker etc.
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 31, 2014, 06:07 am
I got it finally found out what I did wrong...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 31, 2014, 08:07 am
So its working on the tiny85? Great!

That 0.1uF cap wasn't just for programming. It should be with the tiny on the final circuit, as close to the tiny's Vcc and GND pins as possible. (The other, larger, cap was just or programming).
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 31, 2014, 07:12 pm
Is there a way to get the single LEDs not to flash when the other 4 are blinking in there sequence???
Also there dim when it starts up and bright when it is done...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 31, 2014, 08:01 pm

Is there a way to get the single LEDs not to flash when the other 4 are blinking in there sequence???

They shouldn't be flashing. They are supposed to fade up gradually, like in the movie.


Also there dim when it starts up and bright when it is done...

They are fading up and flashing?
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 31, 2014, 08:26 pm
It is just a slight flash not a blink...
I see it in yours also...
I also didn't see but the 2 LEDs do get brighter as it gets fuller...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 31, 2014, 09:23 pm
Quote
You see a strange pulsating effect on the fading leds on this video. It looks cool, but unfortunately you don't see it with the naked eye. 


Is yours flashing to the naked eye? It shouldn't be...
Title: Re: Klingon Proton Collector
Post by: jameskirk on Sep 01, 2014, 01:41 am
We are good I just looked at it again with the lights out it is my eyes playing tricks on me...lol...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: PaulRB on Sep 01, 2014, 08:11 am
Great. So how are things looking for fitting this all into the replica movie prop?
Title: Re: Klingon Proton Collector
Post by: jameskirk on Sep 16, 2014, 04:16 am
I have not finished my Klingon Proton Collector yet...
I'm doing the touch up and patching the rough spots on the prop
before I add the electronics...
Thanks
Michael
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 04, 2016, 05:10 am
Well I finally have it done.
Here is a video clip.
Proton Collector (http://vid1078.photobucket.com/albums/w495/jamestkirk1864/Proton%20Collector/Screenshots/Power%20Leech%20011_zpso91gqyzb.mp4)
Title: Re: Klingon Proton Collector
Post by: PaulRB on Aug 04, 2016, 08:26 pm
Wow! Was that really two years ago? What batteries did you use in the end?
Title: Re: Klingon Proton Collector
Post by: jameskirk on Aug 05, 2016, 02:40 am
I used 3 AA Batteries.
(http://i1078.photobucket.com/albums/w495/jamestkirk1864/Proton%20Collector/Misc/Mikes%20Leech%20Build%20061_zpsleipzntm.jpg)

Here is what I did with the handle.
I used a magnet to turn it on and off.
Handle (http://vid1078.photobucket.com/albums/w495/jamestkirk1864/Proton%20Collector/Misc/Power%20Leech%20009_zpsabmwqhbz.mp4)
Thanks for all your help Paul
Michael