• Please review our updated Terms and Rules here

Tandy 1000 DIY Lightpen Shenannigans

creepingnet

Veteran Member
Joined
Feb 25, 2005
Messages
1,121
Location
Reno, NV
I'm kind of starting this thread in part to document my shennanigans in DIYing a working light pen using cast-off parts and some drivers from TVdog's archive. The light pen port has been a curiosity to me as a Tandy 1000 user since I got my first computer, a 1000 SX, back in 1997 (yes, it was 10 years old when I got it ;D ).

What motivated this endeavor is several things...

- Curiosity about that lightpen port, nobody used it, but it holds so much potential
- The desire for some kind of pointing device for the Tandy and not having a free serial port for a mouse (my current is a 1000A using all three ISA slots up with Memory Expansion, Ethernet, and XT-IDE)
- The scarcisty of light pen port and gameport pointing devices for the Tandy 1000 (yes I'm aware it uses TRS-80 controllers/mice)
- The fact I remember seeing a lightpen on a CGA PC in the 80's as a very small kid and being quite fasinated with it

How I started was with making a breadboard wire for the Tandy 1000 series light pen port, which I used the Tandy 1000 Hardware reference manual to get the pinout for... the port itself is D-sub male, and the connector is D-sub female - which I had from a pile of spares I got at Vetco a couple years ago for repairing the NEC MultiSync II monitor I use with my Tandy (cracked source selector board PCB and bad DB-9 port).

Pinout is as follows
1 - +5vdc
2 - Ground
3 - Light Pen In
4 - Switch/Button
5 - nc
6 - nc
7 - nc
8 - nc
9 - nc

The cable I made goes to a 4 pin molex female micro-connector that I can use to stick components into like a breadboard.

So came the research/Google-Fu part of this. I found an old Atari 8-bit archive article about lightpens here to get an idea on how I can "hack" something that may (or might not) works together. - https://www.atariarchives.org/creativeatari/Build_Your_Own_Light_Pen.php

Then there was reading up on some about the CGA graphics controller in the Tandy 1000, the MC6845 CRTC - which is the chipset used by the Tandy for CGA graphics (and the reason it has a Lightpen port). This included a blog article, and a thread from here on VCF

NERDLY PLEASURES -http://nerdlypleasures.blogspot.com/2016/05/ibms-cga-hardware-explained.html

VCFED - http://www.vcfed.org/forum/archive/index.php/t-18091.html

So what I deduced was this - most lightpens seems to consist of a phototransistor or a light detector cell of some sort, a resistor, and a push-button to turn the pen on when you want to use it. Going off the atariarchives article, this meant wiring a phototransistor to the LPIN (pin 3) and +5VDC (pin 1), and then wiring a switch between ground and the LPIN side (pin 2 to pin 3). But then that leaves me wondering what the LPSW (pin 4) is for.

For components I'm using....
- a photosensor from a dead ball mouse
- a 100K, later a 10K resistor
- momentary pushbutton switches swiped from a dead VCR (one for what the Atari aritcle calls a "loop" and the other for the regular switch, both connect to ground - switch one takes from the photosensor on the LPIN side, and the other from the LPSW.
- various wires I had laying around
- and of course, my home-made LP breadboard cable

For drivers/controllers for the pen, I'm using the PENMOUSE/LIGHTPEN driver, I can't remember where I found it but I'm putting it up for download on my own site eventually anyway. Basically it consists of four EXE files....

- LIGHTPEN.EXE - the control TSR for the lightpen itself
- PENMOUSE.EXE - I assume this makes it behave as a mouse
- INSTALL.EXE - which configures the TSR for the lightpen
- CONTROL.EXE - some kind of very old lightpen file manager program that crashes with a stack overflow, probably because its being run off an 8GB HDD.

Initial testing of this configuration started with me wiring up the "pen" a few different ways at first, eventually settling on the very basic 10K resistor on the +5VDC side of the opto-sensor, and putting a bare wire into the ground. That is what's making results, using the wire as a switch. I have something more complex now with the 2 switches going to ground from LPIN and LPSW...

Driver setup is done by first running "LIGHTPEN.EXE" to put the control module in memory, not doing this causes all other programs to immediatley terminate and drop you to the rood directory of the hard disk with the error message "controller or lightpen not availible".

Wired up and with LIGHTPEN in memory though - were ready to rock, running the install program shows that it IS picking up the light pen....but it seems up to random luck in timing though as it appears the photosensor just BARELY addresses at random intervals, and the rest of the time the click addresses on another part of the raster refresh - as indicated by a random asterik appearing when I click the button for LPIN.

I've tried it out in turbopaint, same deal.

So it seems I'm missing a few things, maybe someone can help me out on this....

Do mice use different devices than lightpens do for sensing the spot on screen? I think it may be possible I need to put down a buck or two on some phototransistors instead per the Atari article. Either that or use a transistor (have a ton of them for Guitar pedal builds) to make an amplifier and boost the input signal from the pen to LPIN so it can actually track more than once in a blue moon.

Are there any better schematics or photos from a compatible device out there than the Atari one. I know that one is pretty simple, maybe I need a few more capacitors to handle timing,. I know the NES Zapper is a similar device and uses more than just a resistor, photosensor, and a switch to do it;s job (I see 2 capacitors, an IC, and maybe a diode or two in there). Also, I'm aware an Atari 400/800 is not the same as a Tandy 1000 PC compatible - even if they use the same standards. I'm also curious how the "LPSW" pin is supposed to work, a lot of devices I know switches ground off a signal to make it go low/high to register, but maybe I'm missing something important.

Just some thoughts. Either way, my tinkering is proving rather successful after about 4 hours of total work over the course of a few afternoons at 1-2 hours a pop.
 
Here's a light pen schematic that does use a transistor, it might be worth a shot:

https://www.atarimagazines.com/compute/issue10/018_1_BASICS_OF_LIGHT_PEN_OPERATION.php

It does seem to be remarkably hard to find a light pen schematic specifically for PCs.

Also, regarding the photodetectors from mice, I believe most mice use infrared LEDs. (At least I don't actually recall seeing visible light coming from inside an old mouse.) Perhaps it's possible that the matching photodetectors are also tuned to be less sensitive to visible light
 
Could you use one of the Atari CX-75 light pens? They seem to be fairly cheap, and according to this website, should probably work if you rewire the connector.

Atari CX-75 Lightpen on Ebay: https://www.ebay.ca/itm/Atari-CX-75...977520?hash=item1ef015c570:g:XtsAAOSwa1ZcBgjD
DB9 lightpen schematic: http://wiki.icomp.de/wiki/DB9-Lightpen
A DB9 breakout adapter to wire it up: https://www.ebay.ca/itm/DB9-9-pin-M...var=584285217601&_trksid=p2060353.m2749.l2649

Or I could be wrong.. the cx-75 was used to register on the screen. Is that how the tandy one worked?
 
Here's a light pen schematic that does use a transistor, it might be worth a shot:

https://www.atarimagazines.com/compute/issue10/018_1_BASICS_OF_LIGHT_PEN_OPERATION.php

It does seem to be remarkably hard to find a light pen schematic specifically for PCs.

Also, regarding the photodetectors from mice, I believe most mice use infrared LEDs. (At least I don't actually recall seeing visible light coming from inside an old mouse.) Perhaps it's possible that the matching photodetectors are also tuned to be less sensitive to visible light

The IR thing might explain why it's not addressing where the sensor is on the screen. I kind of thought that might be the case, just not sure. Maybe I should put the NEC into Amber Mono emulation mode and see if it picks it up better. I remember now, I think that detector is from a VCR ND that would be infared because I never see a light source in a VCR when I repair them.
 
So what I deduced was this - most lightpens seems to consist of a phototransistor or a light detector cell of some sort, a resistor, and a push-button to turn the pen on when you want to use it. Going off the atariarchives article, this meant wiring a phototransistor to the LPIN (pin 3) and +5VDC (pin 1), and then wiring a switch between ground and the LPIN side (pin 2 to pin 3). But then that leaves me wondering what the LPSW (pin 4) is for.

The LPSW is just that, a switch that reads either pressed or not-pressed. It does not "turn the pen on when you want to use it". Most light pens were always on once connected; the atariarchives article was probably talking about a second switch just to turn off the pen. The typical use of the LPSW was a little button near the tip of the pen that, for all intents and purposes, was a mouse button. Pressing it could either flash the entire screen pure white for one frame (so that the pen location could be determined if it was resting in a black area), or it could indicate to the software you want to pick something up or select something.

Once you fix this and your pen is always on, your software might start working. Keep us posted (I've always wanted to program for one but lack the skill to assemble and troubleshoot the hardware).

It might be different on Tandy 1000 systems, but on IBM CGA systems, the resolution provided by a light pen is limited to the granularity of 6845 character generator, giving the light pen an effective 40x100 resolution in all graphics modes, and 80x25 in 80-column text mode. So while you might be tempted to draw with it, it won't be pretty unless the graphics program performs a lot of averaging or other smoothing tricks. It seems best suited for selecting things in 80x25 text mode.
 
Could you use one of the Atari CX-75 light pens? They seem to be fairly cheap, and according to this website, should probably work if you rewire the connector.

Atari CX-75 Lightpen on Ebay: https://www.ebay.ca/itm/Atari-CX-75...977520?hash=item1ef015c570:g:XtsAAOSwa1ZcBgjD
DB9 lightpen schematic: http://wiki.icomp.de/wiki/DB9-Lightpen
A DB9 breakout adapter to wire it up: https://www.ebay.ca/itm/DB9-9-pin-M...var=584285217601&_trksid=p2060353.m2749.l2649

Or I could be wrong.. the cx-75 was used to register on the screen. Is that how the tandy one worked?
Thx, that's some stuff I can look at.

From my googley-fu I think all light pens for computers worked much the same. Raster is detected by the light sensor, sent to a DAC then converted to on screen coordinates and appropriate action by the computer per horizontal refresh and software as to which scanline and where during that lines drawing cycle the sensor picked it up.

I think the Atari could work via a configuration change of the pins. The Tandy interface is much simpler than the regular CGA one that seems to use more pins for +12v and I think one other function.

If I can get this going...might be able to also create a light gun for the Tandy 1000 (maybe a good port/parody of Duck Hunt is in order, lol).
 
Shameless necro of this thread to see if you ever got this working?! This sounds like an awesome diy project for my 1000sx and my breadboard
 
Yeah, I'm getting back into vintage computers again after about half a year Alpha testing a modern survival game (Drive Beyond Horizons). I have my Tandy permanently setup in the garage and running 24/7/365 now since I got a new workbench and bolted a rack to it.. Someone recently sent me a schematic in e-mail that I'm going over. Thinking about putting together a breadboard setup to that port permanent for experiments. I just haven't been writing about it because nothing major has come to forefront.
 
Yeah, I'm getting back into vintage computers again after about half a year Alpha testing a modern survival game (Drive Beyond Horizons). I have my Tandy permanently setup in the garage and running 24/7/365 now since I got a new workbench and bolted a rack to it.. Someone recently sent me a schematic in e-mail that I'm going over. Thinking about putting together a breadboard setup to that port permanent for experiments. I just haven't been writing about it because nothing major has come to forefront.
Would you mind sharing the schematics?
 
Presumably the light pen's optical sensor is used to determine the pen's location based on two important details (a) the display timing (horizontal, vertical sync?) and (b) when in that window of time the particularly bright point, produced by the electron beam actively exciting the phosphors, is located immediately beneath the sensor.

I think that either the pen would have to be adjustable for monitor brightness (peak intensity) or designed for a particular pre-defined monitor spec.

-----

If a photoresistor is used, then the output will be varying resistance that produces a voltage difference with respect to the applied supply voltage. The resistance of the sensor will likely have a characteristic response to different colors of light in addition to it's intensity. (analog signal)

By contrast a phototransistor is a light activated switch that will produce digital pulses of a sort when the light hitting it produces enough electricity to drive the transistor. Although the output won't necessarily be a clean square wave. (digital signal, nominally).

Every design may be a little bit different and so the interface hardware and software will need to be correct for a given pen.

P.S.

Using a momentary switch would suffice to provide a digital input, but the coordinates associated with the click event would be dependent on exactly when the location was last calculated relative to the detection of a button press. And debouncing the switch input would probably be necessary too.

For a simple point and click interface you might have to hold the pen very still in front of the desired spot.

Drawing with the pen should be fine as long as you don't move it too quickly and are careful about precisely signaling a start and stop (per the click situation in the last paragraph).
 
Last edited:
The necro-ization of this this thread has me idly wondering about if there would be any practical route to emulating a light pen on an LCD monitor. The best idea that immediately comes to mind for me would be to start with something like the RGB2HDMI; the way it samples the incoming signal effectively means it knows how the position of the "beam" relates to the upscaled output, so in principle it seems like you could effectively add a mouse or touch-screen controlled "overlay" layer that accepted a touch/mouse click and would use an output GPIO pin to signal a light pen pickup the next time the "beam" passes that spot in the digitization loop. (I guess you would need to make this conditional on if the pixel color at that spot is something other than black.)

I don't know if it's really worth anyone's time implementing this, there's not very much light pen software and the resolution limits called out by @Trixter would still apply (at least for CRTC-linked light pens, I suppose you could get pixel-precise resolution if there were a high-res light pen card like was being discussed in another recent thread present), but in principle it might be something you could tack onto an existing dingus with just software. (Well, okay, a *teeny* amount of hardware.) Maybe the same concept could be used for light-gun arcade hardware, although I don't imagine it'd be any more fun doing that through an RGB2HDMI with a mouse hooked to it than it is in an emulator. (Maybe for that you could construct the overlay layer to talk to a Wii-mote-type pointer so you could do it at a distance?)
 
@Eudimorphodon I think the easiest way to get a light pen working on an LCD monitor would be to overlay each frame with a single pixel of a dedicated color (not otherwise used in the frame). Of course you need to sequentially update the position of that every frame. Essentially you'd be drawing a dot at the point wheree the beam ought to be. That way you have an actual visual point to track since the LCD brightness is constant.

It would probably be easiest to do that with an analog video signal like VGA where you just need to time things right and substitute alternate color signals. Doing it with native HDMI output would require it to be done to the framebuffer or by the game before it got there. Although I suppose a converter/upscaler box could probably do that somewhere in the process of generating the new video ouput (as you seem to be proposing).
 
Last edited:
@Eudimorphodon I think the easiest way to get a light pen working on an LCD monitor would be to overlay each frame with a single pixel of a dedicated color (not otherwise used in the frame). Of course you need to sequentially update the position of that every frame (0,0), (0,1), (0,2), (0,3). Essentially you'd be drawing a dot at the point wheree the beam ought to be. That way you have an actual visual point to track since the LCD brightness is constant.

I was talking about making the thing that emulates the light pin signals required by a CGA-style light pen, not actually trying to use a genuine "detects light from the screen" light pen with the LCD monitor. While it certainly would be possible to use some sort of "draw spots on the screen" algorithm to make an actual optical light pen work it'd result in some *very* visible screen distortion and a *ton* of lag unless your monitor had a *very* high refresh rate. My assumption when talking about using an RGB2HDMI was that if you really wanted to simulate the pen experience you'd do it with a touchscreen digitizer; trying to actually make a *light pen* would would be a fiendish overcomplication.

I also have some *serious* questions about the algorithm you're proposing here, since it seems to imply it could take as many as 4000 frames for the pen to acquire the target. A really visually disruptive way of doing it would be to locate the pen by sequentially dividing the screen and narrowing in on it, IE, flash half the screen and see if the pen sees the flash, then divide it again, and again, until you hit the cell the pen is over. With that technique you might be able to locate the pen in only about 11 flash sequences... at the cost of triggering epilepsy harder than Electric Soldier Porygon. (Although that might not necessarily be worse than a colored block scanning frantically through every cell location.)

Anyway. If you want to write your own light pen software there's an alternative way of driving a light pen that wouldn't care about running on an LCD screen; the only downside is it's *only* useful for doing things like menu selection, drawing is pretty much entirely off the table. (Unless you combined it with something like the progressive estimation technique I said above to narrow down the pen location, then I suppose you could use it to select points for line drawing/cad... slowly.) Here's an 80 Micro article from 1980 about building a light pen that connects to the computer's audio cassette input. The way it works is you chuck a menu with buttons up on the screen, then you poll to see if the pen detects light. When it does you sequentially flash each target until you see the light go out, boom, selection made. I know it sounds pretty lame, but this is actually how the pens were used in practice a lot of the time even on computers that had CRTC-linked ports for them.

But light pens aren't color-sensitive, are they? They just measure light vs. dark.

Exactly.

Maybe if you *had* some kind of light pen which could tightly chroma-key onto a particular color you could combine that with a 4K+ LCD screen that has an HDR color gamut to overlay a barely-visible coordinate grid that the pen could see and directly read its position? This would be extremely silly, of course, when we have resistive and capacitive touchscreens (and Wacom-style tablet digitizers, for that matter) but I suppose would be technically possible.
 
The point was that an LCD screen has a nearly constant brightness and so there might not be a readily identifiable current brightest point like you would have on a CRT. So you would need a detectable substitute of some sort.

If you could find a way to simulative the relative changes in brightness for every single pixel (using a different colir system and converting to RGB) that would probably work better than a traveling pixel, but I guess you're still fundamentally limited by the LCD refresh rate.

:(
 
On the topic of Light Pens, I became fascinated with these (as we all know in the same way video killed the radio star, the Mouse killed the Light Pen)

But when I initially looked into it there was very little information on how to execute one as a home computer project. I found some very basic block diagrams about using counters, but nothing much of any detail.

I decided to design my own, mainly in hardware, but I was forced out of that hardware comfort zone and I had to write the software driver for it. I found (in my SOL-20 computer and using a Matrox video card) that BASIC was too slow, so I had to make an 8080 assembly language driver.

I came up with the idea of using one video plane as an illumination plane to activate the pen, and the other plane as the image plane. Also I used an Inkwell PEN, that had two buttons and I was able to make one of them to be a rubber. This pen also has a lens so you don't have to drag it directly on the CRT's glass face, just hold it nearby.

The hardware and software is described in the article I wrote about it here:

 
The point was that an LCD screen has a nearly constant brightness and so there might not be a readily identifiable current brightest point like you would have on a CRT. So you would need a detectable substitute of some sort.

I think you’re kind of missing the forest through the trees here. With a CRT the spot that’s being directly stimulated by the electron beam at a given moment is *much* brighter than anything around it in that instant. It’s that flash that light pens really depend on, not the decaying glow of the phosphor in between scans. There is no comparable scanning action that meaningfully changes the brightness of individual pixels as they’re refreshed on an LCD (or most other modern) screens, so there’s nothing for a light pen to “passively” key off of.

In short it’s a technology inherently reliant on CRTs. (The “flicker individual spots” method I outlined would be an exception, but I’m even going to put an asterisk on that because I suspect you’ll need a pretty dark ambient environment because you’re not going to get the high intensity flying spot; your pen will need to activate on the base level brightness of the screen.) I never suggested using an *actual* light pen on an LCD for this reason, what I was outlining was a system for coordinating a location on a upscaled framebuffer (displayed on an arbitrary screen type) to the beam location acquired from the input scanning.
 
On the topic of Light Pens, I became fascinated with these (as we all know in the same way video killed the radio star, the Mouse killed the Light Pen)

But when I initially looked into it there was very little information on how to execute one as a home computer project. I found some very basic block diagrams about using counters, but nothing much of any detail.

I decided to design my own, mainly in hardware, but I was forced out of that hardware comfort zone and I had to write the software driver for it. I found (in my SOL-20 computer and using a Matrox video card) that BASIC was too slow, so I had to make an 8080 assembly language driver.

I came up with the idea of using one video plane as an illumination plane to activate the pen, and the other plane as the image plane. Also I used an Inkwell PEN, that had two buttons and I was able to make one of them to be a rubber. This pen also has a lens so you don't have to drag it directly on the CRT's glass face, just hold it nearby.

The hardware and software is described in the article I wrote about it here:

Wonderful article by the way!!!, reading through it now and appreciate the sharing of the schematics. Will help me wrap my head around everything going on as im still a novice in this whole thing.
 
@Eudimorphodon And I'm pointing out that there should be a way to get similar technology if desired, even if you ending needing a more sophisticated sensor that can detect colors.

Of course, you could just use some sort of modern touch overlay/touchpad or even make a break-beam setup based on IR, visible light lasers, etc if desired. Even magnets and the right sort of hall effect sensor would work on a LCD which isn't remotely as sensitive as a CRT to an electrogmagnetic field...
 
Back
Top