Ultimate 4 IR points lightgun system

Big update, there is now a brand new configuration/testing app for the gun!

the GUI licenses are for donators only

Update: in light of some recent events, and after a lot of thinking, I decided to limit licenses to my software to people that donate at least 15$ and have a clear history in this forum.

I won't be giving any license to people who just arrive here or who give less money.

Don't forget to also attach your real name and mail address to the donation, so that I can create a proper personal licence file for you.

Please remember that I invested so much money and time in this project, that even if all user give me 15$ I still won't make any money out of it, it is mostly for security measure, and fairness.



Here are some of its functions:

Offset/calibration wizard or manual setting

Button remap

IR sensor, buttons and feedback testing

Change any gun settings

Save/Load gun profiles

Firmware flashing, with 4 different player mode with each a different firmware pid

Many more...

If you want access to the UI or want to support me and help me maintain it, or just pay me a beer, you can find my Paypal and Patreon below

First, a small obligatory disclaimer: like with any DIY project, I am not responsible of any damage you might do to your hardware/yourself. Be sure to read everything careful before using my firmware. I am not a professional in electronic. I am giving all the schematics and pics as example, use them at your own risks.

And of course, this firmware cannot be sold alone nor in a package/hardware, it is completely free. If some people sold it to you, they are scam.

Features:

Auto calibration: calibrates automatically with 4 IR Led, on any screen/setup.

calibrates automatically with 4 IR Led, on any screen/setup. Precise line-of-sight aiming: very precise line of sight aiming, and far less jittery than other IR solutions.

very precise line of sight aiming, and far less jittery than other IR solutions. Reduced minimum distance: as long as the system can see the 4 leds when aiming center, it should work.

as long as the system can see the 4 leds when aiming center, it should work. Out of screen aiming support: out of screen tracking down to one led, allowing to move the cursor on the sides.

out of screen tracking down to one led, allowing to move the cursor on the sides. Out of screen firing mode: for games with off-screen reload, firing off-screen can trigger the reload button.

for games with off-screen reload, firing off-screen can trigger the reload button. Mouse released when off range: releases mouse control when out of range.

releases mouse control when out of range. Mouse/keyboard and joystick mode: you can switch between 3 input modes at anytime (mouse+kb, joystick, mouse+joystick).

you can switch between 3 input modes at anytime (mouse+kb, joystick, mouse+joystick). Fullscreen and 4:3 aspect ratio switch: if your screen is not 4:3, you can enable/disable this mode at anytime, to play 4:3 games with pillar-box.

if your screen is not 4:3, you can enable/disable this mode at anytime, to play 4:3 games with pillar-box. Manual screen calibration: manual forced calibration, just in case your leds are a bit far from the screen center.

manual forced calibration, just in case your leds are a bit far from the screen center. Solenoid/rumble support with fullauto: you can use 1 solenoid and 1 rumble motor for various feedbacks.

you can use 1 solenoid and 1 rumble motor for various feedbacks. Mamehooker support: for the supported games/emulators, you can use Mamehooker for customized feedback and settings.

for the supported games/emulators, you can use Mamehooker for customized feedback and settings. Solenoid temperature sensor support: change the solenoid speed depending of the temperature.

change the solenoid speed depending of the temperature. Nunchuck support: you can plug a wii nunchuck to the arduino.

Building the hardware:

Needed components for the gun:

An old lightgun where the IR Camera and the Arduino can fit (Guncon 1&2, Virtua Gun...)

Arduino Pro Micro Atmega32u4 5V/16MHz or the smaller Micro (has less buttons supported but has a smaller form factor)

long enough micro USB cable (e.g. 3m)

the DFRobot IR Camera

push button with shaft longer than the shell thickness (for the extra calibration button)

electronic cables to connect everything (e.g. kynar cables)

soldering iron & solder

hot glue or whatever you want to use to prevent anything from moving inside the gun

