Pages: [1]   Go Down
Author Topic: Larson Scanner, Anyone?  (Read 1567 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 56
Posts: 2186
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
//                             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.



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

* LarsonViaPortBD.pde (12.35 KB - downloaded 38 times.)
* LarsonViaPortBD_b.pde (12.35 KB - downloaded 32 times.)
« Last Edit: June 14, 2013, 09:27:18 am by Runaway Pancake » Logged

"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?"

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Offline Offline
Edison Member
*
Karma: 56
Posts: 2186
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.


Logged

"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?"

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4554
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PWM can be done in software...! smiley
« Last Edit: June 13, 2013, 04:17:37 am by fungus » Logged

No, I don't answer questions sent in private messages...

0
Offline Offline
Full Member
***
Karma: 0
Posts: 102
Where's the Kaboom?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2186
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


"SoftPWM library"... not required.

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

Go with it or don't.
Logged

"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?"

Canberra Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 504
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Offline Offline
Edison Member
*
Karma: 56
Posts: 2186
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

* Larson_8_PortBD.pde (10.04 KB - downloaded 26 times.)
Logged

"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?"

Offline Offline
Edison Member
*
Karma: 56
Posts: 2186
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

* brtdimbounce.pde (9.59 KB - downloaded 15 times.)
Logged

"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?"

Grand Blanc, MI, USA
Online Online
Faraday Member
**
Karma: 71
Posts: 3515
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have one of these, works well, nice kit!
http://shop.evilmadscientist.com/productsmenu/tinykitlist/152-scanner
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Canberra Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 504
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that Runaway,

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

Pedro.

Edit - just connected it up. Nice thank you.
« Last Edit: June 14, 2013, 05:21:55 pm by Pedro147 » Logged


Offline Offline
Edison Member
*
Karma: 56
Posts: 2186
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)

* outward_8.pde (6.92 KB - downloaded 17 times.)
* static_fading_8.pde (1.92 KB - downloaded 21 times.)
Logged

"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?"

Canberra Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 504
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A clearer video of Larson Scanner, Anyone in action  smiley-cool

Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is my years Halloween project smiley Cylonscanner with Happy Pancapkes 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...  smiley-evil But it was perfect for fitting in a Jack-o-lantern... without getting pumpkin-goo on my Arduino board smiley

Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2186
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

"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?"

Pages: [1]   Go Up
Jump to: