Circuit
Video input comes from composite video source and works as a passthrough. I have used one male and two female connectors to make it easy to connect as a passthrough no matter what cables are available.
The LM1881N video decoder chip is an interface between video and Arduino. The signal changes on VSYNC (pin 3) and COMPOSITE SYNC (pin 1) are timed by Arduino and used to prepare HID report for host. The decoder is wired exactly like in the datasheet application example schematic, using two 0.1uF capacitors and one 680K resistor.
The male DE9 connector is a socket for lightpen. Pin 3 is the push button (active low) and pin 6 is the light pen signal from phototransistor (also active low) whenever electron beam passes in front of light pen lens. You need to provide power to light pen, so pins 7 and 8 must be connected to common 5V bus and GND (respectively).
Operation
Timer1 is setup to count without prescaler (so 16MHz) and with interrupt on capture (change on pin 4, ICP1, connected to pin 6 on light pen cable).
Another interrupt is triggered by high to low transition on pin 7, connected to VSYNC.
After every low to high transition on COMPOSITE SYNC (pin 9 on Arduino) row counter is increased, Timer1 is reset to 0 and starts counting time for the current row.
If there is ICP interrupt the current row numbe and current Timer1 value are saved for later use.
After every VSYNC interrupt a HID report is prepared if there was ICP interrupt event:
- row number is our Y position
- Timer1 value saved in ICP is our X position
- button state is compared with last state
- x/y values are smoothed and rescaled
- HID report is sent to USB host
Relevant events are cleared. The row counter is set to zero, a new image frame starts.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.