News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_m_dr_m

How to make an optic pen?

Started by m_dr_m, 10:38, 09 December 23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

m_dr_m

Hello, given modern modernity, is there a simpler way to make an optic pen than Dart Light Pen?
I'm also willing to buy one already made.

Goal: exploit it for incoming artistic tools.

SerErris

The light pen itself just consists out of a light sensitive transistor and some logic gates. So Potentially you can reverse engineer the dark light pen PCB with a PLA or CPLD. I have not really looked into the logic of the dark light pen as the pictures we have here on CPC wiki of the PCB is lacking two things:

1. The Backside of the PCB is pretty blurry
2. You cannot identify the Transistors on the PCB.

Also the characteristics of the Fotosensitive transistor inside of the PEN is unknown. 

I think it is much simpler to just create on from scratch. But never done that. Also I could not find any projekt to create a new one.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

SerErris

#2
Okay,

the simples setup should be to connect a light pen like this one to the expansion port:

https://www.atariarchives.org/ecp/chapter_6.php

Instead of connecting it to a joystick port, you connect the LightPen Output Gate to the L.PEN pin and the Switch could be connected to NMI or something alike, so that you can press a button and let a software react on the interrupt and read the CRTS L.PEN registers.

Obviously I would use a modern fotoresistor that has a range from 400nm to 1000nm to be able to recognize the signale better. 
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

GUNHED

My first lightpen (still have it) was made out of:
- Resistor
- Transistor
- Optical 'sensor'

How to do it was written in some computer magazin back the day.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Brocky

from what ive read, using the light pen pin on the expansion port requires very little hardware
just a photodiode (a reverse LED!)..and maybe a resistor to keep the levels low...
when the electron beam from the monitor hits the photodiode it generates a signal to the CRTC, which is doing all the timing and puts the location of the beam hit into a register... 
your draw function works just by reading that register out and plotting the location on screen...


GUNHED

The 6128plus offers that small nice port to connect a light pen anyway.  :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Bryce

Quote from: GUNHED on 14:56, 13 December 23The 6128plus offers that small nice port to connect a light pen anyway.  :)

Yes, but it wasn't compatible with the pens that worked on the classic CPC as far as I know, such as the DK'Tronics pen. The circuitry of the DK device is easy to recreate and works with the DK software and other programmes too (including your own FutureOS I believe).

Bryce.

GUNHED

#8
No, it's not compatible. But who cares?
The idea was to have a small port instead to use the large 50 pin expansion connector. The needed signals are all there (see 6128plus manual).

Here I got three kinds of Light Pens (no dk'tronics though), all work fine with CPC6128 (Expansion port) and 6128plus (Light-Pen-Port). :-)

Some unusual light pens used different and uncommon techniques, they still need to be connected to the expansion port. However, they are not better - just better protected against 'hardware piracy' if you know what I mean.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

SkulleateR

There once was a simple pcb posted either in "CPC Internatoinal" or "CPC Magazine" back in the days together with a REALLY simple Basic Code but it worked, I built that one (but I really don´t know where I put it) ... if someone finds that article please leave a note here :)

SerErris

Also the lightpen on the 50pin port has the fantastic benefit of it getting directly attached to the CRTC and you can then just read the CRTC lightpen register to understand where it actually has hit the screen.

So I think it cannot get better than that.

There also exist Joystickport versions, but you then have to do the calculation yourself and also time will go by until you read it, and I am not sure how it should work as the joystick port is only getting checked every 1/50s second - that would be just not helpful.

If you want to mod your case, you can just put a new port in the case (4 Pins are enough), with 12V, GND and then one line to the CRTC LightPen and one line to NMI.

But in reality that does not make to much sense if the exact same thing is anyhow availble without any mods on the expansion port.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.


SerErris

And I am not sure how this is actually working via Joystickport. There is no interrupt source and I am not sure how you actually check it? 

Run a routine every µsec to get the actual pixel? That must have poor resulution. Even every line will be painful. 

Anyone can share light in it how this joystick port based version would even work?
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

SerErris

Quote from: SkulleateR on 19:29, 14 December 23There once was a simple pcb posted either in "CPC Internatoinal" or "CPC Magazine" back in the days together with a REALLY simple Basic Code but it worked, I built that one (but I really don´t know where I put it) ... if someone finds that article please leave a note here :)
https://archive.org/details/06_Schneider_CPC_International_1985-08
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

SkulleateR

Quote from: SerErris on 11:59, 15 December 23
Quote from: SkulleateR on 19:29, 14 December 23There once was a simple pcb posted either in "CPC Internatoinal" or "CPC Magazine" back in the days together with a REALLY simple Basic Code but it worked, I built that one (but I really don´t know where I put it) ... if someone finds that article please leave a note here :)
https://archive.org/details/06_Schneider_CPC_International_1985-08

Thanks :) Not the one with the PCB and the Basic listing but a nice addition ...

dodogildo

This project from Amstrad Magazine #8 looks pretty cool. I wonder if anybody tried it before.
M'enfin!

GUNHED

