Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: SAMCO DIY Arduino Powered IR Light Gun  (Read 84912 times)

0 Members and 1 Guest are viewing this topic.

Owillingham

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:July 06, 2021, 09:59:29 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #120 on: June 20, 2021, 09:13:40 am »
Any schematics for including recoil on the Samco lightgun?  have parts on order to build the Samco gun, but would be nice to include recoil at the same time of building.

samco

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:November 28, 2023, 04:34:44 pm
  • SAMCO Light Gun Creater
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #121 on: June 21, 2021, 12:20:17 am »
Hi, think I already answered this on facebook. But yeah, have schematics available on my GitHub (for ItsyBitsy but should be easy enough to adapt to other boards and can already change Pin assignments in code if you need to). Recoil is still a work in progress so no documentation yet.

Dam0

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:July 07, 2023, 06:50:40 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #122 on: August 04, 2021, 03:51:06 am »
SAMCO, after many months of leaving your 1.0 arduino kit on the shelf, i finally re-plugged the gun in and it works flawlessly....

so thanks for all your hard work, now to gather the light-gun games i got into a single frontend.

i "think" my issue in the end was i was standing too close buy about a good metre maybe more. so all up, for a 24" screen i recon id be 5-6 foot away from the screen for the cursor to operate properly.

i kinda thought on it a bit in hindsight, that after reading about some ppl using lenses on their gun4ir setups to reduce the focal length makes some sense .

anyhow, thanks for your hard work . very happy i waited this time, before i cracked a poopy pants

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #123 on: August 07, 2021, 01:06:48 pm »
I made an enhanced version of the SAMCO project. The enhancements are:
  • Increased precision for maths and mouse pointer position
  • Glitch-free DFRobot positioning (DFRobotIRPositionEx library)
  • IR camera sensitivity adjustment (DFRobotIRPositionEx library)
  • Optional averaging modes can be enabled to slightly reduce mouse position jitter
  • Enhanced button debouncing and handling (LightgunButtons library)
  • Modified AbsMouse to be a 5 button device (AbsMouse5 library)
  • Multiple calibration profiles
  • Save settings and calibration profiles to flash memory (SAMD) or EEPROM (ATmega32U4)
  • Built in Processing mode for use with the SAMCO Processing sketch

Much of the code was re-worked but the positioning math calculation is all from SAMCO. It is fantastic how well this works!

One big change is with the button handling code that allows button combinations. For example, you can assign a button combination to enter pause mode that you will never press while playing a game so the reload button can be assigned a mouse button or key press.

The other big enhancement is the calibration profiles. I found myself sometimes wanting to play on my big screen TV and other times on my monitor. Combine that with 4:3 aspect ratio games requiring different calibration data, adding multiple profiles is an obvious solution. While the calibration procedure is simple, it's even faster to just press a button to select a profile.

Support for the ATmega32U4 boards was a bit of a last minute addition and not as well tested, but it should work (though I haven't tested saving to EEPROM).

The buttons in the sketch are configured for a SAMCO 2.0 GunCon 2 build. If your gun has different button pin assignments then you will have to modify the sketch.

You can get the source code from: https://github.com/Prow7/ir-light-gun
See the readme files on GitHub for more details.

Big thanks to Samco for this project. Your custom PCB made it super easy to mod a GunCon 2! Also thanks to Gustavo for his Apexel lens adapter models. A fantastic solution to the less than ideal narrow FOV that the camera has.

samco

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:November 28, 2023, 04:34:44 pm
  • SAMCO Light Gun Creater
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #124 on: August 08, 2021, 08:48:13 pm »
Wow, this is awesome Prow! I was hoping that a gun coder would get their hands on my code at some stage.

Haven't got a spare SAMD board to try it out yet but just looking through your code, I'm super impressed. Can't wait to try it out!

Cheers Sam(co)

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #125 on: September 11, 2021, 07:00:01 pm »
Hiya!New face peeking in to say thanks, because this project's given me the perfect inspiration to get and mod a GCon 2 for myself. Would be the first good lightgun solution I've found that isn't in some desolate theater arcade.

Had a few asks, though:
  • How accurate is the SAMCO compared to other solutions? And for anyone who's used it, how is the performance any different with @Prow's enhanced fork? I feel like that may as well be the version I use whenever I get around to building this.
  • From what I can tell, the Gun4IR seems to be scarily similar to SAMCO, down to using the same board and camera, but I'm curious what the differences are between the two. For example, the SAMCO uses Wii-styled lightbars which I already have plenty of from using my Wii remote on PC, so it seems awfully more convenient than the specific IR light pods that the G4IR uses. Is there an appreciable difference in accuracy between these two?
  • Sort of an appendix to the last question, but from what I can tell it looks like the G4IR will be getting some form of PS1/2 support as an emulatable Guncon 1. Since both of these projects are more or less running the same handful of Arduino-compatible boards at the core and use the same camera as one another, with just different sketches/software/calibration being the most apparent differences, is it possible the SAMCO will also see similar support? Admittedly, it's one of the reasons I got an EMS TopGun a couple years ago, to use with original hardware because PS2 specifically is a PITA for configuring with lightguns - not to mention the latest 1.7.x builds of PCSX2 removing plugin support, and subsequently killing the nuvee plugin this would rely on.
I know all of that might be a mouthful, but I'm admittedly only just now discovering lightgun mods so these are things I'm considering before diving in head-first for parts. AFAIC, SAMCO sounds cooler and more convenient for my setup, but I want to be sure is all!  ;D

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #126 on: September 16, 2021, 10:01:10 pm »
Had a few asks, though:
  • How accurate is the SAMCO compared to other solutions? And for anyone who's used it, how is the performance any different with @Prow's enhanced fork? I feel like that may as well be the version I use whenever I get around to building this.
  • From what I can tell, the Gun4IR seems to be scarily similar to SAMCO, down to using the same board and camera, but I'm curious what the differences are between the two. For example, the SAMCO uses Wii-styled lightbars which I already have plenty of from using my Wii remote on PC, so it seems awfully more convenient than the specific IR light pods that the G4IR uses. Is there an appreciable difference in accuracy between these two?
  • Sort of an appendix to the last question, but from what I can tell it looks like the G4IR will be getting some form of PS1/2 support as an emulatable Guncon 1. Since both of these projects are more or less running the same handful of Arduino-compatible boards at the core and use the same camera as one another, with just different sketches/software/calibration being the most apparent differences, is it possible the SAMCO will also see similar support? Admittedly, it's one of the reasons I got an EMS TopGun a couple years ago, to use with original hardware because PS2 specifically is a PITA for configuring with lightguns - not to mention the latest 1.7.x builds of PCSX2 removing plugin support, and subsequently killing the nuvee plugin this would rely on.
I know all of that might be a mouthful, but I'm admittedly only just now discovering lightgun mods so these are things I'm considering before diving in head-first for parts. AFAIC, SAMCO sounds cooler and more convenient for my setup, but I want to be sure is all!  ;D

I can't compare the performance to other solutions but the SAMCO 4IR Beta code, which is what I used, has perfect accuracy for a single player directly in front of the screen. I'm currently using light sensor bars from an original EMS LCD TopGun. The only thing I have to do is block the middle IR LEDs on the one sensor bar that has 3 spots. This was one consideration for why I tried out the SAMCO build; it was very easy for me to make a little foam mount for one of the sensor bars to sit on top of my big screen TV.

I guess the main differences with Gun4IR are: different IR emitter layout, a configuration GUI, closed source project, and I think you must use a Pro Micro board (though check the project to confirm the supported boards).

Even though my code will build for the Pro Micro and the 32u4 ItsyBitsy boards, I recommend using an M0 or M4 SAMD board instead. Or, if you wait a bit, then hopefully soon I'll add support for the RP2040 ItsyBitsy and it will be another good option, at least for my code. I actually have it prototyped and working, just need to clean up the code a bit. :)

Interesting you mention PS1/2 support... I tried to find information on the original Xbox light guns, but couldn't find any information, so that was as close as I got to any console support.

Yes, it's a cool project and the custom SAMCO PCB is awesome! makes modding a GunCon super easy. 8)

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #127 on: September 17, 2021, 12:53:38 pm »
I can't compare the performance to other solutions but the SAMCO 4IR Beta code, which is what I used, has perfect accuracy for a single player directly in front of the screen. I'm currently using light sensor bars from an original EMS LCD TopGun. The only thing I have to do is block the middle IR LEDs on the one sensor bar that has 3 spots. This was one consideration for why I tried out the SAMCO build; it was very easy for me to make a little foam mount for one of the sensor bars to sit on top of my big screen TV.

I guess the main differences with Gun4IR are: different IR emitter layout, a configuration GUI, closed source project, and I think you must use a Pro Micro board (though check the project to confirm the supported boards).

Even though my code will build for the Pro Micro and the 32u4 ItsyBitsy boards, I recommend using an M0 or M4 SAMD board instead. Or, if you wait a bit, then hopefully soon I'll add support for the RP2040 ItsyBitsy and it will be another good option, at least for my code. I actually have it prototyped and working, just need to clean up the code a bit. :)

Interesting you mention PS1/2 support... I tried to find information on the original Xbox light guns, but couldn't find any information, so that was as close as I got to any console support.

Yes, it's a cool project and the custom SAMCO PCB is awesome! makes modding a GunCon super easy. 8)
+1 for open source!
I was considering getting the M0 based on your recommendation on the repo, and for futureproofing anyways. But is there any user facing difference going for the RP2040 instead? I mean, I guess saving $2 on raw parts has its plus!I'm certainly patient, since I'd have to wait about a month on the camera alone anyways.

On the note of console support, apparently there's another SAMCO fork that allows it to work on actual PS2 hardware as a Gcon2 - or at least, that's the claim, as I obviously don't have a working setup to know for sure. It's only in the last two days I realized the post on this board. Now, it's obviously a stretch to suggest that these changes could be implemented retroactively in your project, but even just the possibility of having that compatibility is enough to make me genuinely more excited than I perhaps reasonably should be. :P
Anyways, glad to hear. I'll be waiting to see what updates comes to your code. It really has reinvigorated my interest in light gun games again. (^^

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #128 on: September 18, 2021, 06:09:05 pm »
+1 for open source!
I was considering getting the M0 based on your recommendation on the repo, and for futureproofing anyways. But is there any user facing difference going for the RP2040 instead? I mean, I guess saving $2 on raw parts has its plus!I'm certainly patient, since I'd have to wait about a month on the camera alone anyways.
It looks like it should be a drop in alternate to the M0 or M4, at least for the SAMCO project from what I can see. I think even all of the Arduino pin numbers for the buttons match up for the GunCon 2 SAMCO PCB, so the button configuration in the sketch doesn't even need to change.

Quote
On the note of console support, apparently there's another SAMCO fork that allows it to work on actual PS2 hardware as a Gcon2 - or at least, that's the claim, as I obviously don't have a working setup to know for sure. It's only in the last two days I realized the post on this board. Now, it's obviously a stretch to suggest that these changes could be implemented retroactively in your project, but even just the possibility of having that compatibility is enough to make me genuinely more excited than I perhaps reasonably should be. :P
Anyways, glad to hear. I'll be waiting to see what updates comes to your code. It really has reinvigorated my interest in light gun games again. (^^
I don't have a PS2 so I can't test out that code. It would be cool to have that working though.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #129 on: September 20, 2021, 09:13:22 am »
It looks like it should be a drop in alternate to the M0 or M4, at least for the SAMCO project from what I can see. I think even all of the Arduino pin numbers for the buttons match up for the GunCon 2 SAMCO PCB, so the button configuration in the sketch doesn't even need to change.
That looks to be the case.And since the M0 is out of stock, I guess I'm going RP2040.Just ordered all the parts for myself. It'll be a bit belated, but I think it'll be a good enough gift for myself. :p

samco

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:November 28, 2023, 04:34:44 pm
  • SAMCO Light Gun Creater
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #130 on: September 22, 2021, 01:47:24 am »
Hi ThatOneSong, yeah from what I can tell the ItsyBitsy RP2040 should work fine with the M0 sketch. But if you have any problems just let us know either here or on my facebook. https://www.facebook.com/groups/2456595207897603 :)


ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #131 on: September 22, 2021, 10:49:25 am »
Hi ThatOneSong, yeah from what I can tell the ItsyBitsy RP2040 should work fine with the M0 sketch. But if you have any problems just let us know either here or on my facebook. https://www.facebook.com/groups/2456595207897603 :)
I'm looking forward to it! By which I mean, a while for the board and other parts to arrive. Unfortunately I wasn't quick enough on the trigger for the camera so it's on backorder for the moment, but everything--aside from the ItsyBitsy RP and a 3m cable--is being imported anyways. (^^;

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #132 on: September 22, 2021, 12:34:20 pm »
Hi ThatOneSong, yeah from what I can tell the ItsyBitsy RP2040 should work fine with the M0 sketch. But if you have any problems just let us know either here or on my facebook. https://www.facebook.com/groups/2456595207897603 :)
One thing to note is that the ItsyBitsy RP2040 currently will not work with your sketch. The RP2040 does not support the Arduino USB stack and the AbsMouse library only supports the Arduino USB stack.

My modified AbsMouse5 library is working with the Adafruit TinyUSB stack now, which is an option for the RP2040. This update is not yet on my GitHub project, but hopefully soon I'll get back to working on it.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #133 on: September 30, 2021, 10:52:58 am »
Just came in to say I've just received both IB-RP2040 and Samco boards - extra props to samco of course for the quick turnaround. The GCon2 itself is still on its way, but unfortunately the camera has been sitting on Backordered for a bit now. Not sure how long it takes DFrobot to fulfill orders; I didn't anticipate them being in such high demand.
Regardless, I'll be waiting eagerly on the 2040 sketch update.  :applaud:

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #134 on: October 01, 2021, 10:48:36 pm »
The update for the ItsyBitsy RP2040 is now available.

One thing to note is the button pin values in the sketch must be modified if you use the ItsyBitsy RP2040. The sketch uses the Arduino pin numbering as printed on the top of the PCB but these values don't work for the RP2040. The button pin values must be the physical GPIO pin numbers printed on the bottom of the PCB (or see the Adafruit pinouts page). More details on this in the readme. It was a bit odd to me since the A0 through A3 pins are defined, but the digital pins aren't translated... for example D7 is defined as 7, which doesn't translate Arduino to GPIO. ¯\_(ツ)_/¯


samco

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:November 28, 2023, 04:34:44 pm
  • SAMCO Light Gun Creater
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #135 on: October 05, 2021, 08:22:39 pm »
Nice one Prow! Thanks for the heads up on the AbsMouse Library too. I don't have too much time to tinker at the moment so I'll be keeping an eye on this thread to see how this goes and what you guys think of the RP2040.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #136 on: October 06, 2021, 07:57:30 pm »
So I will say the process of getting here was a bit of an experience for me...
First off, without even having gun in hand, following the procedures in advance setting the board up had me for a loop.Firstly, even getting an RP2040 recognized in Arduino software--which Adafruit's store page and documentation contradict one-another atm (one says there is no support, another generic Raspberry Pico page was updated saying there is...)--was difficult since it's a third-party repository that needed a bit of searching to find. Would be nice to add this in the SamcoEnhanced readme for 2040-ers.Sidenote, this might just be my PC, but the board wasn't being assigned a serial driver like it's supposed to, but was stubbornly hanging as an unknown device with no known drivers. I had to force the 'RP2 USB' device to use a Microsoft-brand USB Serial Device. But at least afterwards, I can assign the port number and it was able to be flashed just fine.
One thing that was unclear as a first-timer was the note in the Enhanced repo;
Quote
If you are using an ItsyBitsy M0 or M4 then I recommend you set the Optimize option to -O3 (or faster). If you are using an ItsyBitsy RP2040 then I recommend the -O3 Optimize option.
I was looking and couldn't find any such Optimize flag options; neither in the Preferences, or the Sketch/Tools dropdowns that Ada's documentation suggested should be there. Nada.And results when searching for "Arduino optimization flags" kept bringing up coding habits, but not the GCC flags. There was only one I could find after going through multiple pages that pointed to C:\Program Files (x86)\Arduino\hardware\arduino\avr\platform.txt where I could change the references of -Os to -O3. If there is something I'm overlooking here, feel free to say, but maybe a note should be appended on what exactly this step means on the latest Arduino IDE.
Anyways, from there, code runs, that's all I could get at the time. Fast forward to today and my GCon 2 arrives. Time to get to work.Disassembly and all that wasn't hard at all, thanks to Samco's own video documentation on the process. This was my first substantial soldering work in quite some time, so I was proud to see good joints coming out of it.My main difficulty came when I was adding in a microswitch mod where I had to rip out the original trigger tact switch (what a frick that was), and plant in a microswitch alongside a replacement arm attached to the trigger. While that worked out, it made cable routing feel kind of precarious - of which I also had a bit of trouble, since I tried attaching my microUSB to the board after attaching the B button board, which wouldn't work. I had to take out the button standoff and put the cable in before reattaching, but it felt quite tight. Thankfully, it all ended up coming together in the end.
Prow is all too right about the GPIO mapping. But I figured it out with just a bit of cross-referencing Samco's documents;
Code: [Select]
Trigger = 6
D-Up = 9
D-Left = 8
D-Down = 7
D-Right = 10
C = 11
A/B/Start/Select/Pedal stays the same.
While I'm unfortunately still not able to use the gun due to the camera still being backordered, I can at least confirm all the inputs work (after changing the sketch mappings) as well as the calibration toggle. It will unfortunately be another lengthy wait I imagine before this is really finished, but the process so far has been fun and leaving me with great anticipation for what it's like when it's really working.
A lot of rambling for a lot of nothing seems to be my only contributions here, but I'm kind of okay with that. (^^;

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #137 on: October 11, 2021, 07:46:50 pm »
Self-bumping update: I got the camera, and aside from the TOP label being off by 90 degrees clockwise, it all seems to be working. I'm glad I got one more sensor bar than I needed because the sole one I've had on my monitor for a few years for my Wiimote has such a narrow FOV compared to the new ones I'd just ordered, it's crazy.
I did manage to play through Time Crisis on MAME without any issue, it tracks surprisingly really well and no latency--especially when coming from a wireless EMS.
But after I decided to play T2 Arcade, a few minutes in, the trigger started acting a bit funny and some of the depressed shots were only firing off for a frame or something. It didn't seem to be consistent, but weird how it crops up so late into it.
From what I can tell, I think on some inputs, it's double-clicking instead of firing once and holding like I want it to? Because it's not just the trigger - the start button also on rare occasions can spurt out 1111 which was odd (esp. since it's one of the buttons directly embedded to the Samco2 board).
I was going to say it worked better some time later, but when playing a Naomi shooter through the Flycast core on RetroArch, again halfway through, all my on-screen shots just... stop registering? And when I alt-tabbed, this very messagebox I'm typing this in was being spammed with 1111's.
It's stuff like that which makes it hard for me to believe it's just the trigger microswitch that's bad... it's literally brand new and I even triple-checked my solder points; no joints touching one-another or anything. After writing this part I played Point Blank with lr-Duckstation with no issues, just like with Time Crisis (though I did note two small instances of double-clicking). Maybe it's just brandist against anything non-Namco.

@Prow, any idea what's up here?

EDIT:L Update to the update. Of course, the next morning I try to confirm the trigger issue and it's working perfectly again. But the D-pad (and kinda start button) is still sticky sometimes.

But I've noticed on two separate instances that after some time (pretty much *only* happens after putting the gun down for a bit then up again), the calibrated aim is offset a quarter-screen to the right, despite not having moved at all since. But it's fixed with a re-calibration, so... I don't have a clue really.
« Last Edit: October 12, 2021, 11:08:33 am by ThatOneSeong »

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #138 on: October 13, 2021, 01:08:52 am »

From what I can tell, I think on some inputs, it's double-clicking instead of firing once and holding like I want it to? Because it's not just the trigger - the start button also on rare occasions can spurt out 1111 which was odd (esp. since it's one of the buttons directly embedded to the Samco2 board).
I was going to say it worked better some time later, but when playing a Naomi shooter through the Flycast core on RetroArch, again halfway through, all my on-screen shots just... stop registering? And when I alt-tabbed, this very messagebox I'm typing this in was being spammed with 1111's.
Adjusting the debounce time will hopefully fix this. I'm not sure why I set the debounce times lower than they need to be. I'll make a note to fix the sketch. With that said, I don't have any issue with my gun and the buttons.

Quote
But I've noticed on two separate instances that after some time (pretty much *only* happens after putting the gun down for a bit then up again), the calibrated aim is offset a quarter-screen to the right, despite not having moved at all since. But it's fixed with a re-calibration, so... I don't have a clue really.
Interesting you report this as I had this happen once recently. In my case, I reconnected the USB cable and it was fine since I have the calibration stored in NVRAM. Just as you say, I recall I set the gun down for a bit and then when I picked it up the aim was way off. If you can reproduce this it would be interesting to know if the calibration values somehow change. You can view them in the serial monitor (or any serial terminal program). I was unable to reproduce it, but only tried a few times.

Quote
I was looking and couldn't find any such Optimize flag options; neither in the Preferences, or the Sketch/Tools dropdowns
I jumped the gun on this one... I submitted a Pull Request to the Arduino Pico project and expected an update to be released before anyone would actually use an RP2040 build. It actually may not matter all that much, but might as well optimize for speed. I'll update the wording to describe it as an optional setting if it's available.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #139 on: October 17, 2021, 10:33:35 pm »
Heeey, sorry for the wait. Been pulled away for some time on some PC upgrades and switching to Linux. Fun.
Interesting you report this as I had this happen once recently. In my case, I reconnected the USB cable and it was fine since I have the calibration stored in NVRAM. Just as you say, I recall I set the gun down for a bit and then when I picked it up the aim was way off. If you can reproduce this it would be interesting to know if the calibration values somehow change. You can view them in the serial monitor (or any serial terminal program). I was unable to reproduce it, but only tried a few times.
Seems like we've both only had this happen once without any way to reproduce. But this hasn't happened often. And I appreciate the honesty - easily forgiven, though no less confusing for a first-timer. I think it's safe to say the debounce--or lack thereof--only affects my membrane buttons, but definitely not an issue with the trigger (the unresponsiveness might've just needed some time to get worn in. shrug).
As of now, I'm just trying to work out how to get this working in X11. Not the most straightforward thing to say the least. :laugh:

DeKay

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 1
  • Last login:January 28, 2024, 01:31:20 pm
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #140 on: October 25, 2021, 07:03:59 pm »
Hey Prow.  You and Samco are doing great work here!  I sent you a few minor fixes for things I tripped over getting my ItsyBitsy M4 set up this weekend in a github pull request.  I really have to learn to use git properly one of these days   :)

woordmand

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 21
  • Last login:January 27, 2022, 01:34:09 pm
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #141 on: January 07, 2022, 12:03:20 am »
I made an enhanced version of the SAMCO project. The enhancements are:
  • Increased precision for maths and mouse pointer position
  • Glitch-free DFRobot positioning (DFRobotIRPositionEx library)
  • IR camera sensitivity adjustment (DFRobotIRPositionEx library)
  • Optional averaging modes can be enabled to slightly reduce mouse position jitter
  • Enhanced button debouncing and handling (LightgunButtons library)
  • Modified AbsMouse to be a 5 button device (AbsMouse5 library)
  • Multiple calibration profiles
  • Save settings and calibration profiles to flash memory (SAMD) or EEPROM (ATmega32U4)
  • Built in Processing mode for use with the SAMCO Processing sketch

Much of the code was re-worked but the positioning math calculation is all from SAMCO. It is fantastic how well this works!

One big change is with the button handling code that allows button combinations. For example, you can assign a button combination to enter pause mode that you will never press while playing a game so the reload button can be assigned a mouse button or key press.

The other big enhancement is the calibration profiles. I found myself sometimes wanting to play on my big screen TV and other times on my monitor. Combine that with 4:3 aspect ratio games requiring different calibration data, adding multiple profiles is an obvious solution. While the calibration procedure is simple, it's even faster to just press a button to select a profile.

Support for the ATmega32U4 boards was a bit of a last minute addition and not as well tested, but it should work (though I haven't tested saving to EEPROM).

The buttons in the sketch are configured for a SAMCO 2.0 GunCon 2 build. If your gun has different button pin assignments then you will have to modify the sketch.

You can get the source code from: https://github.com/Prow7/ir-light-gun
See the readme files on GitHub for more details.

Big thanks to Samco for this project. Your custom PCB made it super easy to mod a GunCon 2! Also thanks to Gustavo for his Apexel lens adapter models. A fantastic solution to the less than ideal narrow FOV that the camera has.
I used your improved version of sanco firmware on 32U4, it is really good.  But compared to gun4ir, it lacks support for electromagnets.  Calibration is not very friendly either.  Hope to see the updated version of the firmware.

sparehead1

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:March 05, 2023, 01:15:33 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #142 on: January 07, 2022, 05:49:23 am »
Hi there! I've ordered some Samco boards, guncon 2's, cameras, and itsy-bitsy M4's. I want to use them on a projector screen so I was wondering if there are guides for the distance from the screen in relation to screen size? Can I use fish eye or wide-angle lenses? Should I still use Wii sensor bars or can I use 4 IR LED's spaced out a little more? Thanks in advance! I'm looking forward to building them!

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #143 on: January 07, 2022, 12:24:50 pm »
Hi there! I've ordered some Samco boards, guncon 2's, cameras, and itsy-bitsy M4's. I want to use them on a projector screen so I was wondering if there are guides for the distance from the screen in relation to screen size? Can I use fish eye or wide-angle lenses? Should I still use Wii sensor bars or can I use 4 IR LED's spaced out a little more? Thanks in advance! I'm looking forward to building them!
From my experience you will want to use at least a wide angle lens.

If you already have 2 Wii sensor bars then might as well just try it out with them first.

For a bit of reference, I use sensor bars from an original EMS LCD TopGun which have the IR emitters approximately 33cm apart. I have a super wide angle lens on my gun (the FOV is less than a fish eye lens) and I can be positioned around 2M away from my 65" TV.

sparehead1

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:March 05, 2023, 01:15:33 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #144 on: January 07, 2022, 10:46:52 pm »
Thanks Prow :)

I dont have sensor bars yet so I think I'll make some IR LED arrays. Any recommendations for super wide or fish eye lens's? I want to use it on my 110" screen.

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #145 on: January 08, 2022, 03:49:09 pm »
I dont have sensor bars yet so I think I'll make some IR LED arrays. Any recommendations for super wide or fish eye lens's? I want to use it on my 110" screen.
Good idea to make your own IR emitters. I can only guess maybe Wii sensor bars may not be spaced out enough for a screen that large.

For the lenses, I bought an Apexel lens kit. However, I have noticed many people in the Gun4IR Discord buy a cheap 3 in 1 mobile phone lens kit which includes a wide angle and fish eye lens. I don't know if some accuracy aiming at the corners will be lost when using a fish eye lens due to the distortion, I haven't tried it. :dunno I saw that mentioned which is why I initially used the wide angle lens but then swapped in the super wide angle lens.

rbarr110

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 298
  • Last login:September 25, 2023, 04:02:41 pm
  • I already built my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #146 on: January 09, 2022, 03:00:14 pm »
I am so glad I found this thread.  I wanted light guns soooo bad 10-15 years ago when I was more active here.  My current machine I built is too big for my wife, thanks CRT monitors.  So I have been toying with a new cabinet design off and on for years and finally got to a point that I think I can make what I want.

Had the GunCon 2's for a while and the SAMCO solution looks soo easy that I had to do it.  Everything is ordered, only thing that may hold this back is the damn backordered DF robot cameras. 

sparehead1

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:March 05, 2023, 01:15:33 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #147 on: January 10, 2022, 05:14:34 am »
For the super wide lens this the one that's recommended?

Prow

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 11
  • Last login:Today at 10:05:02 am
  • I'm here for Light Guns
    • github.com/Prow7/ir-light-gun
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #148 on: January 10, 2022, 12:16:40 pm »
For the super wide lens this the one that's recommended?
I have the APL-DG7 lens kit (7 in 1). So that kit does look similar and gives you the 3 useful lenses to try out.

ThatOneSeong

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:Yesterday at 11:48:38 pm
  • Just your average Seong.
    • Twitter
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #149 on: January 18, 2022, 01:37:10 pm »
However, I have noticed many people in the Gun4IR Discord buy a cheap 3 in 1 mobile phone lens kit which includes a wide angle and fish eye lens. I don't know if some accuracy aiming at the corners will be lost when using a fish eye lens due to the distortion, I haven't tried it. :dunno
I can speak to being one of those "many people." It's okay I suppose. The fisheye causes too much distortion for the dual light-strip array, presumably whacking out the rectangular field that the sketch expects. Using the wide angle combination seems to work better, about as fine as vanilla, though I had to bump up the sensitivity by one level to make it work consistently (dunno how much of that is just having more sunlight than usual).
If only I'd known this earlier; the super wide lens seems the best option for Samco in general. But that'll have to wait until after I've moved house. Another two months long wait for shipping from China.  :badmood:

sparehead1

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:March 05, 2023, 01:15:33 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #150 on: January 18, 2022, 07:04:59 pm »
I went with the super wide which is now on a slow boat. I thought I'd snagged the last 2 cameras from element14 but now my order says they are on back order and not expected to ship until June  :(

sparehead1

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:March 05, 2023, 01:15:33 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #151 on: May 14, 2022, 08:13:08 pm »
My camera's turned up :D

now I need to find a way to attach the wide-angle lens's :/

scratcher53

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:February 07, 2024, 07:47:17 pm
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #152 on: May 19, 2022, 05:02:39 pm »
Hi All,
New to light guns but have a few questions.
i have built two Samco guncon2 guns and using the 4 ir sketch, may use prow enhanced sketch, is there a way to re asign some keys. EG move the calibration key to the down key on the d pad and asign ESC to the up key. Also move the reload key from the left side to the bottom (currently the calibration key) ?
Thanks,


fgh

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:March 26, 2024, 04:27:20 am
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #153 on: October 05, 2022, 02:19:40 am »
Hey guys,

Finally got myself some Samco boards for some light gun action..


Samco: Absolutely awesome work! This is so convenient with the PCB all laid out! I've uploaded the 4IR_beta sketch, and it tracks well. (GCon2, 32u4).
Also, I saw your cool mini cabinet with that sweet recalbox setup. Any chance you will ever share it (without roms)? Is it a pi3 or 4?

Anyway - I'm loving it so far. Will make a dedicated cabinet similar to my main cab (link), but with just one monitor.
Thanks a lot for making this! :)


Prow: That looks like some nice updates! I just had a go with your sketch as well. My setup works well so far on Samco's 4IR_beta on a guncon2 with a 32u4 5V.
With your sketch, however, I have trouble calibrating. Both X and Y seems to be offset by more than half my 27" screen, and when calibrating, the A and B buttons do not seem to have any effect. (This part also works well with Samco's sketch.)
Also tried the relevant dpad buttons to move the X/Y centering (pushed momentarily and held them down lots of times), but nothing happened. (all buttons work in notepad).
In other words - As soon as I start calibrating by pressing the trigger while aiming at the center cursor, the cursor jumps quite far upwards for the vertical alignment, and I cannot get it to center or track any closer. And a similar jump to the left edge when starting horizontal calibration.
So I get smooth tracking from both sensor bars it seems, but offset by a huuge margin. (30-40cm horizontal and 15-20cm vertical)
Any ideas?

(I don't know how to set compiler options, but as far as I could see from the docs, I could leave all at default for 32u4 and guncon2.)


Cheers,
Frode
« Last Edit: October 05, 2022, 02:29:22 am by fgh »

samco

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:November 28, 2023, 04:34:44 pm
  • SAMCO Light Gun Creater
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #154 on: October 11, 2022, 05:46:34 pm »
Thanks Frode! Yeah, my mini cabinet runs on a Pi4 8Gb. Was planning on cleaning up the theme a bit (it's the first one I've ever made so it's a bit of mess) and adding a few more guns i.e. PS2 etc but got a bit busy so went on the back burner. Hopefully one day I'll get some time to fix it all up and release it.

Cheers Sam(co)

DemmyTree

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 2
  • Last login:December 02, 2022, 10:50:56 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #155 on: November 29, 2022, 03:28:53 pm »
Sorry to bother you, im having issues with the setup of the lightgun, i've bound everything to the PCB and have been trying to upload the code but it is coming up with failures no matter what im attempting.

It seems the problem that comes up is mainly to do with the HID and USB Endpoint, im not sure what that means and need assistance if anyone is able to explain this.

samco

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:November 28, 2023, 04:34:44 pm
  • SAMCO Light Gun Creater
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #156 on: December 01, 2022, 07:54:47 pm »
Sorry to bother you, im having issues with the setup of the lightgun, i've bound everything to the PCB and have been trying to upload the code but it is coming up with failures no matter what im attempting.

It seems the problem that comes up is mainly to do with the HID and USB Endpoint, im not sure what that means and need assistance if anyone is able to explain this.


Hi Mate, any chance you can chuck up a screenshot of the IDE (including errors). Might be able to give ya hand.

DemmyTree

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 2
  • Last login:December 02, 2022, 10:50:56 am
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #157 on: December 02, 2022, 10:49:23 am »
Sorry to bother you, im having issues with the setup of the lightgun, i've bound everything to the PCB and have been trying to upload the code but it is coming up with failures no matter what im attempting.

It seems the problem that comes up is mainly to do with the HID and USB Endpoint, im not sure what that means and need assistance if anyone is able to explain this.


Hi Mate, any chance you can chuck up a screenshot of the IDE (including errors). Might be able to give ya hand.
I've never touched Arduino before and just used the stock sketch you created for it. Im using the ItsyBitsy M0 Express but have also attempted it on a M4 Express as well.

The version is 1.8.15 on Samco_1.1_4IR_BETA.ino (i have tried the 2IR version and also had the same failure occurrence) The board is not soldered onto the PCB however it is held in by headers with an additional header to keep it in place

On the serial monitor it picks up the camera partially keeps repeating with no movement of the cursor occuring when shifting the gun around.
15:47:58.811 -> CALIBRATION:     Cam Center x/y: 512, 450     Offsets x/y: 1.47, 0.82
15:47:58.861 -> Device not available!


In file included from C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\cores\arduino/Arduino.h:157,
                 from C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\cores\arduino/USB/SAMD21_USBDevice.h:22,
                 from C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\cores\arduino/USB/USBAPI.h:37,
                 from C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\cores\arduino/USB/PluggableUSB.h:23,
                 from C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\libraries\HID\HID.cpp:19:
C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\libraries\HID\HID.cpp: In member function 'virtual int HID_::getInterface(uint8_t*)':
C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\cores\arduino/USB/USBCore.h:37:56: warning: narrowing conversion of '(int)(((unsigned char)((int)((HID_*)this)->HID_::<anonymous>.PluggableUSBModule::pluggedEndpoint)) | 128)' from 'int' to 'uint8_t' {aka 'unsigned char'} [-Wnarrowing]
   37 | #define USB_ENDPOINT_IN(addr)                  ((addr) | 0x80)
      |                                                ~~~~~~~~^~~~~~~
C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\cores\arduino/USB/USBCore.h:276:10: note: in definition of macro 'D_ENDPOINT'
  276 |  { 7, 5, _addr,_attr,_packetSize, _interval }
      |          ^~~~~
C:\Users\DemmyTree\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.11\libraries\HID\HID.cpp:36:14: note: in expansion of macro 'USB_ENDPOINT_IN'
   36 |   D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, 0x40, 0x01)
      |              ^~~~~~~~~~~~~~~
Sketch uses 48236 bytes (18%) of program storage space. Maximum is 262144 bytes.
Device       : ATSAMD21x18
Version      : v1.1 [Arduino:XYZ] Jun 23 2019 17:45:14
Address      : 0x0
Pages        : 4096
Page Size    : 64 bytes
Total Size   : 256KB
Planes       : 1
Lock Regions : 16
Locked       : none
Security     : false
BOD          : true
BOR          : true
Write 48556 bytes to flash (759 pages)
[==============================] 100% (759/759 pages)
Done in 9.417 seconds
Verify 48556 bytes of flash
[==============================] 100% (759/759 pages)
Verify successful
Done in 3.808 seconds

samco

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 52
  • Last login:November 28, 2023, 04:34:44 pm
  • SAMCO Light Gun Creater
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #158 on: December 05, 2022, 01:22:12 am »
Hi @DemmyTree, it looks like a connection problem. "Device not available!" basically mean the ItsyBitsy cannot connect to the camera so you could double check you've got all the wires round the right way and try again. But I think it's probably more likely you just not getting a good connection because nothing is soldered in.

scratcher53

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 4
  • Last login:February 07, 2024, 07:47:17 pm
  • I want to build my own arcade controls!
Re: SAMCO DIY Arduino Powered IR Light Gun
« Reply #159 on: December 11, 2022, 07:45:33 pm »
Hi Sam,

I have built two of your guns and use them with demulshooter and various emulators in bigbox / launchbox. The problem i have is people keep hitting the calibration button by mistake. The question is can i change the calibration button to one of the d pad buttons and then have the original calibration button as the reload button. I have looked at the code but it all went over my head.
Thanks for the help