This is only a preview of the December 2023 issue of Silicon Chip. You can view 37 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Arduino Uno R4 Minima":
Items relevant to "Ideal Diode Bridge Rectifiers":
Items relevant to "Secure Remote Switch, Pt1":
Items relevant to "Multi-Channel Volume Control, Pt1":
Items relevant to "Coin Cell Emulator":
Items relevant to "Recreating Sputnik-1, Part 2":
Purchase a printed copy of this issue for $12.50. |
Review by Jim Rowe
Arduino UNO R4 Minima
A leap forward for Arduino
The R4 is the latest version of the
ubiquitous Arduino Uno. It is a
major upgrade as it has a 32-bit
microcontroller, part of the Renesas
RA4M1 series, with 256kB of
flash, 32kB of SRAM and 8kB of
EEPROM; significantly more than
previous versions. Other features
include a DAC with 12-bit precision,
an ADC with 14-bit precision, a USB
2.0 full-speed module and a real-time clock.
T
he Arduino Uno R4 Minima
resembles earlier versions, such
as the Uno R3. The PCB is identical in
size (68 × 53mm) and shape, and the
SIL header sockets along the sides are
compatible with those of the R3 and
earlier versions. However, if you look
a bit closer, significant differences
become apparent.
For a start, the USB connector at
the top is now a USB-C socket rather
than the Type-B socket used in earlier
versions. There are also fewer components visible; for example, only two
ICs instead of four, and no power transistor or large electrolytic capacitors.
The Uno R4 Minima is undoubtedly a
big step up from its predecessors like
the Uno R3 and the Nano.
The main reason for the improvements is that the R4 Minima no longer uses an Atmel ATmega328P 8-bit
microcontroller, but is now based
on a much faster and more powerful
microcontroller: the Renesas R7FA4M1AB#CFM#AA0. This is part of Renesas’ RA4M1 series, a 32-bit micro with
a 48MHz ARM Cortex core.
As shown in the block diagram,
Fig.1, the R7FA4M1 also has much
more internal memory than the
ATmega328: 256kB of flash vs 32kB,
32kB of RAM vs just 2kB, and 8kB of
EEPROM for data storage compared
with just 1kB. So it has eight times
the flash, 16 times the RAM and eight
times the EEPROM.
But that’s just for starters. The
R7FA4M1 also includes a floating-point
24
Silicon Chip
unit (FPU) for faster mathematical calculations, a USB 2.0 full-speed module, a 14-bit ADC (analog-to-
digital
converter) compared to 10-bit in the
ATmega328 and a 12-bit DAC (digital-
to-analog converter), which the
ATmega328 lacked entirely.
It also has an RTC (real-time clock)
module, a CAN communications module, and the familiar UART, I2C and
SPI serial interfaces. The CAN port
does need an external transceiver,
though.
With a clock rate three times that of
the older ATmega328, we expect it to
be more than three times faster since
its word size is four times larger (32
bits vs 8 bits). The floating point unit
should make the gulf in performance
even larger when working with decimal floating point numbers.
There are also four on-chip op amps
(another feature the ATmega328P
lacked) and a temperature sensor, plus
a choice of six different on-chip clock
oscillators: a main clock oscillator, a
sub-clock oscillator and high, middle
and low-speed clock oscillators, plus
a 15kHz on-chip oscillator dedicated
to the independent watchdog timer
(IWDT). There’s a clock trim function
for the high, medium and low-speed
oscillators.
The R7FA4M1 has two hardware
SPI (serial peripheral interface) serial
units, two I2C interfaces and four SCI
(serial communications) interfaces.
Also, the R4 Minima can easily simulate a mouse, keyboard or other HID
Australia's electronics magazine
(human interface device) when connected to a computer via a USB cable.
The new 12-bit DAC gives the R4
Minima the ability to produce analog
signals and waveforms without using
PWM (pulse-width modulation). That
means that the R4 Minima can generate
cleaner audio signals and waveforms.
It also means that the R4’s six PWM
outputs can be used for other things
like driving LEDs and Mosfets.
Another feature of the R7FA4M1
MCU is its serial wire debugging support. It has a very small 5×2-pin DIL
header near the 3×2-pin in-circuit
serial programming (ICSP) header,
labelled “SWD”. Serial Wire Debug is
a modified version of the JTAG protocol, designed specifically for ARM
processors.
It means that, with the right hardware and software, you can monitor
and even pause the operation of the
processor core without using or affecting any of its I/O pins.
As you can see, the R7FA4M1 microcontroller is very powerful indeed.
All those feature are packed inside
an unassuming 64-pin LQFP package
measuring only 12 × 12mm, including
the leads on all four sides.
For more information you can view
the Uno R4 Minima data sheet at:
siliconchip.au/link/abq0
Other features
But wait, there’s more! (No, you
don’t get a free set of steak knives…)
Like the earlier versions, the R4
siliconchip.com.au
Minima can be powered with 5V via
the USB socket, or it can be powered
via either the concentric barrel connector or the VIN pin. In the latter cases,
it can handle a DC voltage between
6V and 24V.
That wide range is thanks to the
Renesas ISL854102FRZ-T buck converter chip (the second IC on the
module PCB, up near the concentric
power connector), which retains good
efficiency even at higher input voltages. As a result, the R4 Minima can
be powered from almost any external
DC power source of no more than 24V.
Schottky diodes are also provided for
reverse polarity and overvoltage protection.
Another nice feature of the R4 Minima is that it has a five-in-one ESD
protection diode between the pins of
the USB socket, to protect the micro
and the rest of the module from electrostatic damage.
The device used is a Nexperia PRTR5V0U2X, which includes two pairs of
ultra-low-capacitance diodes between
the USB D- (DM) and USB D+ (DP) signal lines and the USB+5V and ground
lines. There is an additional ESD protection diode between the two power
lines to ensure signal line protection,
even if no supply voltage is present.
So the Arduino Uno R4 Minima is
a really impressive step up from the
R3 and earlier Unos. It has a faster and
more powerful MCU with much more
memory and many additional features
like an inbuilt USB 2.0 interface, a realtime clock and a 12-bit DAC capable of
providing smooth audio signals, plus
the ability to run from a wide range of
power sources.
Fig.1: the block diagram for the Renesas R7FA4M1AB#CFM#AA0 32-bit
ARM Cortex microcontroller. One of the biggest improvements over the old
ATmega328P is the extra storage space (256kB vs 32kB of flash etc).
How about compatibility?
As you can see from the pinout diagram in Fig.2, the R4 Minima is basically hardware-compatible with the
earlier versions of the Arduino Uno.
So, it should be capable of interacting
with most shields designed to work
with the earlier versions, especially if
they have the same operating voltage.
However, in their product reference
manual, Arduino states that they cannot guarantee that all sketches and
libraries intended for use with earlier
versions will be fully software compatible with the R4 Minima because
of the significantly different microcontroller used.
They advise that all sketches
developed to run on the Uno R3
siliconchip.com.au
Fig.2: the pinout diagram for the Arduino Uno R4 Minima. The board layout
is designed so that it is hardware-compatible with the earlier versions of the
Arduino Uno and its shields.
Australia's electronics magazine
December 2023 25
should run on the R4 Minima, provided that they were developed using
the Arduino API. Still, changes will
be needed if your sketch uses instructions only suitable for the AVR architecture.
Similarly, they advise that not all
libraries written to suit the Uno R3
would be compatible with the R4 Minima. Apparently, some libraries have
already been ‘ported over’ as part of
their early adopters program.
Arduino has already produced
eleven tutorials demonstrating the various special features of the R4 Minima,
plus a guide to popular shields and
their compatibility with it. These are
all available on the Arduino website,
at siliconchip.au/link/abq1
The titles are:
1
2
3
4
5
6
7
8
9
10
11
Getting Started with Arduino Uno R4
Minima
Arduino Uno R4 Minima Real Time Clock
Arduino Uno R4 Minima ADC Resolution
Arduino Uno R4 Minima Digital-toAnalog Converter (DAC)
Arduino Uno R4 Minima EEPROM
Arduino Uno R4 Minima USB HID
Arduino Uno R4 Minima CAN Bus
Arduino Uno R4 Minima Shield
Compatibility
Arduino Uno R4 Minima Cheat Sheet
Arduino Uno R4 Shield Guide
Debugging the Arduino Uno R4 Minima
One was that the analog output of
the DAC appears on pin A0 of the Minima; another was that in the Arduino
programming language, the simplest
way of programming the DAC is by
using the instruction analogWrite(A0,
value); where ‘value’ can be any integer value between 0 and 255.
Why only values between 0 and
255? That’s because, although the DAC
does have a resolution of 12 bits, the
Arduino firmware gives it a default resolution of 8 bits. If you want to increase
it to the full 12 bits, this can be done
in the Setup() section of your sketch
by using this instruction:
analogWriteResolution(12);
This allows you to feed the DAC
with values between 0 and 4095, rather
than the previous 0 to 255.
Armed with this basic information,
I worked through the examples in
the Arduino tutorial on the Uno R4
Minima’s DAC. There were three
example sketches (see github.com/
arduino/ArduinoCore-renesas/
blob/main/libraries/AnalogWave/
examples/), all using a library called
analogWave. The first sketch generates a nominal sine waveform, the second plays “Frere Jacques”, while the
third generates any of the 88 notes on
a piano keyboard.
All three allow output frequency
adjustment by varying the voltage
fed to the A5 analog input pin using
a potentiometer connected between
+5V and ground. The analog output
from A0 can be either fed directly to
a small piezo sounder or the input of
a small amplifier driving a speaker; I
used a tiny low-cost amplifier module
based on an LM386.
Scope 1: the output
of the sketch
“DACEqual
TemperedScale”
which generates a
3.788kHz sinewave.
Trying it out
I ordered an Arduino Uno R4 Minima from a supplier on eBay. It cost
me US$20, roughly $31 at the current exchange rate. It arrived about
10 days later.
First, I tested its compatibility with
some sketches I had written for the
Uno R3 and found that they ran just
fine. The only thing I had to change
was to install the latest version (2.2.1;
siliconchip.au/link/abq2) of the Arduino IDE, because the version I had been
using (1.8.19) had trouble uploading
sketches to the Uno R4 Minima.
I think that was because the USB
interface of the R4 Minima is built into
the R7FA4M1 MCU itself, rather than
in a separate chip as in the R3 and earlier versions of the Uno.
I then decided to try one of the R4
Minima’s interesting new features:
the DAC. I learned a few basic facts
by reading the information on this in
the Renesas RA4M1 data sheet (pages
1149-1156; siliconchip.au/link/abq4)
and the brief information in the Arduino ‘Cheat Sheet’ on the R4 Minima
(siliconchip.au/link/abq3).
26
Silicon Chip
Scope 2: the output
of the sketch “Using_
the_R4_DAC_to_
gen_a_sawtooth.
ino” which generates
a sawtooth wave
with 63 rising steps
followed by a singlestep fall.
Scope 3: the output
of the sketch “Using_
the_R4_DAC_to_
gen_a_sinewave.ino”
which generates a
smoother sinewave
than the one shown
in Scope 1.
Australia's electronics magazine
siliconchip.com.au
All three sketches use a previously
calculated set of samples to produce a
sine waveform, called wave.sine(freq).
Although the sketches all worked,
they did generate rather rough and
noisy waveforms, with a significant
amount of accompanying noise and
harmonic content. Scope 1 shows the
output from the first sketch generating
a 3.788kHz sinewave.
When I looked around on the Uno
R4 Minima section of the Arduino
Forum, I found others expressing reservations about the performance of
sketches using the analogWave library.
There were also a few suggestions on
how to get the R4 DAC to produce
smoother and cleaner waveforms, from
contributors like “Grumpy Mike” and
“susan-parker”.
Ms Parker (who also calls herself
‘TriodeGirl’) seems to be a very experienced programmer who has produced
her own sketch, using direct register
setup and interrupts. She explained
that one of the reasons why the analogWave library produces noisy or ‘hairy’
waveforms is because it performs DAC
initialisation each time it is called.
I also found a sketch from a contributor calling themselves “daueb” that
didn’t make use of the analogWave
library at all but instead used the basic
instruction analogWrite(A0, value).
After looking at daueb’s sketch, I
decided to write a small sketch of my
own to test the R4 Minima’s DAC.
The sketch is called “sketch_for_
testing_the_R4_DAC.ino”, and all it
does is prompt you to feed in a value
between 0 and 255 via the Arduino
IDE’s Serial Monitor, after which it
feeds this value to the DAC so you can
measure the output voltage from the
A0 pin using a DMM. The sketch uses
the default DAC resolution of eight bits
but also has provision for changing to
12 bits if you want.
Fig.3 shows what I found when I
used this sketch to plot the output of
the R4 Minima’s DAC over the full
range of input values from 0 to 255. It is
basically a straight line from 0.0034V
to 4.7468V.
Encouraged by this result, I wrote
a small sketch to generate a linear
sawtooth waveform, again using
the analogWrite(A0, value) instruction suggested by daueb. It is called
“Using_the_R4_DAC_to_gen_a_sawtooth.ino”, and like the first sketch,
you can download it from siliconchip.
com.au/Shop/6/306
siliconchip.com.au
Fig.3: the output from the Arduino sketch “sketch_for_testing_the_R4_DAC.ino”,
which plots the output for the R4’s DAC over an input range of 0 to 255.
This sketch generates a sawtooth
wave consisting of 63 rising steps followed by a single-step fall; the result
is shown in Scope 2. You can vary
the number of upward steps simply
by changing the step size in the ‘for’
instruction inside the sketch’s loop():
for (x = 0; x < 255; x += 4)
A smaller value in the place of 4 will
give a smoother sawtooth (at a lower
frequency), while a larger value will
give a ‘staircase’ sawtooth at a higher
frequency.
Next, I came up with a similar small
sketch to generate a sine waveform,
called “Using_the_R4_DAC_to_gen_a_
sinewave.ino”. Scope 3 shows the
waveform that this sketch can produce
– it’s much smoother than the waveform in Scope 1, but much lower in
frequency.
As before, you can change the waveform’s smoothness and frequency simply by changing the step size in the
‘for’ instruction inside the sketch’s
loop:
for (deg = -180; deg < 180; deg += 5)
If you increase the step size from
5 degrees to, say, 10 degrees, you’ll
get a more stepped sinewave at a
Australia's electronics magazine
higher frequency. If you decrease it
to, say, 1 degree, you’ll get an even
smoother sinewave but much lower
in frequency.
So there you have a demonstration
of the basic trade-off when you are
trying to generate waveforms using a
DAC: decreasing the step value gives
greater waveform smoothness but also
lowers the frequency.
These simple sketches are only suitable for generating smooth waveforms
at low frequencies. Unfortunately,
those using the analogWave library
are not much better.
As far as I can see, the only way to
get smoother waveforms at higher frequencies from the Arduino R4 Minima’s DAC would be to use Ms Parker’s
approach, using direct register setup
and interrupts. You can find her sketch
on GitHub: github.com/TriodeGirl/
Arduino-Uno-R4-code-DAC-ADCints-Fast_Pins/
Summary
The DAC is only one of the features of the R4 Minima that makes
it so attractive. There’s the much
larger flash memory, RAM and data
EEPROM; the faster CPU with an
inbuilt floating-point unit (FPU); the
December 2023 27
inbuilt real-time clock (RTC); the
inbuilt capacitive touch sensing unit;
the inbuilt USB 2.0 full-speed comms
module; an ADC with 14-bit resolution; and the inbuilt op amps and
CAN port.
We’ve only just scratched the surface of the Uno R4 Minima in this article. If you’d like to delve further, we
suggest you get one and explore all its
capabilities yourself. It really is a big
step forward in the Arduinosphere!
Where you can get it
You can buy the Arduino Uno R4
Minima directly from the main Arduino website, but it’s also available from
several suppliers on eBay. In most
cases the cost will be around US$20,
possibly with shipping costs added.
WiFi version
One last thing: the Uno R4 Minima isn’t the only new addition to the
Arduino Uno family. It also has a sibling, the Uno R4 WiFi.
That one has all the new features of
the R4 Minima plus more: the addition of an Espressif ESP32-S3 to provide WiFi and Bluetooth comms, plus
an onboard 12×8 LED matrix and a
While we’ve reviewed the Uno R4 Minima (shown enlarged), there’s also a WiFi
version of the board, see: https://store.arduino.cc/products/uno-r4-wifi
SparkFun Qwiic I2C+power connector that can be used to plug in their
add-on boards.
As you’d expect, the Uno R4 WiFi
costs more than the R4 Minima, at
US$27.50. Still, those extra features
are pretty tempting for an increase
in cost of less than 50%, especially if
you want wireless communications
SC
and networking.
Silicon
Chip
as PDFs on USB
¯ A treasure trove of Silicon Chip magazines on a 32GB
custom-made USB.
¯ Each USB is filled with a set of issues as PDFs – fully
searchable and with a separate index – you just need a
PDF viewer.
¯ 10% off your order (not including postage cost) if
you are currently subscribed to the magazine.
¯ Receive an extra discount If you already own digital
copies of the magazine (in the block you are ordering).
The USB also comes with its own case
EACH BLOCK OF ISSUES COSTS $100 OR PAY $500 FOR ALL SIX (+POSTAGE)
NOVEMBER 1987 – DECEMBER 1994
JANUARY 1995 – DECEMBER 1999
JANUARY 2000 – DECEMBER 2004
JANUARY 2005 – DECEMBER 2009
JANUARY 2010 – DECEMBER 2014
JANUARY 2015 – DECEMBER 2019
WWW.SILICONCHIP.COM.AU/SHOP/DIGITAL_PDFS
Ordering the USB also provides you with download access for the relevant PDFs, once your order has been processed
28
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
|