Quote from: SkulleateR on 19:29, 14 December 23There once was a simple pcb posted either in "CPC Internatoinal" or "CPC Magazine" back in the days together with a REALLY simple Basic Code but it worked, I built that one (but I really don´t know where I put it) ... if someone finds that article please leave a note here :)
I have that one too. Works great (as far as technology allows it of course).
Here is the wiki entry: https://www.cpcwiki.eu/index.php/Happy_Computer_Light_Pen
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Brocky

#17
currently testing a photodiode connected to an arduinos analog input, testing i can actually detect the electron beam, before writing a small sketch that will output a signal on a digital pin when the beam is detected and hooking up to the lightpen pin (and ground) on the CPC..

only doing it with an arduino coz i dont have any transistors/opamps on hand!

SerErris

I think the main task will be to get it accurate enough. From the CRTC you only get the character position AFAIK.

But still very interested in your experiments.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

Brocky

#19
im detecting something.. but stray light is being a bit of an issue... ive put the photodiode into an old pen and have it recessed so that only light from the monitor will get in...

im guessing, that a button will be required to "activate" the lightpen when its needed... so its not constantly spamming the CRTC from stray light...

for reference, heres some info from the MC6845 datasheet...

Light Pen Strobe (LPSTB) - A low-to-high transition on this high-impedance TTL/ MOS-compatible input latches the current Refresh Address In the light pen register. The latching of the refresh address is Internally synchronized to the character clock (CLK)
Light Pen Register (R16-H, R17-L) - This 14-bit read-only register pair captures the refresh address output by the CRTC on the positive edge of a pulse input to the LPSTB pin. It consists of an 8-bit low order (MA0-MA7) register and a 6-bit high order (MA8-MA 13) register. Since the light pen pulse is asynchronous with respect to refresh address timing an internal synchronizer is designed into the CRTC. Due to delays in this circuit, the value of R16 and R17 will need to be corrected in software. Figure 16 shows an interrupt driven approach although a polling routine could be used.

and interestingly....

Note that the LPSTB input may be used to support additional system functions other than a light pen. A digital-to-analog converter (DAC) and comparator could be configured to use the refresh addresses as a reference to a DAC composed of a resistive adder network connected to a comparator. The output of the comparator would generate the LPSTB input signifying a match between the refresh address analog level and the unknown voltage. The light-pen strobe input could also be used as a character strobe to allow the CRTC refresh addresses to decode a keyboard matrix. Debouncing would need to be done in software

Brocky

the UM6845 datasheet says When the LPEN pin is changed from low to high, the registers get stored on the falling edge of the next CLK... 
so it seems there are even more differences between the different CRTC types!

GUNHED

Yes, some CRTC versions work with the usual (= the way Amstrad provides signals) light pens, but some CRTCs don't. There are different kinds.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

darkhalf

The above seems to read the same to me for both, also noting the diagrams (Page 5-29)
https://datasheetspdf.com/pdf-file/544758/UMC/UM6845RB/1

Both communicate:
LPEN signal Low -> High triggers loading into the Ma0-Ma13 positions, which the contents of are available on next falling CCLK line (High -> Low). I'm not seeing the difference here?

I got one of the joystick port Amstrad ones but not sure is really available for it apart from what came on tape.

Would like to reverse engineer the Dart one so that we have more software avaiable. Unsure about all the extra logic chips on there, and can think it could only be used for some memory mapping decoding
CPC464/GT64, CPC464 Plus/CTM640, 2 x CPC6128/CTM644

Brocky

#23
Quote from: darkhalf on 21:22, 18 December 23The above seems to read the same to me for both, also noting the diagrams (Page 5-29)
https://datasheetspdf.com/pdf-file/544758/UMC/UM6845RB/1

Both communicate:
LPEN signal Low -> High triggers loading into the Ma0-Ma13 positions, which the contents of are available on next falling CCLK line (High -> Low). I'm not seeing the difference here?

I got one of the joystick port Amstrad ones but not sure is really available for it apart from what came on tape.

Would like to reverse engineer the Dart one so that we have more software avaiable. Unsure about all the extra logic chips on there, and can think it could only be used for some memory mapping decoding

i was comparing CRTC type 0 and type 2.... looks like you compaired type 0 and type 1 (HD6845S and UM6845 are type 0, UM6845R is type 1, MC6845 is type 2).

the difference im seeing is type 2 puts the Refresh Address on the registers on the rising edge of LPEN signal, type 0 and it seems type 1 only put it on the register at the falling edge of the next CLK.

bit of a moot point really... as theres not that many type 2s around AFAIK... majority are type 0 and 1s...(correct me if im wrong!)

darkhalf

Quotelooks like you compaired type 0 and type 1
Was looking at the MC6845 you mentioned (Type 2) as I was curious of the differences

Figure 4 of the datasheet I have shows  LPSTB (LPEN) signal going high and clocking in the Refresh Memory Address into the register, but the register data is not valid until tLPD1 has expired (on the CLK signal going low). So effectively it looks like it should function the same as the other two types of CRT

Mute point as you mention, and also the processor still needs to read the register, which is many clock cycles later

CPC464/GT64, CPC464 Plus/CTM640, 2 x CPC6128/CTM644

Powered by SMFPacks Menu Editor Mod