Forum Index > Projects > Larson Scanner kit and LED Menorah kit support
 Pinball mod with a larson kit, couple of questions
 |  Printable Version
By: Anonymous: Sonny_Jim () on Sunday, February 12 2012 @ 01:27 AM PST (Read 6027 times)  
Anonymous: Sonny_Jim

Hi there, I've just received my Larson kit and very impressed with it and I have a few questions about how I can power it from the general illumination voltage on a pinball table (6.3VAC).

My plan is to mount some LED's underneath the plastic around the ball lock area on the table that 'scan' when the ball is grabbed by the magnet. Activating the scanner at the right time should be easy, a small burglar alarm sensor near the magnet should do the trick but I'm not too sure about how I am going to power it.

The bulbs for the general illumination run at 6.3VAC, am I right in thinking that if I build a rectifier from 4 diodes this would give me too much DC voltage and damage the components. Would adding in some resistors help to stop the damage or would they be likely to fail early.

Another thing I was consider was just doing half wave rectifcation, but by my reckoning this would only give me 2VDC, which I don't think would be enough.

Any ideas?





       
   
By: Windell (offline) on Monday, February 13 2012 @ 06:06 AM PST  
Windell

The microcontroller will work from about 3 to 5.5 V DC, and the LEDs are set up to work at 3 V (via the resistor choice on the PCB ). If you leave the default program on, it should actually work without hazard up to 5 V, even though it's pushing the limits of the chip.

The "obvious" solution is to use a full-wave rectifier (4-diode bridge, with a large cap following), followed by a 3 V regulator. You might also consider using the full wave rectifier with a common silicon diode (1N914, 1N4001, etc) or two in series, as each would drop the voltage by about 0.7 V.

You might also *try* a half-wave rectifier, but be sure to follow it with a large cap, at least 1000 uF.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: sdb (offline) on Monday, February 13 2012 @ 06:46 PM PST  
sdb

Short version: use a regulator. I don't know how much power the larson will use, but you probably had better start with a TO-220 package, not just one of the little TO92 guys, solely to handle the heat produced when throwing away so much of the incoming voltage (potentially 2x what the larson itself will be using).

Long version:

The issue is that typically when someone says "6.3 volts A.C." they mean RMS voltage.

When you rectify A.C. you get pulsating D.C. with the same peak voltage. (minus 0.7-1.4 volts due to diode losses of one or two diodes in the rectifier current path for each half cycle) In this case, that could be almost 7.5-9volts. (RMS volt multiplied by square_root(2) or about 1.4 times the RMS voltage.) Then when you add a capacitor, it will bring up the bottoms between pulses, but only slightly take off the top of each pulse.

It gets worse. Your input A.C. voltage (from your electric utility) can vary -10% to +20% and still be considered "normal". That variance will be passed thru to your 6.3VAC side and cause it to vary the same percentage. 9volts plus 20% is 10.8volts.

Full-wave vs. half-wave won't make a significant difference, except to make the bottoms lower, longer. It also eliminates one of the diode losses, so the peaks might be even higher. If you have enough capacitors to smooth out those bottoms then the voltage will be nearly the same as the full-wave version because the D.C. pulses still peak at the same or higher voltage.

Do NOT try to just feed the Larson thru a couple of diodes or resistors. It would be best to regulate, but you could probably make a voltage divider work but that requires math and some beefy resistors since they will get quite warm.

A voltage divider requires math. Let's assume the Larson will use 0.1amp and design a voltage divider to provide about 3volts given a 9volt input. First, you will need a 1/3 and 2/3 divider, and without the Larson attached it should be drawing more than 2x the needed current, so lets call it 300ma total. Rtotal = E/I = 9v/0.3a = 30ohms. Since you need 2/3 and 1/3 split you'll need a 10ohm resistor and a 20ohm resistor. They will need to be rated for about 3 watts and will get hot.

Wire the resistors in series across your rectified and filtered D.C. with the 10ohm to ground and the 20ohm to +v (so it goes Gnd---10ohm----20ohm---+Volts). Measure the voltage between the two resistors relative to ground, it should be 1/3 of the total. Assuming it is around 3volts, and well under 5volts, you can power the larson from that point.

Note... Resistors of those exact values will be expensive, but the precise values are not critical. Just keep the two about the same ratio and the total somewhere For example, you could use a 9.6ohm and a 21ohm. This does change the output voltage... If you make the smaller value a bit bigger you will get a higher voltage. Same if you make the larger value a bit smaller. Conversely you will get a smaller voltage if you make the lower value smaller or the higher value larger.

