- Joined
- Jul 9, 2020
- Messages
- 228
- Likes
- 499
It's been a few weeks since I posted in the work log... I've put alot of hours into the project with out a ton to show for it... Worked on prototyping a controller on a proto board so I could start to understand how these chips interact. Studied up on the guide hub post on controller chip pinout. Desoldered and wired up some buttons... Gman said its better to keep it on the board and trim around it so took the advice and trimmed controller board around chip while keeping the oscillator.
It was more of a proof of concept to myself, I knew that this was not going to be the solution that would go into the portable. Still it was a good exercise to understand the fundamentals of the controller. Integrating this NUS-CNT into a custom PCB would be the end goal, even though I was still open to finding an existing community pcb to use in the portable.
Still needed a MCU solution for the joystick conversion. In my very first conversation with @YveltalGriffin, he shared with me about an attiny24 centered analog joystick to n64 encoder signal converter (https://nfggames.com/forum2/index.php?topic=5803.0). Griff told me that I could program this project with an Arduino UNO, ordered that on amazon. I tried sending an email to purchase boards from the man on NFGGames forum, but no response for weeks. Took the gerber files to JLCPCB and had a small run printed and shipped. Luckly, the day I started investigating controller boards, this PCB showed up in the mail. I went down that rabbit hole for quite a while...
I built the board pretty quickly, although none of the analog sticks fit the footprint.. I had to finagle it in there with some bent pins at an angle... but electrically it was sound.
I spent the better part of two days trying to figure out how to flash the MCU. What a freaking journey. I used Arduino IDE with the Ardiuno UNO over usb to program the ATTINY24 (eventually). First step was to program the arduino to be an Arduino as ISP; load up the example template called ArduinoISP. Make sure arduino uno is selected as the device and also confirm the port is properly selected for the COM port. Verify, compile, and flash to UNO with ArduinoISP.
I had to build a header cable to connect the arduino to the attiny. The board had 6pin ICSP header but Griff recommended that I dont use the icsp on the arduino but rather the pins 10-13 on the long arduino header. Since this was the new way, i needed to go into the arduino code and activate this style wiring.
if you scroll down the programming text you will find:
// #define USE_OLD_STYLE_WIRING
If you delete the slashes it will use old style wiring...
Now that the arduino is programmed, I can wire up the header pins to the ICSP. It is also important to note that if you do not put a capacitor between reset pin and ground, the arduino won't be able to program the Attiny24 for some reason i dont quite understand. Basically, there is a condition that the MCU and arduino reach that would trigger the arduino to reset when we don't want it to... Thats why we need the cap. Here is the documentation from Arduini IDE program:
pins MOSI, MISO and SCK are the same pins as
// digital pin 11, 12 and 13, respectively.
Pin 10 is the reset pin for the attiny. NOT the reset pin for arduino. I made a mistake at first and wired a cap between pin 5 and 6 on the ICSP header. But infact it should be as pictured below. With negative leg in ground and other leg in the reset pin on the long header beside the arduino IC.
First we need to burn the bootloader onto the attiny24. I needed to download a bunch of files for AVR and attiny chips... and change the fuse values on board.txt. to 0x42 for the low fuse, and 0xdf for the high fuse. Select the chip from IDE's "Tools" menu, set processor speed to 1MHz, select port the same as before, select programmer as "Arduino as ISP", then "hit burn bootloader". This took me a few trys to get this far...
After that being a success, I had to flash the hex and eep files... THIS part took me days. Long story short, I had to use my windows 10 virtual machine. find the AVRDUDE directory in my program files. Put a copy of avrdude.conf in the folder too. I put the hex and eep into that same folder (you can also copy all these 4 files to their own folder too). I entered the command line and navigated to the folder where these 4 files are in; AVRDUDE.exe, avrdude.conf, Joystick.hex, joystick.eep. **joystick.hex and joystick.eep is the name of whatever you rename your hex file**
avrdude -P com3 -b 19200 -c avrisp -p attiny24 -v -e -U lfuse:w:0x42:m -U hfuse:w:0xDF:m -U eeprom:w:joystick.eep -U flash:w:joystick.hex -v
This defines the port as COM3, sets baud rate at 19200bps, config as avrisp, target device as attiny24 verifies all that, erases chip, sets low/high fuse, writes 6 bytes to eeprom, flashes 1067 (or so) bytes to chip's program memory.
After what finally showed as a "successful" programming of the chip, the board would not for the life of me (or itself) register to the NUS-CNT controller chip. I made sure that worked with an official joystick. I flashed and flashed and reflashed and changed chips to start over.... Nothing would make it work. I know i was successfully programming the ATTINY24 because I extracted the hex for blink from the temporary files and used it in the same manor and method. I got the attiny to run the blink program.
I even got the gamecube style joystick from the local retro store to do more research. Turns out, as @Gman informed me, these joysticks are a cheap knock off of the open source attiny project that I was working with. I tried swapping that chip in too... nothing there either.
I tried everything to get that thing to work to no avail... So I let it rest for a while.
Thanks to @YveltalGriffin, for helping me get started with the ATTINY programming while he was packing up to move to his new jobby job in a far away land. Thanks buddy!
Thanks to @Gman for the humor and guidance with the mcu programming
Thanks to @Shank for encouragement and kinship in the headache of programming attiny. Sorry it took you through so much headache bud.
_______________________________________________________
I met @printsmith3d, through his worklog of an amazingly cool n64 portable he has been working on... said he had lost the eagle files he had designed but he was kind enough to share the oshpark board file links with me. Got a couple of those printed for further research... perhaps this would be a solution. He used the same attiny project with the code tweaked a bit for switch joysticks.
I had a much easier time programming the MCU this time around. But still it would not register a joystick.
I finally tried his code with a switch joystick and actually got it to recognize it for a moment there but it was all biased incorrectly and needed a calibration. This felt like a small victory... SOMETHING was happening even though it was not quite right. I wired up the switch micro had designed for calibration but at that point no response from joystick again ;\ UGH!
Something has to give...
It was more of a proof of concept to myself, I knew that this was not going to be the solution that would go into the portable. Still it was a good exercise to understand the fundamentals of the controller. Integrating this NUS-CNT into a custom PCB would be the end goal, even though I was still open to finding an existing community pcb to use in the portable.
Still needed a MCU solution for the joystick conversion. In my very first conversation with @YveltalGriffin, he shared with me about an attiny24 centered analog joystick to n64 encoder signal converter (https://nfggames.com/forum2/index.php?topic=5803.0). Griff told me that I could program this project with an Arduino UNO, ordered that on amazon. I tried sending an email to purchase boards from the man on NFGGames forum, but no response for weeks. Took the gerber files to JLCPCB and had a small run printed and shipped. Luckly, the day I started investigating controller boards, this PCB showed up in the mail. I went down that rabbit hole for quite a while...
I built the board pretty quickly, although none of the analog sticks fit the footprint.. I had to finagle it in there with some bent pins at an angle... but electrically it was sound.
I spent the better part of two days trying to figure out how to flash the MCU. What a freaking journey. I used Arduino IDE with the Ardiuno UNO over usb to program the ATTINY24 (eventually). First step was to program the arduino to be an Arduino as ISP; load up the example template called ArduinoISP. Make sure arduino uno is selected as the device and also confirm the port is properly selected for the COM port. Verify, compile, and flash to UNO with ArduinoISP.
I had to build a header cable to connect the arduino to the attiny. The board had 6pin ICSP header but Griff recommended that I dont use the icsp on the arduino but rather the pins 10-13 on the long arduino header. Since this was the new way, i needed to go into the arduino code and activate this style wiring.
if you scroll down the programming text you will find:
// #define USE_OLD_STYLE_WIRING
If you delete the slashes it will use old style wiring...
Now that the arduino is programmed, I can wire up the header pins to the ICSP. It is also important to note that if you do not put a capacitor between reset pin and ground, the arduino won't be able to program the Attiny24 for some reason i dont quite understand. Basically, there is a condition that the MCU and arduino reach that would trigger the arduino to reset when we don't want it to... Thats why we need the cap. Here is the documentation from Arduini IDE program:
pins MOSI, MISO and SCK are the same pins as
// digital pin 11, 12 and 13, respectively.
Pin 10 is the reset pin for the attiny. NOT the reset pin for arduino. I made a mistake at first and wired a cap between pin 5 and 6 on the ICSP header. But infact it should be as pictured below. With negative leg in ground and other leg in the reset pin on the long header beside the arduino IC.
First we need to burn the bootloader onto the attiny24. I needed to download a bunch of files for AVR and attiny chips... and change the fuse values on board.txt. to 0x42 for the low fuse, and 0xdf for the high fuse. Select the chip from IDE's "Tools" menu, set processor speed to 1MHz, select port the same as before, select programmer as "Arduino as ISP", then "hit burn bootloader". This took me a few trys to get this far...
After that being a success, I had to flash the hex and eep files... THIS part took me days. Long story short, I had to use my windows 10 virtual machine. find the AVRDUDE directory in my program files. Put a copy of avrdude.conf in the folder too. I put the hex and eep into that same folder (you can also copy all these 4 files to their own folder too). I entered the command line and navigated to the folder where these 4 files are in; AVRDUDE.exe, avrdude.conf, Joystick.hex, joystick.eep. **joystick.hex and joystick.eep is the name of whatever you rename your hex file**
avrdude -P com3 -b 19200 -c avrisp -p attiny24 -v -e -U lfuse:w:0x42:m -U hfuse:w:0xDF:m -U eeprom:w:joystick.eep -U flash:w:joystick.hex -v
This defines the port as COM3, sets baud rate at 19200bps, config as avrisp, target device as attiny24 verifies all that, erases chip, sets low/high fuse, writes 6 bytes to eeprom, flashes 1067 (or so) bytes to chip's program memory.
After what finally showed as a "successful" programming of the chip, the board would not for the life of me (or itself) register to the NUS-CNT controller chip. I made sure that worked with an official joystick. I flashed and flashed and reflashed and changed chips to start over.... Nothing would make it work. I know i was successfully programming the ATTINY24 because I extracted the hex for blink from the temporary files and used it in the same manor and method. I got the attiny to run the blink program.
I even got the gamecube style joystick from the local retro store to do more research. Turns out, as @Gman informed me, these joysticks are a cheap knock off of the open source attiny project that I was working with. I tried swapping that chip in too... nothing there either.
I tried everything to get that thing to work to no avail... So I let it rest for a while.
Thanks to @YveltalGriffin, for helping me get started with the ATTINY programming while he was packing up to move to his new jobby job in a far away land. Thanks buddy!
Thanks to @Gman for the humor and guidance with the mcu programming
Thanks to @Shank for encouragement and kinship in the headache of programming attiny. Sorry it took you through so much headache bud.
_______________________________________________________
I met @printsmith3d, through his worklog of an amazingly cool n64 portable he has been working on... said he had lost the eagle files he had designed but he was kind enough to share the oshpark board file links with me. Got a couple of those printed for further research... perhaps this would be a solution. He used the same attiny project with the code tweaked a bit for switch joysticks.
I had a much easier time programming the MCU this time around. But still it would not register a joystick.
I finally tried his code with a switch joystick and actually got it to recognize it for a moment there but it was all biased incorrectly and needed a calibration. This felt like a small victory... SOMETHING was happening even though it was not quite right. I wired up the switch micro had designed for calibration but at that point no response from joystick again ;\ UGH!
Something has to give...
Attachments
-
2.2 MB Views: 315
-
2.5 MB Views: 351
-
1.9 MB Views: 364
-
1.6 MB Views: 355
-
1.1 MB Views: 355
-
1.3 MB Views: 334
Last edited: