Go Down

Topic: Larson Scanner, Anyone? (Read 3 times) previous topic - next topic

Runaway Pancake

Jun 12, 2013, 03:06 am Last Edit: Jun 14, 2013, 04:27 pm by Runaway Pancake Reason: 1
Maybe somebody has already done one this way, but I cannot find anything similar based on 'Search'.

First, there are a lot of LED back-and-forth, running lights jobs out there; many of them claiming to be "Larson scanners".  But a "Larson scanner" needs a trail of dimmer lights following the leading light.  Whether he was the inventor as such I'm not sure, but when Glen Larson did these for Battlestar Galactica (Cylons) and Knight Rider (KITT), he used light bulbs and the bulbs' incandescence (their residual glow) made for the trailing effect.  
LEDs go on/off rapidly, there's no continuing glow-down when they go off, no gradual fade out.

So - how could that be done with LEDs?

Whip out your Arduino?  Good start, but still.
Use the PWM pins?  There are only six.
Charlieplex? Stop already.
Glom some "library"?  Not me.
Off-board circuitry, something MAX-blah-blah?  Totally unnecessary.

I worked it out with 10 positions.
I didn't use any PWM pins as such, no libraries, or any of that - just a stock Arduino with 10 LEDs and 10 resistors.
I used a "lightbar" because it was handy, made for a small footprint.  T1 LEDs could fit within the confines of a small protoboard or a "proto-shield".



The Arduino paradigm focusses on digitalWrites, but that would have made for a lot of flicker.  The key is "Port Manipulation", poking (as we used to say in C64 BASIC) the PORTB and PORTD registers, getting the data out in parallel.  Actually, there are two such operations: the PORTB chunk and the PORTD chunk.

I arranged an array of "frames" composed of 12 words each, bits 2 - 11 correspond to Digital pins.
In the following examples, "Frame 1" begins with the leading LED in bit 7 and in "Frame 2" it's in bit 8.
Code: [Select]

//                             11
//                             1098765432    
const word dimbits[] = { 0b0000000011111100, // frame 1
                        0b0000000011111000,
                        0b0000000011110000,
                        0b0000000011100000,
                        0b0000000011000000,
                        0b0000000010000000,
                        0b0000000010000000,
                        0b0000000010000000,
                        0b0000000000000000,
                        0b0000000000000000,
                        0b0000000000000000,
                        0b0000000000000000,
//                             1098765432                                
                        0b0000000111111000, // frame 2
                        0b0000000111110000,
                        0b0000000111100000,
                        0b0000000111000000,
                        0b0000000110000000,
                        0b0000000100000000,
                        0b0000000100000000,
                        0b0000000100000000,
                        0b0000000000000000,
                        0b0000000000000000,
                        0b0000000000000000,
                        0b0000000000000000,

Long story short: the brighter an LED is supposed to be, the greater the number of times it shows up in a frame's words.

In the sketch (PDE attached), each word gets read and split into two bytes that are written to their respective port registers.  The sketch grabs each line at machine speed, it strafes.  The variable times_out sets the speed, it's the number of times that all 12 lines in the "frame" get read and output (put out?).
In the demo, times_out = 7500 makes for a leisurely procession; 100 would make a solid bar while 100000 would be agonisingly slow.

http://www.youtube.com/watch?v=o66bi_jEBoQ

Sorry if it's a little blurry, but you should just get the idea, get it together and put it together, upload the sketch and enjoy.

[So, "noobs", et al., grab the sketch and place it in a file with the same name (LarsonViaPortBD). ]

> > > While tending to a request, I found a discontinuity in one of the dimbit[] words and corrected that in LarsonViaProtBD_b.pde
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

KirAsh4

This is similar and has been "out there" for a long time now:

http://blog.blinkenlight.net/experiments/basic-effects/knight-rider/

Runaway Pancake


Mine doesn't require anything extra, a "proto-shield" would be nice, maybe, but a solderless breadboard will make it happen.
My method of "PWM" is different and by composing a series of frames anyone should be able to come up with others patterns and effects fairly easily.
And I've put it all out on the table, "how to do it" doesn't get more complete.


"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

fungus

#3
Jun 13, 2013, 11:12 am Last Edit: Jun 13, 2013, 11:17 am by fungus Reason: 1
PWM can be done in software...! :)
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Marvin Martian

Check out the SoftPWM library - not only will it allow you to PWM all the pins, but has built in support for fade up and fade down of values over time, which is exactly what you need for such an application

Runaway Pancake


"SoftPWM library"... not required.

I came up with this because it's a n00b-faq.

Go with it or don't.
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Pedro147

Hi "Dr Pancake"
Quote
Actually, it's Doctor Pancake,
But anyway...  (:

I have played around a little with direct port maniplulation and also Larson scanner code that I found using hardware PWM but found this restricting due to there only being six PWM pins on the Arduino Uno. I have also used the Blinkenlight code which I did manage to modify from his ten LED's to the eight that I normally use for these types of code.  would like to try your code but with only eight LED's and I must admit that despite your thorough explanation I still do no quite get it. Would you mind showing me how to adapt it to using only eight LED's and I will try and work out how it works. Thanks if you can help Pedro.
http://www.pedroduino.com

Runaway Pancake

OK, I'm easy - see attached PDE.

I noticed a discontinuity (error) in one of the words in the dimbits[ ] array.
[Now, The Universe is back in balance and many lives have been spared.]

Its length is four segments, use digital outputs 2 - 9.
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Runaway Pancake

And, to shed more light on the subject, the attached sketch has two LEDs bouncing back and forth opposite each other, one is dim and one is bright, 8 positions/LEDs.
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Jack Christensen

I have one of these, works well, nice kit!
http://shop.evilmadscientist.com/productsmenu/tinykitlist/152-scanner
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Pedro147

#10
Jun 14, 2013, 11:57 pm Last Edit: Jun 15, 2013, 12:21 am by Pedro147 Reason: 1
Thanks for that Runaway,

and glad to hear that you have restored cosmic harmony, may the force be with you  8) I can sleep easy tonight

Pedro.

Edit - just connected it up. Nice thank you.
http://www.pedroduino.com

Runaway Pancake

Here are two more examples:

outward_8.pde has two leaders starting from the innermost and proceeding outward (no bounce)

static_fading_8.pde is just a strip of fading (frozen)
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Pedro147

A clearer video of Larson Scanner, Anyone in action  8)

http://www.youtube.com/watch?v=VI8g4giMCYY
http://www.pedroduino.com

Sourcery

#13
Oct 28, 2013, 09:48 am Last Edit: Aug 12, 2014, 01:10 pm by Sourcery Reason: 1
Here is my years Halloween project :) Cylonscanner with Runaway Pancakes code above... THANKS, it worked awesome and super easy to implement...

I Did it as a standalone board with just 10 LEDS, an ATMega328 and a Oscillator Resonator. Yeah I know I cheated and skipped the resistors...  ]:) But it was perfect for fitting in a Jack-o-lantern... without getting pumpkin-goo on my Arduino board :)

http://www.youtube.com/watch?v=FDa46I3XnQk

Runaway Pancake

The resistors were just a bridge too far then?
[The old LEDs sans resistors jack-o'-lantern exigency.   :smiley-mr-green:  ]

"Happy Pancapkes"?  Who's that?
Like the man said about military fame, it's: "to be killed on the field of battle and have your name misspelled in the newspapers"

Happy Samhain, kids!
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Go Up