© 2013 - Philip Tallents
Micro Control: What Teachers Should Know
Why do we sometimes teach things at school that are irrelevant in the real world – particularly in industry? Microcontrollers are not toys, but we seem to be content with flashy lights and remote control buggies. Together we can define a way to get more from this technology in the classroom.Because micro-control is highly technical, many of us have tried using hobby style robotics with our students. We find it easier to learn a well presented software with flowchart graphics than a supposedly scary language such as Assembly or ‘C’. The stress of learning these new technologies can be time consuming. The hobbyist approach achieves a good result; but does this restrict our students and give them false hopes?
Would it be pleasing to see past students become Industrial Designers, Electrical, or Mechatronic Engineers? We need to look at the microcontroller industry. This will help us choose the best content for our classroom activities and control system projects.
Here we will try to clarify the key factors of industrial micro-control.
Use the following article to assist your understanding of microcontrollers. At the end we canreflect on, improve, and select an informed curriculum in micro-control. Be warned, you may like what you see, as much as we do at PicoKit.
1. What is a Microcontroller?
2. How does a Microcontroller work? 3. Which Microcontrollers are used?
4. Where do real world Microcontrollers fit in an educational curriculum?
© 2013 - Philip Tallents
What is a Microcontroller?
There are many terms used for the word ‘microcontroller’ such as Microchip, PIC, PICMicro, AVR, IC (Integrated Circuit), embedded device, system on a chip, and MCU (Micro Control Unit). We will use the term MCU. For a simple expression, one might say an MCU is a ‘Computer on a Chip’. Although this is useful, we might overstate the obvious by pointing out that an MCU has no display monitor, keyboard, mouse, or hard-drive. However, an MCU does generally have at least the following:
1. Flash memory to store firmware instructions 2. Memory file registers allocated to data
3. The ability to process control, arithmetic, and logic
4. Electrical leads (pins/legs) to interface with external devices 5. Hardware peripherals to automate special features (e.g. a Timer) 6. Clock generation to govern the device
7. A program counter to establish the active instruction
8. Programmable resets such as a Watchdog Timer and a Sleep condition 9. Numerous data bus ways to link it all together as one electrical system
Figure 1: CORE Block Diagram of the Microchip Technology PIC12F509 PIC®
MCU
Figure 2: Hardware Peripheral Block Diagram of the PIC12F1501 MCU
2
.4
.5
.7
.8
.9
.© 2013 - Philip Tallents
How does a Microcontroller work?
Figures 1 & 2 show the different parts of the MCU system. Moreover, figure-2 presents a clear picture of the Hardware Peripherals on the device. These Peripherals often do all the hard work in an MCU. Because you set them up, leave them to do their job, and then they interrupt to say they are finished. They might also trigger another peripheral to go and do something else. The peripherals are so important, that there are many, and some are very specialized.
ADC (Analog to Digital Converter)
Analog Inputs - e.g. Variable Resistors, Infrared sensors, Light Dependent Resistor, Voltage Probe
DAC (Digital to Analog Converter)
Analog Output & Voltage Reference - e.g. Sine Wave Generation
PWM (Pulse Width Modulation)
Duty Cycle Output - e.g. Motor speed, Dimming & Mixing LEDs, Buzzers
Comparator
Analog Threshold Trigger - e.g. to detect a charged capacitor, or AC Zero-crossing
Timer (as an Output)
Sets time critical events - e.g. runs the PWM & Interrupts, Servo Control
Timer (as an Input)
Counts input events - e.g. to count trigger inputs, Digital Colour Sensor
CLC (Configurable Logic Cell)
Combine Logic Gates - e.g. Rotary Encoder, Motor Position Sensor, Manchester Decoder
NCO (Numerically Controlled Output)
Duty Cycle/Pulsed - e.g. Precise Frequency Control, Audio reproduction, & Decoding Signals
© 2013 - Philip Tallents There are many other MCU devices and peripherals to choose from, such as those listed below.
Hardware Interrupt Capacitive Touch
FVR (Fixed Voltage Reference) Ethernet, USB, CAN, UART SPI, I2C, LIN, Parallel, & DMA PPS (Peripheral Pin Select)
WPU (Weak Pull-Up Resistors) RTCC (Real-time Clock & Calendar) OPAMP (Operational Amplifier) FSR (File Select Register – Pointer) LCD Driver, IrDA, EMA
CWG (Complimentary Waveform Generator)
Even though many peripherals exist, one device cannot contain them all. In industry, they still use specialized components to interface with the MCU. For example, they might use a more refined ADC with an external Real Time Clock and Calendar. With additional components, the system is more functional and the MCU controls it all.
Which Microcontrollers are used?
In industry, you need to choose the right MCU for the job. There are many companies to select from, such as Renesas Electronics, Freescale Semiconductor, Atmel, and Microchip Technology. Moreover, to save money, you should choose an MCU to suit your needs with the least features.
Industry Example: A client proposes we make 1 million pieces of a product. We need to make the product very small and so we choose to use an MCU. We do the calculations, and every cent will cost an extra $10,000. Hence, we decide to use a simple PIC® MCU from Microchip Technology. This MCU has six pins, is three millimeters big, and cost only twenty-seven cents. The peripherals are very limited on this MCU, but we can write the firmware to do everything we need.
This actually happened to us at PicoKit. We chose Microchip Technology because we knew they have the cheapest MCU products available. Despite their range of 15,000 MCU products, the choice was quite easy.
One key difference between MCU devices is their ability to crunch numbers. To do this, they come in three flavours: 8-bit, 16-bit, or 32-bit. The 8-bit MCU has low to mid-range functionality; primarily used with cheap products and toys. The 16-bit MCU can do heavy calculations; often used with graphical displays, industrial motors, and sound processing. The 32-bit MCU is the most powerful; used mainly for cars, mobile phones, and tablet computers. However, the 32-bit MCU is (usually) the most expensive and the hardest to program.
© 2013 - Philip Tallents
Where do real world Microcontrollers fit in an educational
curriculum?
The MCU industry is huge, and we can make our lessons just as diverse. Think of the products & services we can use - toys, movies, machines, traffic signs, phones, cars, robots, and more. An industry focus can ensure we have meaningful and creative real world activities. Our students will aspire to greatness. An MCU industry theme could be one of these:
MECC (Mechatronics & Embedded Control Curriculum) Units
1. Animatronic Mechanisms & Movie Robots
2. Robotic Aviation, GPS & Autonomous Flight (with Wireless Control) 3. High Powered LEDs, Colour Mixing and Stage Lighting
4. Roller Coasters, G-Force & Theme Park Ride Mechanisms 5. The Google Car & Line Following Navigation
6. Traffic Management, Boom Gates & Digital Speed Signs 7. Industry Automation & Robotic Machinery
8. Hexapods, Quadrupeds & Rescue Robots
9. Micro-Mouse Competitions, Shortest Path Calculations & Logic 10. Sound Waves & Radio Frequency Communications
11. Robotic Toys, Mechanisms & Embedded Control
12. Amplifiers, Filters, and Digital Sounds (Recording & Reproduction)
13. Security Control Systems, Proximity User Access & Biometric Identification 14. Electronic Components & MCU Block Circuit Design
15. Touch Panel User Interfaces & Industry Control 16. Humanoids, Powered Exoskeletons & Military Robots © 2012 – Not to be used without express permission by Philip Tallents
These might sound exciting, but having a theme is not enough. As teachers, we need to work together, to share our insights, and develop resources. Moreover, you might already have MCU industry contacts that could benefit from an educational partnership. Think of the excursions, the AV media, and technical resources that might be at hand. We could have a blog site dedicated to this sort of thing. Ultimately, any classroom can be the source of inspiration for future Microelectronic Engineers and Product Designers. We just need to engage the students with the right subject matter and in the right way. MCU technology is here to stay. It is time we started doing it justice with a good curriculum.
© 2013 - Philip Tallents
What is the best way to teach an Industrial Microcontroller?
Teaching an MCU technology means that we need to use an industry proven system. An MCU is fully accessible using the native interface as in industry. Contrary to popular belief, the façade interface used with hobbyist devices is not a stepping-stone to the real thing.
For the MCU, Assembly is the fully functional and well-documented language. It is a valid industrial language and allows full control over the MCU. It provides a tangible experience as each instruction executes directly on the MCU – one at a time. It helps us understand how the MCU works. Moreover, Assembly is the backbone of ‘C’ which is the other language used in the MCU industry.
The C language is mainly for the experienced MCU user, because C radiates Assembly. It is fast and convenient, but it still converts back to Assembly. It requires an understanding of the MCU, best learnt with the documentation that is in Assembly. If your C code does not work as expected, chances are, you need to look at the dis-Assembly to work it out. Assembly underpins the learning of C for an MCU. The free industry software MPLAB-X® by Microchip Technology does both Assembly and C. Therefore, once you learn Assembly it is easy to step into C, not the other way around.
MPLAB-X® Screen shot
The industrial method of MCU programming is the best way in school. Manufactures and ‘3rd Party
Developers’ have Development Tools and Evaluation Kits to teach the MCU. These instruct the user by showing a sample circuit and firmware program. The user can then tinker with the code to see what changes as a result. These circuits often do many things, and the firmware examples demonstrate this. Once you are familiar with the circuit, you can devise your own tasks to control it.
© 2013 - Philip Tallents This gives you a few options to try:
1. The Development Tools are good Classroom Models but they usually cost more than $50 2. Reusable Breadboards allow you to proto-type designs, but they do not allow the students to
take the project home.
3. Moving the prototype to a Custom Circuit board lets the student learn about designing and making a Printed Circuit Board (PCB) but is a demand on time (and the teacher)
The best blend of these options is cheap, ready packaged MCU Soldering Kits. The good ones: Use an industry MCU and an industry language
Utilize a broad range of MCU features
Target different skill levels in programming, and in soldering
These are all good options for schools. Students can interact with the MCU technology in different ways. From Bloom, we know students learn best when they have opportunities to Remember, Understand, Apply, Analyze, Evaluate, and Create. With Evaluation Kits and Soldering Kits, you can explore the circuit design, and the firmware, to see how professionals do it. Then when you know the system, you can get a bit more creative with Control Boards and Custom Circuits.
In general, the software and the hardware must work well together to highlight both the circuit and the system. If you want to use the same software for every kit, and circuit, then choose wisely. They do not always work well together. It may not be easy to find one software package that excels in each case. At PicoKit, we like MPLAB-X® since we already use it with our kits and custom software.
Conclusion
Learning an Industrial MCU in school is a positive step towards the future. It will give your students the lead at a career in Industrial Design, Electrical Engineering, and Mechatronics. In every MCU industry, there is a world of opportunity that can enhance your classroom. We can work together; make industry connections; create curriculum resources; deliver practical projects; and use industry-aimed software. Dabbling in industrial MCU technologies is now achievable for anyone. The potential to become an embedded designer or robotic specialist is here.