Mechatronics C C
SBy Fred Eady
I practice what I preach. When I’m not pounding out words
and hardware designs for SERVO, you can find me hard at work
writing code and punching together real world mechatronic
devices. This month, we’ll take a look at the soft side of
mechatronic construction and write some basic machine
control component code using the CCS C compiler.
The Art of Mechatronics
The word mechatronics describes the melding of
mechanical and electronic disciplines to arrive at a suitable
solution to a given problem or task. Mechatronics can also
be defined as the methodology used to replace mechanical
devices with like-function electrical devices. For instance, a
mechatronic equivalent of a purely mechanical relay is a
solid-state relay, and simple mechanical SPST switches can be
mimicked by low-on-resistance MOSFETs or simple transistors.
As a SERVO reader, you likely already have your
Mechatronics Degree in Robotic Arts. Once again, in this
month’s discussion I’m going to orbit on the outer limits of
what most people recognize as a robot. The electronic
intelligence and mechanical hardware we’ll be talking about
can indeed be assembled in such a way as to help create
a classic robotic device.
However, our machine control hardware and firmware
examples won’t end up as a walking, talking, or thinking
piece of iron. Instead, our C code seed routines will be
crafted to enable them to grow into functions that
spin motor shafts, drive solenoid coils, and read
position sensors.
Mechatronic Interfacing 101
The use of the CCS C compiler as the firmware
generator tells us immediately that we will be working with
PIC microcontrollers. PICs are hearty microcontrollers that
come standard with I/O pins that can source or sink up
to 25 mA per pin. Although the 25 mA per pin figure
sounds adequate for most any drive requirement, the PIC
mechatronic circuit designer is usually limited to a maximum
aggregate PIC I/O current source/sink limit of around 200
mA. Assuming a five volt power source and a 470Ω current
limiting resistor, that’s equivalent to driving about 20 LEDs
directly from a single PIC microcontroller’s I/O pins.
Obviously, not every load we will be required to drive
with a PIC I/O pin will fall within the 25 mA current
consumption window. In addition, we are sure to encounter
devices that need to be driven with voltages that exceed
the PIC’s I/O pin maximum voltage value. For instance,
most off-the-shelf devices intended for CNC applications use
24 volt logic. If we are to be able to employ the unique
services of a device with 24 volt logic, we must be able to
translate the device’s 24 volt logic level to the PIC’s 3. 3 volt
or 5.0 volt logic level.
SERVO 10.2009 37