Shop OBEX P1 Docs P2 Docs Learn Events
Suggestion: Light-pen — Parallax Forums

Suggestion: Light-pen

Nick MuellerNick Mueller Posts: 815
edited 2007-04-12 08:10 in Propeller 1
Hi!

Decades ago, I have built a commercial "high-res" (512 x 256 pixels; B&W) for the APPLE ][noparse][[/noparse]. The distinct feature was a light-pen.
It was some fibre-optics cable (the cheap plasics type), a photo-transistor and an amplifier. The graphics-chip supported that light-pen and the location the event occured (accurate to +/- 2 lines and 8 pixels wide) could be read from some GDP's register.

Just now, I got the idea of having one for the Propeller. I'm not in the situation to modify the VGA or TV routines (yet) but if someone thinks that it is doable, I could spend some time reinventing the electronics.
Electronics were a bit tricky because of noise and low signal. So it required some shielding for the amplifier and a low-noise high gain OpAmp.

Anybody wanting to pick that idea?

Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-04-10 15:47
    A couple things come to mind:

    1. You don't really have to modify the graphics routines. Just monitor their sync outputs in another cog to get the timing info.

    2. The lightpens of yesteryear were all used with CRTs, which used a (hard) glass faceplate. Now we've got flat panel LCDs with (soft) plastic faceplates, which are much easier to scratch. Somehow, this has to be addressed by the choice of pen tips.

    -Phil

    Update: As subsequent posters have pointed out, a lightpen wouldn't work with an LCD anyway: STNs switch too slowly and TFTs are always on. ('Hadn't had my coffee yet. wink.gif )

    Post Edited (Phil Pilgrim (PhiPi)) : 4/10/2007 5:19:57 PM GMT
  • Jasper_MJasper_M Posts: 222
    edited 2007-04-10 15:53
    Actually, the lightpens detect the drawing beam location. LCDs don't have anything like that, so light-pens won't probably work at all with them.
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-04-10 15:57
    > Actually, the lightpens detect the drawing beam location. LCDs don't have anything like that, so light-pens won't probably work
    > at all with them.

    Oh, they are to slow. And they also do have segments that work in parallel. You are right! Fogettid!
    Would only work on a CRT (remember?)


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-10 16:25
    Don't dump that idea just yet...

    It would still be very cool on the composite side...

    Perhaps a modification to the TV driver is in order?

    Oldbit
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-04-10 16:44
    > It would still be very cool on the composite side...

    It only works on a CRT. The problem is detecting the signal. On a CRT, the signal has a very fast attack and a *very* slow decay. Not so on an LCD (but I never scoped one with a photo-transistor).
    It would be best to trigger on the slope (differentiation) and the level, but I just triggered on the level (IIRC). That worked good enough, because we sold a complete system (medical stuff) and the sensitivity could be adjusted.

    But who is using a CRT nowadays? Not that many. OTOH, OSD with a lighpen for a TV-set would be cool. smile.gif

    For what I thought about using it, CRTs aren't used.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO

    Post Edited (Nick Mueller) : 4/10/2007 9:14:21 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-04-10 17:00
    Today's equivalent technology is a touch screen, I have a couple at my desk that Ive thought of trying to interface with, but they are both USB interface. Thought about using a VDIP, but I dont know if·thier HID class drivers would work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 4/10/2007 5:12:27 PM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-10 18:19
    Nick Mueller said...
    > It would still be very cool on the composite side...

    But who is using a CRT nowadays? Not that many. OTOH, OSD with a lighpen for a TV-set would be cool. smile.gif


    My setup is a corner table with a large/heavy 25" TV at one side, and a VGA monitor to my left.
    Guess I'm one of the last to upgrade... sob...

    Oldbitcollector
  • Shane De CataniaShane De Catania Posts: 67
    edited 2007-04-11 02:24
    Hi Paul,
    Funny you mentioned touch screens, I was just discussing a new project this morning and suggested using a propeller and an 8 inch VGA touch screen. I had exactly the same idea in mind (using a VDIP). My client was very interested in an all-in-one unit rather that having to have a separate PC for the user interface and is now sold on the idea! Of course I don't have a touch screen at hand as yet, and can't be 100% sure it will be doable. Paul is there any chance you could hook up the gear you have and tell me how you went and what brand of monitor you used? That would be really appreciated. Thanks in advance.
    Cheers,
    Shane.

    PS Sorry slightly off topic - I like the light pen idea too... I'll keep a CRT screen handy!
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-04-11 04:47
    Sadly I dont have my VDIP anymore, it was appropriated for another use. I'll see if we have another not in use for the test. The touch screens I have are from Maple. I found it online and it turned out thier headquarters is about a mile from our Chinese associates; so I had them go in person and pick up a couple units to ship to us. The downside is all the controls are in Chinese, so I have no clue how to adjust them (they can be reflashed to another language, but these aren't); fortunately they have an auto-adjust button which works well enough.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2007-04-11 05:05
    For LCD screens or CRT screens, you could allow a program to do a X/Y sweep of the screen when a button on the light pen is pressed. Just look for the "blip" on the light-pen sensor to determine position.

    Pseudo code: (Assume screen resolution is 256 by 192)

    1) If Button On Light Pen is pressed, blank screen and proceed with steps 2 through 4 
    
     
    2) For X = 0 to 255 
           line (X,0)-(X,192), white 
           {Monitor Light Pen input for X position} 
           line (X,0)-(X,192), black 
       Next X 
    
     
    3) For Y = 0 to 191 
           line (0,Y)-(255,Y), white
           {Monitor Light Pen input for Y position} 
           line (0,Y)-(255,Y), black 
       Next Y 
    
    4) Restore Original Screen
    


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 4/11/2007 5:09:57 AM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-04-11 06:07
    It's been a while since I've held one of those light-pens in my hand (and I'm a collector of old computer junk) Doesn't looks like it's going to be too hard to build the pen itself.

    Here's a simple circuit from "Atari Archives" for the construction of a light pen.

    www.atariarchives.org/ecp/chapter_6.php

    Oldbitcollector
  • Harrison.Harrison. Posts: 484
    edited 2007-04-11 06:18
    You could always look at Beau's SX Contest project @ www.parallax.com/sx/contest/contest_light_pen.asp for ideas.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2007-04-11 08:28
    The big pluses of a light pen versus a touch screen are the low cost and having a glass screen that can tolerate abuse.

    Regarding the pen...
    You don't require a fiber optic cable; you can put a light emiting diode in a pen housing and use plain old wire.

    Of course, with a touch screen - no pointing device is required. But the pen is actually appealing for fine, detailed work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-04-11 10:45
    > You don't require a fiber optic cable; you can put a light emiting diode in a pen housing and use plain old wire.

    The fiber optic cable has some advantages:
    * It is lighter
    * The sensitive area is much smaller compared to the photo-transistor's window (more accuracy pointing)
    * Less problems with electrical noise (amp and sensor close together)

    I kinda doubt that the linked atari-circuit works very well.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-04-11 11:07
    Nick Mueller said...
    > You don't require a fiber optic cable; you can put a light emiting diode in a pen housing and use plain old wire.
    The fiber optic cable has some advantages:
    * It is lighter
    * The sensitive area is much smaller compared to the photo-transistor's window (more accuracy pointing)
    * Less problems with electrical noise (amp and sensor close together)


    *A fibre optic will tend to be quite stiff once you have the type with a protective cladding. The weight of a photodiode and a switch and some suitably flexible wire is not much of an issue.
    *Resolution problems can be fixed with a mask or a lens.
    *Reduction in noise if only an advantage if it was a problem in the first place.

    But I would say you could make a workable solution using either method however I would look at using surface mount photodiodes, some are tiny.

    Another alternative is a pen containing an ultrasonic emmitter and a pair of detectors to locate the pen tip, I have a digitizing pad that uses that method and the transmitter is built into the ball point pen.

    Graham
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-04-11 11:09
    Further to that you could possibly use an optical emmitter in the pen, it should be modulated IR I suspect and use similar methods discussed recently for IR range finding.
  • LawsonLawson Posts: 870
    edited 2007-04-11 19:52
    Wouldn't a successive approximation technique be faster? I think a succesive approximation search could find the the exact pixel on a 256x192 screen in about 16 frames.

    First frame would alternate black and white pixels...
    Record the brightness of the pixel the light pen sees
    second frame would have two black then two white pixels...
    record the state of the light pen
    third frame would have four black then four white pixels...
    read the pen
    etc. etc.

    After 16 frames the recorded states of the light pen should be a binary integer representing the pen's position.

    I doubt that this is the best pattern of pixels to use, a 2D version of "gray code" would likely be more reliable. Also, using 4, 8, or 16 pixel brightnesses/colors could speed up the search. With a 16 brightness/color search 4 video frames should be enough to find the light pen's tip.

    another way,
    1. one frame with the top white and the bottom black
    2. one frame with the right side white and the left side black.
    3. you now know what quadrant of the screen the pen is pointing at.
    4. restore the contents of the quadrants the pen is NOT pointing at.
    5. loop back to step 1, but this time just put the search pattern on the quadrant the light pen was found in.

    again 16 frames would be needed for a two color or gray level search, and 4, 8, 16 colors or gray levels would speed the search. This system is better because it only blanks the whole screen for two frames. (it'd prolly be really cool to watch too! )

    All of these systems wouldn't need to disturb anything displayed on the screen if the video driver was modified to generate these test patterns.

    my 2 cents,
    Marty
    Beau Schwabe (Parallax) said...
    For LCD screens or CRT screens, you could allow a program to do a X/Y sweep of the screen when a button on the light pen is pressed. Just look for the "blip" on the light-pen sensor to determine position.

    Pseudo code: (Assume screen resolution is 256 by 192)

    1) If Button On Light Pen is pressed, blank screen and proceed with steps 2 through 4  
    
    
    2) For X = 0 to 255 
           line (X,0)-(X,192), white 
           {Monitor Light Pen input for X position} 
           line (X,0)-(X,192), black 
       Next X  
     
    
    3) For Y = 0 to 191 
           line (0,Y)-(255,Y), white 
    
           {Monitor Light Pen input for Y position} 
           line (0,Y)-(255,Y), black 
       Next Y  
    
    4) Restore Original Screen 
    
    

  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2007-04-11 22:52
    Lawson,

    Interesting idea... Along the same lines, you could make half the screen black, half the screen white.... monitor the Light pen

    ...if it is HIGH, sub divide the previous "white" section so that it is now half black, half white and repeat
    ...if it is LOW, sub divide the previous "black" section so that it is now half black, half white and repeat

    for X you would need 8 iterations ... 256 = 8-bit representation
    for Y you would need 8 iterations ....192 = 8-bit representation

    ...So as you said approximately 16 total iterations.

    The binary HIGH / LOW pattern through each iteration will reflect the correct position.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-04-11 23:27
    > Interesting idea... Along the same lines, you could make half the screen black, half the screen white.... monitor the Light pen

    I wouldn't like the flicker while trying to track a lighpen.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • LawsonLawson Posts: 870
    edited 2007-04-12 03:51
    Nick Mueller said...
    >

    I wouldn't like the flicker while trying to track a lighpen.


    Nick

    right, it would be pretty hard on the eyes to continuously track the light pen. (not to mention slow as mud. 16 iterations / 30fps = 0.53 seconds per location and any movement would screw up the algorithm) Now, if all the program needs is the location of click events, continuous tracking is not needed. The nifty part of using converging subdivisions of the screen is that flicker can be held to a minimum.

    Beau I like your idea, it's simpler. I do think it'd be less annoying to alternate checking X and Y position. I think a shrinking flashing square would be less annoying than a shrinking horizontal line followed by a shrinking vertical line.

    Also, single pixel position information would not always be needed. (say when clicking on buttons or selecting text.) In those cases searching could be further accelerated by only checking to say 5-bit precision in X and Y. (i.e. narrow the light pen position down to a single 8x8 pixel square in a 256x192 screen) Only 10 iterations would be needed then.

    my two cents
    Marty


    P.S. I think you can also get just the raw touch screen panels, with no electronics box. The resistive touch screens should be really easy for the Prop to read directly. These are just two clear conductive films separated by an elastic separator. from what I've seen they should read out just like a potentiometer. (huh i guess there are also some "friendly" chips for reading a touch screen too http://www.national.com/pf/LM/LM8300.html )

    Post Edited (Lawson) : 4/12/2007 4:05:53 AM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-04-12 05:26
    The flashing square idea reminds me of a technique I used once on a vector graphics display. This kind of display used, essentially, a huge oscilloscope screen, whereon the vectors were "drawn" from a display list. When you got a "hit", you just checked the X,Y registers to get the location, or the display list address to see which vector was being drawn. For tracking movement, a cursor "target" was always visible, but you had to "pick it up" with the lightpen to move it anywhere. The direction it moved depended on which side of the square got the hit.

    This could also work on an LCD with minimal eye annoyance. Just modulate the pixels under different portions of the square differently and use the time-varying pattern to determine which part of the square is being picked up. If it's the right side, move it right; if the left, move left; etc. An interesting modulation pattern to try might be a maximal-length sequence (MLS) circulating about the square's periphery. The phase of the sequence picked up by the lightpen would determine where on the perimeter the pen was getting its reading. The advantage of such a sequence is its resistance to interference from other stuff that's happening on the screen. (This type of sequence is also used in CDMA cell-phone transmissions to modulate the individual signals for sharing a single channel.)

    -Phil
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-04-12 08:10
    if it takes 16 iterations that is half a second to get a location, that might be a bit slow for true pen use but OK for activating buttons if that is the application though perhaps it would be better to flash the specific regions, you could use similar search techniques to speed up the acquisition.

    Graham
Sign In or Register to comment.