Note... If you make the total resistance higher the resistors will use less power, but also less power will be available for the Larson. If the resistors are too big, the larson will not operate properly. A 10uf or larger capacitor between ground and the resistor midpoint will help.

Now see why I said "use a regulator?" Smile


Forum Apprentice
Apprentice

Status: offline

Registered: 01/20/12
Posts: 6

Profile      
   
By: Windell (offline) on Monday, February 13 2012 @ 07:54 PM PST  
Windell

It turns out that the Larson Scanner requires remarkably little current, about 25 mA on the 'bright' setting and 4 mA on the 'dim' setting, when running at 3V with standard firmware and resistors. (You can run it on a coin cell!)

If you start with 9 V, and use a 3 V regulator, that's 6 V to drop at 25 mA, or 150 mW. Even one of the dinky TO-92 "150 mA" regulators will only go about 20° above ambient at the junction. A zener diode that drops 5-6 V will also be just fine, with current that low. So while sdb's advice is good in general, this *is* a case where you have a bit of leeway.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: Sonny_Jim () on Tuesday, February 14 2012 @ 02:58 AM PST  
Anonymous: Sonny_Jim

Cool, thanks for the replies. I will sit down and have a proper digest of them later, but first glance I think I'll go with a 4 diode rectifier with a regulator and a couple of caps behind it.

I'm just wrestling with AVR Studio 5 and it's debugging tools, this is all new stuff to me so it's a very steep learning curve.






       
   
By: Anonymous: Sonny_Jim () on Tuesday, February 14 2012 @ 07:28 AM PST  
Anonymous: Sonny_Jim

How about something like this?

http://uk.rs-online.com/web/p/linear-regulator/6869638/





       
   
By: Windell (offline) on Tuesday, February 14 2012 @ 10:22 AM PST  
Windell

That ought to be fine *if* you are not planning to reprogram it. If you are going to reprogram it, you need to be aware that your program may use significantly more current, and should pick a larger regulator, as sdb says, in a TO-220 package.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: Sonny_Jim () on Thursday, February 23 2012 @ 09:38 PM PST  
Anonymous: Sonny_Jim

I've ordered a USBtinyISP from China so at the moment I am waiting for it to turn up. The modifications I plan to the source code are very small, one would be to start up in the lighting configuration I prefer and the other would be to make the LED's scan when a button is pressed (reed switch near the ball lock magnet). I'm not planning to light up any more LED's and I'm going to be using the stock code so I'm hoping the current draw will be similar.

I'll post back in here once I finally get it finished, but I'm getting a bit sidetracked by the Raspberry Pi atm :-)





       
   
By: Anonymous: Sonny_Jim () on Sunday, February 26 2012 @ 09:21 PM PST  
Anonymous: Sonny_Jim

Ok, so my USBTinyISP has turned up and I've been pleasantly surprised as to how easy it was to get it all hooked up. I've been hacking around with the larson.c code and I've got a few questions about it:

PHP Formatted Code
if (direction == 0)  // Moving to right, as viewed from front.
                        {  
                                ILED = (15+position) >> 4;
                                RLED = (15+position) - (ILED << 4);
                                MLED = 15 - RLED;              
                        }
                        else
                        {  
                                ILED = (127 - position) >> 4;  
                                MLED = (127 - position)  - (ILED << 4);
                                RLED =  15 - MLED;     
                        }


In the section above, what does ILED, MLED and RLED refer to?

PHP Formatted Code

j = 0;
                        while (j < 5)
                        {
                                if (direction == 0)
                                        m = ILED + (2 - j);     // e.g., eyeLoc[0] = ILED + 2;
                                else
                                        m = ILED + (j - 2);  // e.g., eyeLoc[0] = ILED - 2;
                       
                                if (m > 8)
                                        m -= (2 * (m - 8));
                       
                                if (m < 0)
                                        m *= -1;
                       
                                eyeLoc[j] = m;
                                j++;
                        }
                 
                        j = 0;          // For each of the eye parts...
                        while (j < 4)
                        {
                                LEDs[eyeLoc[j]]   += LEDBright[j]*RLED;                
                                LEDs[eyeLoc[j+1]] += LEDBright[j]*MLED;                
                                j++;
                        }
 


