SlotForum banner

Arduino UNO R4

5.7K views 85 replies 9 participants last post by  ZeGas  
#1 ·
Folks:

I was cruising the web this morning when I came across this Arduino user forum thread:

Maximum Pin current! - UNO R4

The gist of the discussion that affects slot car users is that these newest UNOs (already on sale at the Arduino web site) are a "you don't get somethin' for nuttin'' deal. The two UNO R4 models (Minima and WiFi) are faster and provide more features (the built-in 12x8 array of LEDs on the WiFi model is intriguing). BUT - if you happen to be a user that uses Arduino pins to directly drive "higher-current" devices such as LEDs, you are not so well off with an R4. The UNO R3 specs state being able to drive/sink up to 20 mA of current per pin - but the R4 maximum pin current has been reduced to 8 mA (and somewhere in the discussion folks were saying that some pins may only be capable of 4 mA).

SO what does this mean? Well, IF you have an existing UNO R3 setup which drives LEDs "without a sweat", you might not be able to replace the R3 with an R4 without some changes. You may need to increase the value of current limiting resistors you use. IF YOU DON'T, YOU MIGHT BURN OUT SOME I/O PINS ON YOUR NEW UNO R4! In general, you may need to consider adding external buffer/driver circuits.

I find this ironic as I have been working on the RC Tech/User Manual and yesterday afternoon had just finished a section about how to wire up an UNO R3 to support a 4-lane track. That included my blabber about the current limiting resistors needed if you wired in optional start light LEDs. With this new info about the R4, I should at least put in some text about how the example specifically uses an UNO R3, and that things are different if you wire up an R4. Ah, tech constantly changes... :geek:

Regards,
BBB
 
#2 ·
Just use a relay board , cheap as chips on ebay ,8,16,32 in/ou , then you can drive anything you want 😉.

And yes very odd why they backtracked on this side 🤔.

Also Ruggeduino an option if you want more grunt and miss out the relay board 👍🏼.
 
#7 ·
BUT - if you happen to be a user that uses Arduino pins to directly drive "higher-current" devices such as LEDs, you are not so well off with an R4. The UNO R3 specs state being able to drive/sink up to 20 mA of current per pin - but the R4 maximum pin current has been reduced to 8 mA (and somewhere in the discussion folks were saying that some pins may only be capable of 4 mA).
Crikey, that's your Arduino start light gantry up the swanny then with an R4...when I next buy a R3 clone (still available for under a tenner), I might buy a few.

Looks like there are potential workarounds but not ones your average slot car guy might want to play with.
For example:

Thanks for posting!
 
#9 · (Edited)
An obvious example is start light gantry, most use a RJ45 cable as it has 8 cores enough for 5G/R/Y/GND. All you need is a simple sketch and to solder up some bright LEDs in the configuration of your choice to the RJ45 and other end to socket/pins. Pretty simple, lots of RMS programs support Arduinos too so you can sync.

Or pit lane sensors, speed traps, LED track lighting etc...so many uses for Arduinos on slot car tracks (and other hobbies!).

No esp32 WIFI, BT or additional RAM required for the above, right tool for right job, right? ;-)
 
#13 ·
Thought I'd give it a quick try:-
For R4 & ESP32 WiFi comment out line
#define WITH_WATCH_DOG

Then remove

SERIAL_PRINTLN("Doing software reboot");
asm volatile("jmp 0");


And it compiles for both platforms, not sure if it will work though, probably need to find a way to reset without the assembler above.

Should be pretty simple to get either working an communicating to the PC using bluetooth.
 
#14 ·
If the reset doesn't work it won't work at all. The first thing RC does is reset the board and that has to be done when RC is ready for the Version response.

Wifi won't work, although the board itself should. A long time ago I asked if people wanted a wifi interface for RC and got birds chirping. Likely they didn't fully understand what I was asking.
 
#15 ·
I just tried uploading the 1.0.0.13 RC sketch to an UNO R4 WiFi. The sketch does not verify - it throws this error:

Code:
C:\Program Files (x86)\Race Coordinator\data\arduino\lapCounter\lapCounter.ino:40:10: fatal error: avr/wdt.h: No such file or directory
#include <avr/wdt.h>
          ^~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: avr/wdt.h: No such file or directory
From what I can tell, the error is generated because the processor used in the R4 is NOT an AVR family processor. So looks like some work to support the R4 UNO - hopefully you can conditionally load the appropriate watchdog file depending on what generation(s) of UNO you are using...

Regards,
BBB
 
#20 ·
If you have an R4, make the changes I put above if it all works then create an R4 addendum for your docs, for folks who want to go forward.

I expect R3 or clones will be around for a good few years. Most the Arduino forums seem to think so too, don't forget Uno is open source so anyone can sell Uno boards.
 
#21 ·
My recommendation would be to put a "WITH_R4" define in the sketch. That way we can turn it on/off. This new define would replace the current reset code (watchdog and asm code) with what he has above. If that's done, and somebody verifies it, I'd include it in the next RC release for anybody to use.

Does R4 have built in BT? If it does, that would be nice to support at some point so BT users don't need the addon board. Someday when I retire I'd like support the wifi on the board as well. I assume it has wireless, in which case it would be really cool to have another wireless option. I suspect wireless support wouldn't be hard, but it will require both sketch changes to configure and send the data over wifi, and changes to RC to support it...
 
#22 ·
Oooooh. The R4 has a HID interface which means if supported, no more virtual serial port. We could auto-detect the board and no more driver installs would be required.

And the wifi version has built in BT which makes that a lot easier for end users (no more daughter board and having to flash/deal with it). Interesting, I'd likely not need to support wifi with the built in BT. Except maybe to support old PCs with a network card but no BT.

I wonder how many win10 (and newer) PCs have BT and how many do not?
 
#24 ·
I've replaced the jmp 0 instruction with @Slingshotx 's suggestion and replaced #include avr/wdt.h with #include <WDT.h> as suggested in the Arduino IDE's UNO R4 example code. The modified sketch does verify but gives this warning:

WARNING: library WDT claims to run on renesas architecture(s) and may be incompatible with your current board which runs on renesas_uno architecture(s).​

Odd, since I used the WDT header file they suggested. Anyway, I've been able to upload this modified sketch to the UNO R4 WiFi. Doing so did wipe out the display of the heart on the spiff little 12x8 LED matrix. Looking around on the web last night, I did see that there is a library available to futz around with the little matrix display, so just for fun here ya go.

Image


I'll try to hook up the R4 later today and see if it can successfully talk to RC.

Regards,
BBB
 
#25 ·
If you commented out //#define WITH_WATCH_DOG, and used NVIC_SystemReset() you shouldn't need WDT.h at all. I think it's only needed for the watchdog code.

If it works and Dave doesn't have time I'll do a version of the sketch that should work on all 3 platforms R3, R4 and my favourite ESP32.
I may even try do a BT version that will connect to RC without additional boards.