(optional) Hardware for the solenoid recoil:

n-channel logic gate mosfet (e.g. IRL540)

kickback diode (e.g. 1N4001)

resistors (e.g. 1kOhms and 100kOhms)

small pcb

solenoid that fits inside the shell without hitting anything when activated

long power cable

AC power supply matching the solenoid specs

(optional) Hardware for the rumble feedback:

NPN transistor (e.g. PN2222)

kickback diode (e.g. 1N4001)

resistors (e.g. 270ohms)

small pcb

rumble motor

power supply matching the specs of the motor if not 5V or too power for the arduino VCC

(optional) Hardware for RGB LED:

RGB LED with common cathode (common ground)

3 resistors that match the LED specs

(optional) Extra hardware:

temperature sensor for solenoid speed control (TMP36)

Corrugated Tube to hide the cables and prevent them from bending too much or get damaged.

3D printed clicky trigger with an arcade switch, for a better trigger feel

IMPORTANT: The DFRobot IR Cam often have the sensor tilted, so you might have to tilt the camera on left or right to make it work properly. I would recommend you to install the camera first and test the aiming with the tool before doing anything else.

Notes:

Be careful of which firmware version you are using and the corresponding pins

you don't have to use every pins, just use the ones you want and leave the other pins free.

connect the camera to pin GND, VCC, 2 (SDA), and 3 (SCL)

the pedal and A button have the same function right now, for compatibility purpose. I might change that in the future.

when firing offscreen, the gun trigger will use the secondary button (A button) instead. It is used for offscreen reload. It can be disabled with a button combo.

Hardware for the led system:

4 (or 8 in duo, or 12 for trio) powerful 940nm IR LEDs with angle wide enough (at least 30° for 8 and 12 leds, more for 4).

resistors, cables and USB connector

USB ac power supply powerful enough

Those data are only good with the specific leds I am using, for different leds use the website above!

Software Needed:

If you have a Sparkfun Arduino Pro Micro and windows 7, you might need the drivers --> Here <--

Arduino IDE (this will just be needed to troubleshoot)--> Here <--

(Optional)Mamehooker, for synchronizing the gun recoil/rumble to the game (Windows only)

(Optional)Demulshooter, to improve dual gun support on many emulators and games (Windows only)

And of course all the games and emulators you want to use

Installation:

If you have a Sparkfun Arduino Pro Micro, install the drivers. Follow the steps --> Here <--

Install the Arduino IDE

Launch the IDE

From the board menu, install the "Arduino AVR boards"

Select the correct board model and COM port

Create an empty sketch and flash it

If successful, you can go to the firmware flashing process

If unsuccessful, check the FAQ, or ask for help in this thread



#

# OSD OUTPUT OPTIONS

#

output windows





S

E

A0

A1

A2

J0

J1

J2

s1

s0

r1

r0

Usage:

Calibration button alone: enable/disable 4:3 mode

Trigger+Calibration button: switch offscreen mode button mode (disable/aim at the corner/reload button)

A+Calibration button: change input mode

Pedal+Calibration button: change pedal button mode (unique/reload)

Trigger+A+Calibration button: enable/disable auto reload (reloads after 6 shots)

Troubleshooting:

Updates history:

major update, please read the changelog carefully before updating!

Special credits:

Instead of using the usual 2+ LEDs sensor bar, this system uses one LED in the middle of each side, which allows a far better aiming system overall.It also has many other features, making it the most advanced IR light gun consumer solution.Since both the firmware and this GUI required countless of work to make,Of course you can also still use the firmware alone if you prefer, it's up to youSome videos to show how the system is running:Demonstration of the pinpoint accuracy of this system:Note that the latency in the video is mainly caused by my test app and my screen, the latency in-game is lower.Another cool video made by Foxhole on Point Blank, this guy has skillsAnd my discord server for support and discussion:- to avoid any issue, I would recommend to flash the arduino firmware first (see software installation guide), test the camera, and then if everything work, build the rest of the hardware.Here is the pins listing and their functions in the next table. (the schematics will come next)Note that you don't have to connect everything, just connect whatever you have available for your gun.The corresponding pins on the Pro Micro as reference:Here is a diagram of the feedback circuits I am using for the rumble and solenoid, as sample;You can of course make your own or adapt it the way you want, as long as the Arduino rumble and solenoid pins are correctly connected.If you're using something bigger than a computer screen, I recommend using 2 or 3 leds by point, with a slight angle between them, for a better angle without reducing the maximum distance.I personally use 8 SID1K10CM (5MM 940NM 200mw/sr 1.3-1.5v 30°), because they are very powerful, but any led with similar specs will work. Just avoid the wide angle leds since they are not powerful enough to play from a distance more than 1.5m.You can calculate the resistor needed and the power supply here:or here:As an example, here is the schematics and data of my circuits:The +5V and GND are connect to a the VCC and GND of a USB plug.And here how it looks once done:Place the LEDs at the exact center of each side (up, down, left, right), as close as the screen as possible, to have a good accuracy, like that:It's a temporary installation with tape, I would recommend a better more stable oneJust use the flashing tool in the GUI.If your arduino isn't detected, it probably means the model you have is not supported.To use Mamehooker with this system, first follow those steps:- In your Mame.ini file (in Mame folder), change "output" option to "windows";- Change the COM port of your gun 1 and 2 to be respectively COM1 and COM2 (you can do that in devices manager).- Make sure Mamehooker is correctly configured for your system and detects the emulators you want to use (follow the instructions on its website).- I will provide a zip file of my Mamehooker config files once I finished them, but meanwhile here is the command list:Each of those command have to be sent by serial to the arduino (Com write)Commands that must be sent at game/mame start or stop:16/9:4/3 in 16/9:4/3:Mouse/KB:Joystick:Hybrid:Ingame feedback trigger commands:on:off:on:off:after plugging in your lightgun, simply aim the screen (anywhere on the screen, as long as the IR cam see the 4 LEDs at the same time at least once), you should see your cursor starting to follow your motion right away (if nothing happens, there might be something wrong with your LEDs, check them with your phone digital cam if you can see them bright enough from where you are aiming).On the first use, your aim might be off centered. It is normal, each camera sensor has a slight offset. To correct this offset, hold the calibration button until the cursor jumps to the center of the screen, release it, carefully aim for the cursor, and press the trigger, then press the calibration button briefly to quit the calibration mode. Your sensor should now be calibrated, and since it's saved to the Arduino EEPROM, you won't have to do it ever again, even when changing your screen setup.there is now a way to force the screen calibration (if your leds are not right next to the screen, or if your screen or contents are not the standard 16/9 or 4/3). Instead of pressing the calibration button after the sensor calibration, aim the upper left screen corner, press the trigger once, aim the lower right screen corner, press the trigger once more. It should now automatically exit calibration mode. The calibration data is saved to the arduino, and will stay at each reboot. To reset the calibration to default just reenter the calibration mode and quit the mode right away.once your lightgun is working, it should now follow your aim as long as it sees at least one LED on camera (or 2 LEDs if you aimed out of the LEDs range, to get "back on track"). It means you have a huge range of motion offscreen, the cursor will follow your aiming in the borders of the screen.if you shoot offscreen, it will either shoot at the lower left corner of the screen, or trigger the A button (Right mouse click) instead of the trigger, useful for games that need offscreen shoot to reload.there are different modes you can change with buttons combo, you must first hold one of the following buttons and press the calibration button briefly for some to switch mode. If you have a rumble motor, it will rumble briefly to tell you which mode it activated.Problem: The aim is not working at all.Solution: Pushing buttons work? Yes => issue with your LEDs. No => wrong gun settings or connection problem with your Arduino.Problem: The aim is suddenly messed up.Solution: The cam has trouble seeing your LEDs correctly, or the gun settings are wrong.Problem: The aim is working in the center of the screen, but on the sides it's not aiming properly.Solution: You are not in the right screen aspect mode.*2020/08/21 - GUI v0.94beta - Firmware 2.26- firmware: fixed a bug that prevented the sensitivity profiles to load correctly- GUI: removed the custom max sensitivity level, as it's not working correctly*2020/05-08 - 2.25*2020/04/30 - 2.22- big update of the detection and tracking, it now works better, faster and more precise than ever- various update to make it compatible with the GUI*2020/04/30 - 2.16* 2020/04/13 - 2.07* 2020/04/11 - 2.06* 2020/04/09 - 2.05 - unified firmware* 2020/02/29 - 1.93- reworked the aiming and detection, to make it faster and better- fixed some bugs* 2020/02/29 - 1.91- rewrote the 3 points aiming calculation, it's way more precise now- changed the test tool to better see the led recognition.* 2020/02/28 - 1.87- 2 points detection is now inactive if too close from the screen, to avoid misdetection* 2020/02/28 - 1.86- fixed calibration issues- fixed aiming issues- fixed the flash/clear tool* 2020/02/28 - 1.85- rewrote the whole flashing and config tool, now a lot more user friendly!- made a double timing test to be able to flash any arduino. No need to modify the bat file anymore.- various optimizations- IR points detection bug corrected, it should be a bit more stable now- reworked the buttons management- merged normal and test firmware, now the test tool should trigger the test mode (replug the arduino once to reboot in normal mode)- added RGB LED support for the 7 button + LED firmware! If your gun uses more than 7 buttons or if you don't want LED support please use the 11 buttons firmware- added temperature sensor support! connect a tmp36 sensor to pin A0- added rumble and LED feedbacks when changing modes- added various LED feedbacks- added EEPROM save and load gun data- updated the game screen ratio modes for better usage and compatibility, now there are only 2; fullscreen and 4:3- updated the test tool, now the one pde tool supports both normal and full screen, and has more options (don't use the old tools)* 2020/02/18 - 1.76- reworked the buttons management again and fixed the remaining issues (with the calibration for instance)- fixed the bug with the feedback when offscreen reload is disabled, now it should trigger the solenoid (the way it works remain unchanged when offscreen reload is enabled)- modified the flashing batch file to be more compatible (detects bootloader whatever the model, and waits for 6 seconds now)- rewrote part of the guide, added installation instructions* 2020/02/16 - 1.75- fixed the combo buttons functions (joystick mode, offscreen shot...)- reworked the buttons management to decrease risks of bugs and future-proof it- did a lot of small optimization to increase the execution speed.- changed the zip file, firmware name and flash bat again, now you can know which firmware you have, and choose between normal and test firmware. Please don't mix with the previous files.* 2020/02/15 - 1.70- restored the cursor accuracy without increasing the load, it should eliminate most wobbles- put everything in only one zip and renamed the batches file for more clarity.- added diagrams for the gun feedbacks* 2020/02/12 - 1.68- Improved 2 points detection, optimized other functions- updated the .pde sketch for IR testing* 2020/02/12 - 1.66- fixed bugs and 2 points detection* 2020/02/11 - IR cam testing tool- added test app* 2020/02/09 - 1.55 beta- Rewrote aiming calculation- Added a better tilt/twist detection, it increases the maximum tilt to 89 degrees on each side.- Added a function to disable the press of secondary button when shooting offscreen.* 2020/01/19 - 1.35- improved the led and twist detection* 2020/01/18 - 1.3- cleaned code, added manual screen calibration.* 2019/10/26 - 1.2- first public versionPL1 for his Pro Micro diagramFoxhole for his support and careful testingAnd everyone else in the forum for supporting this project and keeping the arcade love alive