I'm a little perplexed by the above code, could someone walk me through it or at least give me some pointers as to what it's doing? Thanks.





       
   
By: Windell (offline) on Monday, February 27 2012 @ 12:07 PM PST  
Windell

> In the section above, what does ILED, MLED and RLED refer to?

Integer, Modulo, Remainder.

The position of the "eye" is modeled to move with resolution 16X that of the actual LEDs. The integer offset says how far over it is, and the modulo shows how much the leading pixel overlaps with the LED that it's at. The "remainder" is how much of the LED brightness is left in the next bin behind the leading LED.

The "eye" consists of FOUR pixels, and so the procedure is repeated for each of the four pixels, to calculate how much overlap they have with the physical LED locations. The net result is that the "eye" appears to smoothly move between pixels, rather than jump between them.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: brand () on Tuesday, February 28 2012 @ 11:44 AM PST  
Anonymous: brand

<Hmmm. No mood choice for "geeking out"...>

Not to argue with The Doctor, but this section is not quite that straightforward. There's a file here, http://www.drbrad.org/Larson-Sequence.pdf, that summarizes the values generated (I asked myself this same question a couple of months ago).

Ignoring 'robotmode' (for the Kraftwerk-inspired neckties), the variable 'position' counts from 0 to 127 and the variable 'direction' toggles between 0 and 1. That gives a cycle of 256 steps (the left-most two columns).

ILED essentially counts up from 0 to 8 (nine LEDs) and back down to 0, with each number occurring 16 times in a row (the ILED column). The numbers 1-7 occur twice in the full cycle; 0 and 8 only once. Position 0, (position == 0, regardless of direction) is a bit of a degenerate case that gives you an extra 0 (at the very beginning, giving 17 occurrences of 0 on wrap-around) and only 15 occurrences of 8, but that doesn't really affect things.

For each count of ILED (16 counts of position), MLED counts up from 0 to 15 and RLED counts down from 15 to 0 (again, position 0 is a one-off).

The loop beginning 'while (j < 5) ' then gives four indices (form 0 to 8) corresponding to the locations of the four LEDs making up the "eye" (the rightmost four columns of the PDF file).

The loop beginning 'while (j < 4)' is where the brightness is set using the indices from the previous loop ('LEDs[eyeLoc[j]]' and so on). Brightness is only used on four of the LEDs, but a fifth index is calculated so that the j+1 index doesn't do something bogus.

Note that the LED at eyeLoc[0] is only incremented by LEDBright[0]*RLED, while the other three are incremented by both LEDBright[j]*RLED and LEDBright[j-1]*MLED (the LED at eyeLoc[4], similarly to eyeLoc[0] only gets one increment: LEDBright[3]*MLED).

To see the calculations (and the intermediate value of 'm' in the first while loop), you can have a look at the live spreadsheet the PDF comes from: http://www.drbrad.org/Sequence.ods.

So, the real question is not what this routine is doing, but rather, what caffeine delivery vector the Mads were using when they came up with it? : - ) I have a the same question for the pulse-width modulation routine at the end of both this code and the menorah code.

Take care,
brad





       
   
By: Windell (offline) on Tuesday, February 28 2012 @ 12:28 PM PST  
Windell

>Not to argue with The Doctor, but this section is not quite that straightforward.

I was merely trying to provide "some pointers," as requested.

So, the real question is not what this routine is doing, but rather, what caffeine delivery vector the Mads were using when they came up with it? : - ) I have a the same question for the pulse-width modulation routine at the end of both this code and the menorah code.

Actually not much caffeine, just a lot of time with pencil and paper.

The "tricky" part of all this is that besides having the movement be smooth and bright, it has to use very little power. The kit runs on batteries, and how long it lasts is one of the most important figures of merit. The Larson Scanner kit hardware supports operation up to 8 MHz, but we've actually clocked the speed down to 512 kHz. This means that the CPU core (not including the LED power) uses only about 0.4 mA instead of about 4 mA. That may not sound like such a big difference, but if you recall that the Larson Scanner kit uses about 25 mA on the 'bright' setting and 4 mA on the 'dim' setting, this means that the low power mode is (in a sense) 90% efficient instead of 50% efficient.

So, if you're wondering why this is all short-integers and bit shifts (instead of graceful floats and div and mod operations), it's all about speed: we're trying to make this thing behave beautifully in a bare minimum of clock cycles. And, for better or worse, that sometimes ends up with code that looks as though it might have been purposefully obfuscated.

