that the frequency of a PWM signal will affect
the MOSFET’s performance, how do we
decide what is a good PWM frequency to use?
There are four considerations to keep in mind
when choosing a PWM frequency:
1) The heat dissipated in the MOSFET. As
stated in the previous paragraph, as frequency
increases, the more time the MOSFET is in a
transitional or unknown state. This transition
state occurs when MOSFETs switch from on to
off, or vice versa. Thus, the more heat the
MOSFET will dissipate.
2) The responsiveness of the motor. A motor
will respond faster and better to changes in the
PWM duty cycle when the PWM signal is operating at
higher frequencies. As you set up the PWM module in the
microcontroller, adjust the PWM frequency up and down,
and see how the slot car’s performance changes.
■ FIGURE 3. Track layout.
3) The sound generated by the motor. When a motor
operates within a certain frequency range (about 20 Hz
to 4 kHz), the motor will make a very distinctive hum or
whining sound. So, to avoid this whining of the motor, set
the PWM signal frequency at or above 4 kHz.
4) The speed at which the motor is operating. This
consideration will be more dependent upon your motor-control application. If your motor will be running at lower
speeds, you will want a higher PWM signal frequency,
thus giving you a more constant motor torque. If your
motor will be running at higher speeds, use a lower PWM
signal frequency for less constant motor torque.
Basically, when choosing a PWM signal frequency it
essentially comes down to trial and error. Pick a frequency
based upon these four considerations and try it out.
Adjust the frequency higher or lower, and see how it
affects the performance of the motor. (Refer to the Slot
Car Program on the Nuts & Volts website — www.nuts
volts.com — to see an example of how I set up the PWM
module of the PIC12F683 microcontroller.)
will need to control the speed of the motor, and where
you will need to put track sensors. Keep in mind that in an
area where you need to control the motor speed, say a
turn, you will need a track sensor at the beginning, so you
can slow the car down going into the turn, and one at the
end so you can accelerate out of the turn. The track
sensor is a very simple sensor circuit that will use an IR
LED to turn off a photo transistor mounted on the front
of the slot car (see Schematic 2 and Figures 2 and 4).
The track in Figure 3 was divided into four sections,
with Section 1 being the starting point and the first
straight-away. Section 2 is turn one, with a sensor at the
beginning and the end. Section 3 is the second straight-away, and Section 4 is turn two with a sensor at the
beginning and the end. The white arrow indicates the
direction of traffic flow, beginning at the starting line.
After marking the location of where the track sensor
will be located, drill two small holes in the track as shown
in Figure 4, so that as the slot car drives on the track, the
photo transistor will read 18 volts DC until it drives over
the track sensor. At this point, the photo transistor on the
slot car will read and send 0 volts DC, a binary zero or
low, to the microcontroller telling it to brake, slow down,
or accelerate, depending upon what section of the track
the sensor is located. Then, after passing over the track
The Car Detection Scheme
At this point, we know how we are going to drive and
control the speed of the slot car motor, but what about
the track? How do we modify the track so that the micro-controller on the slot car will know what part of the track
it is on? First, build the track into a configuration that you
are happy with. Then, draw that same track configuration
on a piece of paper and mark the areas that are straight-aways, turns, and other areas that the car needs to slow
down for. As Figure 3 shows,
you now know how many
sections you have, where you
■ FIGURE 4. How to
install the track sensors.
May 2008 49