PIC32CM Microcontroller Family, MC Series
The broad portfolio of 32-bit PIC microcontrollers comprises several product families, each distinguished by a set of distinctive features. The newest of these is the PIC32CM “MC” family, where “MC” stands for “motor control”, the primary purpose of these microcontrollers. These 32-bit components are based on the ARM Cortex- M0+ architecture. They can be clocked at up to 48MHz, have a built-in Flash memory (up to 128KB), and 16KB SRAM. Their operating voltage range spans from 2.7V to 5.5V DC, which makes them suitable for simple circuits powered by rechargeable batteries, such as a single lithium-polymer (LiPo) or lithium-ion (Li-Ion) cell. What is more, this makes them pre-immune to voltage fluctuations that occur when powering electric motors. They have also been designed to withstand electromagnetic interference (EMC).
The PIC32CM “MC” series includes a number of solutions to facilitate motor control. The first one is the built-in PDEC (Positional Decoder), which is a circuit that allows the microcontroller to obtain information about the current position of the rotor. This ensures precise and ergonomic drive control, as the supply of power to successive motor windings takes place at the optimum commutator rotation angle. This gives the designer full control of the motor operation – even at high loads, when control via the PWM signal alone might not suffice.
Motor Control using PIC32CM Microcontrollers
The drive control programme is usually based on conditional instructions. The direction and speed of motor rotation depend on the status data of the device. The microcontroller can obtain this information using simple binary signals, e.g. supplied by limit switches. However, more and more often data is collected from accelerometers, optical sensors or magnetic field sensors, etc. Communication with these circuits usually requires implementing at least one protocol (e.g. SPI or I2C) in the software. As the number of peripheral circuits increases, along with the complexity of the overall circuit, designers are often faced with limited microcontroller hardware capacity. For example, microcontroller’s timers can be employed to generate interrupts, as well as used by various libraries to support communication protocols – but at the same time they are needed to control motors. Sometimes, mere collection, processing and transmission of data imposes limitations on the maximum number of controlled devices and forces us to use additional, external multiplexers and controllers. Microcontrollers from the PIC32CM “MC” family feature a number of solutions that facilitate the design of complex control systems, while minimising the number of external components.
Motor control in these systems is implemented using dedicated, built-in timers and counters (TTC). They work independently from other peripheral circuits of the microcontroller due to which control signals are precise and not disturbed by side tasks performed by the program. PIC32 MC chips also have four built-in hardware serial communication modules (SERCOM), which can be configured for data transmission using USART, SPI, I2C, RS485 or LIN interfaces – i.e. the most popular standards employed in industrial embedded systems. The dedicated 12-bit data bus with a CRC module (which minimises communication errors) allows the exchange of data between the microcontroller’s memory and peripherals and bypass its core thanks to the Direct Memory Access (DMA) mechanism. This solution does not cause delays in programme execution.
Microcontroller Programming using MPLAB X and Harmony
Applications for PIC32 microcontrollers are developed in the MPLAB® X environment. It is an integrated solution allowing the user to fully utilise the capabilities of Microchip systems. As it is a proprietary solution, MPLAB X allows the user to use the same code on manufacturer’s various hardware platforms of the manufacturer (provided they have compatible functionalities), which enables easy migration between different families of microcontrollers at every stage of application design. User-friendly interface gives developers an overview of all information about the programmed microcontroller and operations performed by it. MPLAB® Harmony overlay includes more than 1,000 free sample programmes, as well as numerous libraries, which provide an excellent base for learning and support during project development. More details about the content and functionality of the MPLAB® X/Harmony environment will be discussed below, in the context of the PIC32MK family.
PIC32MK GPG and MCM Family Microcontrollers
In more demanding projects, where motor control is just one of many functions performed by the microcontroller, the more advanced PIC32MK chips may prove to be the right solution. They include the “GPG” and “MCM” series. These closely related products share most of their features. The differences are relatively minor, but may prove crucial in certain applications. In the case of the “MCM” series, the Flash memory has a maximum capacity of up to 1MB (512kB for “GPG”), an additional phase synchronization loop for the USB interface is also included, the number of analogue inputs has been increased to 42, and 6 (instead of 2) SPI/I2C communication modules are used. Since the characteristics of the two series are not that different, let us take a look at the entire PIC32MK family.
The PIC32MK “GPG” and “MCM” microcontrollers are based on the MIPS32 architecture and packed with an impressive set of features. The chips enable control of DC motors using PWM signals (in 9 or 12 pairs), but also work with brushless DC drives (BLDC) and even their AC variant, i.e. PMSM (sometimes called BLAC) using algorithms that do not rely on external position sensors. The chips have hardware support for floating-point arithmetic (mathematical coprocessor), offer seven 12-bit ADCs with sampling rates of 3.75 Msps multiplexed into 30 or 42 channels, and have eight channels with direct memory access (DMA). Dozens of noteworthy peripherals are on board the microcontrollers, including: a real-time clock (RTC), up to eight timers/counters (TTCs) with 32-bit resolution, three 12-bit DACs, four operational amplifiers and five comparators.
Displays and a Touch User Interface with PIC32
When working with Microchip microcontrollers, the designer is provided with a wide range of user interface options: the chips are equipped with a parallel master port (PMP) to support liquid crystal displays (LCD), as well as a built-in CVD converter, thanks to which the microcontrollers can act as a controller for a matrix, capacitive touch keyboard. The chip design includes support for up to six I2S channels, a protocol that performs lossless transmission of PCM samples to audio converters. Moreover, all input/output pins can be used to generate interrupts, which makes the PIC32MK chip a perfect control unit even for complex systems. It is worth noting that five pins can be programmed to trigger an interrupt if a certain voltage value is exceeded, which facilitates, among other things, the integration of the microcontroller with analogue sensors. Although the microcontroller is powered by a voltage range between 2.3V and 3.6V DC, the GPIO ports can handle up to 5V DC.
Certification and Libraries for Safe IoT Devices
Similarly, as in the case of the previously described series, PIC32MK chips are programmed using the MPLAB® X environment with Harmony overlay. Libraries made available by the manufacturer offer a wide range of possibilities. Depending on requirements, the user can use TCP/IP stack support, USB communication, as well as mTouch technology (for creating touch buttons, sliders, etc.). Designers of consumer devices can build an audio application based on Bluetooth standards in Android or MFi (Apple) operating systems. Among the demonstration programs provided by the manufacturer, there is also an example of how to use the wolfSSL library. It is one of the most popular solutions for securing communication for IoT devices – it offers encrypted data transmission using SSL and TLS 1.3 protocols. It will be particularly important for those designers who develop mobile devices with broadband connectivity based on PIC32MK.
Where consumer goods and safety are concerned, the Class-B Safety library should also be mentioned. It is a set of low-level procedures developed by the manufacturer, which guarantees that devices built using PIC32 microcontrollers will meet IEC 60335 and IEC 607030 safety standards. These requirements apply not only to consumer devices, but also to equipment used by professionals. IEC 60730 certification has become mandatory for every product sold in Europe. However, this will not be an obstacle for manufacturers using Microchip solutions. As the Class-B Safety library has been tested on all vendor platforms, applications built on its basis do not need to undergo additional testing, which significantly reduces time-to-market. Furthermore, Microchip offers professional support to all engineers interested in using the Class-B Safety library in their projects.
It is also worth mentioning that PIC32MK microcontrollers support the microMIPS technology, where most functions of a 32-bit processor are available from the level of 16-bit instructions, which allows for code compression, reducing its volume even by 25%.
Prototyping with PIC32CM and PIC32MK Microcontrollers
TME also offers PIC32 development kits. These are excellent platforms for every designer to test, develop and improve their devices. They allow access to all features of the microcontrollers discussed here, as well as help to plan the design of the target device.
First, let us take a look at solutions with PIC32CM chips..
Curiosity Nano board – how to start working with PIC32?
This small, palm-sized development kit offers access to most of the PIC32CM functions. At the same time, it is attractively priced and due to its integrated programmer/debugger, no additional devices are required for programming. It is certainly the product of choice for anyone new to the PIC32 and wishing to improve their knowledge of these state-of-the-art microcontrollers.
The EV10N93A board features a PIC32CM1216MC00032 chip with GPIO pins on PCB pads (for soldering gold pins or for mounting the board as a soldered-on component using edge connectors), a Micro USB socket for power supply and programming, a single button and LEDs to indicate the operating status. The kit has full support of the MPLAB® X environment.
PIC32CM Curiosity Pro (EV15N46A) kit
This is another kit equipped with the PIC32CM1216MC00048 microcontroller. It has all the features of the Nano kit, but with the EV15N46A you have additional buttons and pinouts for all microcontroller pins on several gold pin connectors (separately for GPIO, control signals, as well as C/A and C/A converters), a separate port for a programmer/debugger with an SWD interface, an external oscillator for the RTC clock, as well as a current measurement point for precise measurement and optimisation of power consumption of the microcontroller and motors that are controlled by the device.
PIC32CMMotor Control Plug-In module and MCHV-2 & MCHV-3 kits
The module marked EV94F66A, i.e. PIC32CM Motor Control Plug-In, features the PIC32CM1216MC0048 microcontroller along with the basic components required for its operation. There is also an ISP programmer port on the module and a 100-pin connector required to install the module on a prototyping board or in a development kit. Dedicated development kits include the MCHV-2 and MCHV-3 products, which are tools for developing projects for controlling high-current motors used for example in household appliances.
The PIM module, together with the development kit, speeds up the design process, as all power and drive control components are present in the device. Designers can therefore focus on engineering the controller functionality and optimising the programme code, having a fully functional prototype at their disposal. The MCHV kits are powered by 85V to 260V AC. The kit’s power supply can deliver 6.5A and handle three-phase loads of up to 2kVA (this may be an inverter washing machine motor, but also a complex device from the industrial automation segment). The development boards are designed so that the components placed on them can take over the functions of some elements located inside the microcontroller – for example operational amplifiers which are not suitable for high loads.
Module with the PIC32MK microcontroller
One of the advantages of the 100-pin connector used on the MCHV boards is its versatility. Both PIC32MC modules and those equipped with the PIC32MK microcontroller can be placed in the socket. However, thanks to their wide functionality, products from this group can also serve as the heart of an independent, integrated device, which not only controls the operation of motors, but also features a user interface, a network communication module and many other functionalities. The development of such a project is complex, but using an off-the-shelf module with a PIC32MK1024MCM microcontroller accelerates the process. While the MCHV boards facilitate work on a project in its early stages, the MA320211 (PIC32MK MCM Motor Control Plug-In Module) can be reused during testing of the device/controller prototype, for development works on other elements of the project (Human Machine Interface communication, data transmission, etc.).