One of the things that we did while fine tuning the "eye" movement was to simulate it in Processing (where it's possible to draw true grayscale), using the same code for the eye sweep. There, without having to worry about PWM artifacts or CPU time, we spent some time calibrating the width of the "eye," and the model used for its decay, and (especially) the two endpoints of the "motion."


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: Sonny_Jim () on Sunday, March 04 2012 @ 08:30 PM PST  
Anonymous: Sonny_Jim

Cool, thanks for the detailed response, now all I have to do is read it a few times so I can better understand what's going on. My aim is to have the eye 'wraparound', so when the middle of the eye is at the bottom, the dimmer ones are shown up the top, rather than bouncing backward and forward.

It should be a fairly trivial mod but it's certainly making me scratch my head!





       
   
By: brand (offline) on Friday, March 09 2012 @ 11:25 PM PST  
brand

So, yeah, this mod is fairly trivial in concept, but there are some wrinkles in practice.

Essentially, you just want to set the eye via modulo 9 arithmetic. That is, the index of the eye (technically, the third of four LEDs in the eye) is set to the remainder of dividing ILED by 9 [recall that ILED is (15 + position) / 16, where the division is integer division done by just shifting the bits four to the right. The Doctor's comments on code efficiency -- one-byte values and bit shifting -- are very well-founded].

Just for review, the first lit LED is ILED + 2 (adjusted to stay in range) and the last lit LED is ILED - 1 (adjusted). In the Larson scanner, ILED goes through 16 positions: this isn't how the code is written, but you can think of it as LED[0]-to-LED[7] in one direction and LED[8]-to-LED[1] in the other direction. Lather, rinse, repeat. (By the way, the addition and subtraction are reversed when the direction changes).

The variable 'position' is a modulo 16 on a counter from 0 to 127 with a direction bit of 0 or 1, so each position is repeated 16 times (8 times at speedlevel 3, where position is incremented twice each time through the loop). This gives 256 steps: 16 steps of 16 counts each -- all nice, neat powers of 2. That's all illustrated in the PDF file I linked to before.

Where things get goofy for the wrap-around version is that ILED now goes through *9* positions: essentially LED[0]-to-LED[8]. Repeat.

Which means that instead of 256 steps (16 * 16), we need 144 steps (16 * 9), so now 'position' counts from 0 to 143. We're not changing direction, so we can throw that bit away, but we still want RLED and MLED to do their counts to set brightness. This is all illustrated in this file: http://www.drbrad.org/WrapSequence.pdf.

So, what we're doing is much simpler: take ILED (position modulo 16) and
* Add 2 for the front LED
* Add 1 for the next LED
* Add 0 for the next LED
* Subtract 1 for the last LED
Each time we do the arithmetic, we check the value and
* If it's less than 0, we add 9
* If it's more than 8, we subtract 9

This is the equivalent of taking each index modulo 9, but you never want to do arithmetic division operations (and modulo depends on division, at least for non-powers-of-2 divisors) if you're at all interested in efficiency.

The result is a recurring sequence of values from 0-8 that we use for the eyeLoc[] array.

I made the changes and totally over-commented the code. Normally, I would've diked out stuff instead of just commenting it out, but I left it in for comparison (diff files are a much better way to go, but I don't know where you're at). It's here: http://www.drbrad.org/larson.c. You'll need to put it in a directory with the larson_14 makefile to install it (I would've put together a zip file, but you never know where those things have been).

A couple of nuances: it looks better at higher speed, and you should probably try it with 'skinnyEye' mode on by holding the button down at power-on.

Enjoy.

Take care,
brad


Forum Apprentice
Apprentice

Status: offline

Registered: 02/27/12
Posts: 10

Profile Email    
   
By: Anonymous: Sonny_Jim () on Thursday, April 12 2012 @ 06:39 AM PDT  
Anonymous: Sonny_Jim

That's absolutely awesome, thanks Brad! That's exactly what I was looking for and the code is easier to read now it's indented. All that I need to do know is modify it so that the lights run are triggered from a reed switch, and only to run for a few seconds before stopping again. Then all that's left is get a 3V regulator and I'll have this fun little project done!

I've just bought a 5M of SMD 5050 LED's along with some MOSFETs and another Larson scanner kit, hopefully going to make some cool lighting effects!

Thanks again






       
   



 All times are PDT. The time is now 06:50 PM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?