Embedded Prototypes for Control Engineering

Audience may observe that I normally use general-purpose PCBs to build prototypes since the schematics are not too complicated to do so. They look unprofessional, but most could satisfy the desired functionality. Time and budget are also major factors for consideration. Nevertheless, once a design crystallized, it becomes burdensome to construct more than one prototype. This is a good point in time to consider creating a customized PCB.
Continue reading

PIC24EP QEI Basics

An incremental encoder provides a cost-effective way to capture shaft angle of a motor, especially when position accumulation for several turns is required (such as when transferring through a gear mechanism, or converting to linear position in a motion control axis). The hardware needed at the receiving end are a quadrature signal decoder, digital filter, and an up/down counter. Previous articles on this website explained how to implement them on an FPGA chip using hardware description language. That would be useful when you want to design hardware for several motion axes using minimal footprint. For a single channel application, the PIC24EP Motor Control (MC) family from Microchip, such as PIC24EP256MC202 used in this article, conveniently provides a QEI module on chip. So, in this article we discuss how to setup and use it.
Continue reading

PIC24E I2C communication with MCP4725

I2C (Inter-Integrated Circuit) is a serial communication protocol invented by Philips. The main advantage of using I2C is that it requires only 2 wires: clock and data, where several devices can be connected. In a typical arrangement, a processor acts as the bus master and devices as slaves, though multi-master setup is also possible.
Continue reading

Simultaneous Sampling of 4 ADC Channels with PIC24E

No matter how fast we advance in this digital era, the world is still analog in nature. In many industrial applications, an engineer needs to measure a continuous-time signal and store/process it digitally. For this reason, most microcontrollers have Analog-to-Digital Converter (ADC) modules as standard peripherals.
Continue reading

A Note on Output Compare (PWM) Module of PIC24E

A while ago on www.controlsystemslab.com, we present an article on DC motor open-loop speed control , using a simple voltage command from ADC to drive the H-bridge driver. The PWM output is generated from output compare module of the dsPIC30F2010. That 16-bit digital signal processor is now quite dated. The reader would want to implement the scheme on a newer microcontroller.

At the time of this writing, PIC24EP (and dsPIC33E) series from Microchip is the latest product in the 16-bit range that could run at 70 MIPS performance. For those who want to port the code to PIC24EP, unfortunately, you have to modify the ADC and PWM routines. In this article we focus on the latter.
Continue reading

Verifying PIC24EP Clock Frequency by UART Module

In our previous article Configure PIC24 to run at 70 MIPS , I suggested a way to verify whether the PIC24E run at 70 MIPS by setting a timer output and measuring its period using an oscilloscope. If you are a normal person like me who does not have a scope sitting next to the computer, this approach might be infeasible (so why I proposed it in the first place? Doh!). Anyway, there is some other way that does not need a lab instrument. How about this? Let try setting up an asynchronous communication like UART. If the baud rate on the PIC24EP does not match that on the other side, say, our PC, then they couldn’t talk. To set up the baud rate, we have to put FCY = 70M into the equation. If the clock deviates from that value just a little bit, communcation would fail. Above all, we have a chance to learn how to set up UART communcation on the PIC24EP.
Continue reading