8. 33 ms would imply a full range PWM switching period
of 256 8. 33 ms = 2.133 sec. By selecting a PWM
switching frequency, the control resolution is determined
because SSR power switching only responds to higher
order bits. Take a look at Figure 7.
Because the ATmega328P master clock operates at
16 MHz and the maximum TIMER2 divisor is 1024, the
minimum PWM sampling frequency is 30 Hz, yielding
four levels of resolution control. However, if we further
divide the ATmega328P master clock frequency by 8, then
the PWM frequency is 3.75 Hz and five-bit ( 32 level)
resolution is achieved.
Considering many practical applications, a sampling
rate of 4 Hz with five-bit resolution was an acceptable
trade-off. Implementing both TIMER2 pre-scalar 1024
divisor and master clock divisor 8 is required to reach a
PWM frequency of 16 MHz/(1024*256* 8* 2) = 3.83 Hz.
The master clock was divided in software with the
clock_prescale_set(clock_div_ 8); function which, of course,
has a similar effect on the delay(); millis() instructions.
Delay values must be divided proportionally.
The Arduino standard PID_v1 library was also edited
for the same reason and a modified PID_v1R library is
included in the zip archive at the article link.
To debug and validate this design, an Arduino Nano
and breadboard were used with two LEDs, an SSR, and a
60W incandescent light bulb (Figure 8). It was easy to see
the LEDs flash at a slow rate (PWM cycle time) and the
LED brightness change (PWM duty cycle).
The definitive test was switching a 120V resistive load
(60W light bulb). To my joy, flashing and variable intensity
was observed. This was the extent of bench testing before
This was a satisfying project because I learned a lot
about PID and made a practical PID temperature control
device. The Arduino IDE and libraries made programming
and testing a breeze. A few quick points:
• Online cost of hardware is very cheap ($20) and
can be assembled by almost anyone in just seconds.
• ATmega328P microcontroller performance provides
for both rapid sampling ( 4 Hz) and five-bit PWM SSR
switching. Along with a wide temperature range (0-
1024°C), this unit is ready for a variety of applications.
• Keypad selection of temperature profiles enables
the user to operate stand-alone at the remote process site.
• Only 30% of program memory and 60% dynamic
memory are used, leaving plenty of space for user
Some practical applications might include vegetable
canning, rice cooker, slow cooker, alcohol fermentation, or
an SMT solder oven. Someday, I’m going to turn the PID
problem around and make a device that senses meat
temperature and indicates the remaining cooking time.
The Thanksgiving turkey will be cooked perfectly every
FIGURE 8. Arduino Nano test circuit.
November 2017 35