Mastering motor management: synchronization, timing, and software program

[ad_1]

On this subsequent installment of our motor management collection, we look at synchronization, timing, RTOS, and motor management software program structure in motor management design.

Synchronization and Timing

The alpha and omega of each real-time software are acceptable timing, synchronization, and deterministic system response. Particular consideration should be given to those points when designing software program for motor management. In essence, the method sounds fairly simple:    The system reads sensor values, Processes the management algorithm, displays system security and manages the output stage by adjusting the obligation cycle of the three essential PWM outputs.

Minor timing errors can result in vital system response errors, unstable operation, and poor efficiency. To make sure the whole lot capabilities as supposed, it’s essential to keep up synchronization and make sure the system’s determinism.  Right here, I might emphasize that we’re coping with a ‘onerous real-time system’ the place the completion of duties by their strict deadlines is completely crucial.

Motor controller software program may be carried out as a bare-metal answer with out an working system, utilizing an acceptable RTOS (Actual-Time Working System), or as a multicore hybrid answer the place some CPU cores function in bare-metal mode, whereas different cores use an working system. Naked-metal options are all the time based mostly on an Interrupt-Pushed Design, the place interrupts course of time-critical duties, guaranteeing that the whole lot happens at exact intervals.

No matter whether or not it’s a bare-metal, RTOS, or hybrid answer, it’s important to carry out Timing Evaluation, Process Prioritization, and Security Evaluation to make sure environment friendly and dependable system efficiency.

Timing Evaluation ensures that each one duties meet their deadlines. This contains contemplating worst-case execution instances for every job. A few of the essential crucial duties in motor management are Sensor Information Acquisition, Management Algorithm Execution with PWM Sign Era, Fault Detection and Dealing with, Emergency Cease and Security Features, Actual-Time Communication with different system parts and Synchronization with Exterior Programs.

Part-Locked Loop

Part-Locked Loops (PLLs), whether or not built-in into MCU/DSP {hardware} or carried out as an IP core in FPGAs, are important for synchronizing crucial occasions, as beforehand highlighted. The first operate of a PLL is to synchronize the inner clock of the MCU/DSP/FPGA with an exterior clock supply or sign. That is important for sustaining timing accuracy in real-time purposes. PLLs assist in lowering clock jitter, which is important for exact timing and particularly vital when controlling the velocity and place of motors. PLLs assure exact timing alignment between the sampling of suggestions indicators, reminiscent of rotor place and present measurements, and the execution of management algorithms, guaranteeing optimum synchronization and accuracy. In programs with a number of cores, PLLs can be utilized to synchronize the operation of those cores.

Synchronizing Pulse Width Modulation (PWM) with present measurements and Analog-to-Digital Conversion (ADC) by means of a Part-Locked Loop (PLL) is essential in motor management purposes for guaranteeing exact and environment friendly system efficiency.  Synchronizing clock, the PLL ensures that each one system parts, together with the PWM generator, ADC, and different processing parts, function on a synchronized clock. The PWM indicators, which management the ability delivered to the motor, are generated based mostly on this synchronized clock. The timing of those indicators immediately impacts motor efficiency.  Present sensors measure the present flowing to the motor. The timing of those measurements is crucial, particularly in programs like Area-Oriented Management (FOC), the place present suggestions is used to regulate motor torque and velocity. The present sensors’ analog indicators are transformed to digital values utilizing an ADC. The PLL helps in synchronizing the ADC sampling with the PWM cycle. This synchronization ensures that the ADC samples the present on the optimum time relative to the PWM indicators, usually at some extent the place the PWM is neither absolutely on nor absolutely off to get an correct illustration of the present. The digitized present measurements are then fed into the management algorithm. The PLL ensures that these measurements are taken at constant intervals relative to the PWM indicators, enabling the management algorithm to exactly modify the PWM obligation cycle in response to modifications in state variables, guaranteeing optimum motor efficiency. By synchronizing the ADC sampling with the PWM, the consequences of switching noise and distortion are minimized.  That is notably vital in high-power motor management purposes the place the PWM indicators can induce vital electrical noise.

Present and place measurements

Precisely measuring and synchronizing currents with PWM pulses is important. Strategies like common sampling, present oversampling, and averaging are used to enhance accuracy.

Common sampling happens on the identical frequency because the PWM. The problem right here is to find out the suitable sampling time. This includes setting a delay between the beginning of the PWM cycle and the Analog-to-Digital Converter (ADC) sampling.

Present Oversampling includes sampling at a frequency greater than that of the PWM, typically 8-32 instances greater and averaging the measurements. The ADC Interrupt Service Routine (ISR) frequency may be a lot greater than the PWM frequency, which permits for detailed knowledge assortment.

Oversampling is restricted by the bandwidth of the present sensor.  For instance, most of Corridor-effect sensors usually usen in motor management have a bandwidth between 50 kHz and 160 kHz. Correct timing and synchronization are key to coping with high-frequency oscillations that may have an effect on part currents.

click on for full measurement picture

Determine 1: Synchronized PWM and Present Measurements

Determine 1 reveals timing in a single processing cycle. The Analog-to-Digital Converter (ADC) may be configured to pattern at excessive frequencies. This requires organising the ADC’s clock and adjusting its sampling price. As soon as sampling is full, the Microcontroller Unit (MCU) or Digital Sign Processor (DSP) processes these samples to calculate their common. This calculation is usually carried out after accumulating a particular variety of samples. The primary processing Interrupt Service Routine (ISR) should be configured to set off on the level the place the typical calculation is accomplished. Moreover, the Pulse Width Modulation (PWM) module must be arrange in a method that ensures synchronization between the ADC sampling, ISR, and PWM timing. Trendy MCUs and DSPs are adept at dealing with these duties concurrently resulting from their substantial processing energy, real-time operational capabilities, and varied peripherals designed for managing ADC, PWM, and ISR duties.

It’s essential that the sampling of place sensor knowledge is synchronized with the primary processing Interrupt Service Routine (ISR). It’s essential to account for any delays attributable to knowledge transmission, and these may be extrapolated to keep up timing accuracy. When making use of any filters, it’s vital to contemplate the impression of part delay. Within the case of utilizing a resolver, the processing of resolver knowledge should be synchronous and it’s important to pick out some extent the place the amplitude of the sine and cosine indicators will not be minimal to make sure correct readings. Moreover, oversampling the resolver sign and making use of a bandpass filter with a cutoff frequency matching the PWM frequency may be useful. This method helps in filtering out undesirable frequencies whereas preserving the integrity of the sign.

In high-speed programs, it’s crucial to extrapolate the place to make sure the accuracy of rotor place to have appropriate alignment of the stator magnetic subject with respect to the rotor subject. Correct angle measurement ensures that the motor is provided with the correct quantity of energy at any given time, lowering vitality losses, torque ripple, vibrations and warmth era.

This dialogue primarily focuses on Area Oriented Management (FOC) purposes that make the most of direct rotor place measurements. It doesn’t delve into sensorless FOC purposes, by which the rotor place will not be measured immediately however relatively estimated by means of oblique strategies.

Security Features

Some frequent security capabilities typically present in motor management purposes are:

Security Torque Off (STO): This operate instantly removes energy from the motor drive, inflicting the motor to cease producing torque. It’s an important characteristic for emergency conditions when stopping the motor as rapidly as doable is important to forestall hurt.

Protected Course (SDI): Prevents the motor from working in an unintended path.

Protected Working Cease (SOS): This operate maintains the motor in a stopped state with out eradicating energy.

Protected Velocity Vary (SSR) or Protected Restricted Velocity (SLS): Ensures the motor operates inside a protected velocity vary or beneath a protected most velocity.

Overcurrent Safety: This operate protects the motor and electronics from injury resulting from extreme present, which may be attributable to faults like brief circuits or overloads.

Overvoltage and Undervoltage Safety: These capabilities defend towards voltage circumstances which are too excessive or too low, which might injury the motor or the management electronics.

Thermal Safety: Displays the temperature of the motor and the drive. If the temperature exceeds protected limits, the system can shut down to forestall overheating.

Velocity Monitoring and Limiting: Ensures that the motor doesn’t exceed predefined velocity limits, which is essential for purposes the place exceeding a sure velocity may be harmful.

Emergency Cease: A bodily button or change that, when activated, instantly brings the motor to a cease. It is a commonplace characteristic in industrial environments.

Protected Brake Management: For motors geared up with brakes, this operate safely engages the brake to cease the motor, notably in vertical purposes the place gravity may trigger motion.  Previous to activating the Security Brake operate, the system first endeavors to halt the motor utilizing electrical braking, if possible, a course of by which the vitality movement is inverted to decelerate the motor.

Security capabilities may be carried out in {hardware} (HW), software program (SW), or a mixture of each, relying on the precise necessities and constraints of the applying. Security capabilities reminiscent of Overvoltage and Undervoltage Safety, Overcurrent Safety, Thermal Safety, and Emergency Cease are usually carried out in {hardware} to make sure strong, quick and dependable system safety.

Velocity Monitoring and Limiting, Fault Detection Algorithms and Protected Working Cease (SOS) are carried out in Software program.

Features like Security Torque Off (STO), Protected Course (SDI), Protected Velocity Vary (SSR)/Protected Restricted Velocity (SLS), and Security Brake Management are sometimes carried out by means of a mixture of {hardware} and software program. This hybrid method usually includes software program instructions for initiation and management, whereas counting on {hardware} parts for efficient enforcement and execution.

The subject of Security Design and practical security, together with requirements like SIL3, in motor management is a specialised topic and isn’t coated on this article.

Varied producers within the realm of embedded programs and motor management provide complete design packages and instruments geared toward facilitating and accelerating the design and certification course of in crucial sectors like industrial, transportation, vitality, and medical. These packages usually embody pre-certified software program libraries, detailed security manuals, and {hardware} modules designed to adjust to stringent security requirements like IEC 61508, ISO 13849, and comparable. Moreover, they typically present intensive documentation and assist for reaching certifications like SIL (Security Integrity Degree) scores, that are essential in high-reliability and safety-critical purposes. This help not solely streamlines the event course of but in addition considerably reduces the effort and time required for compliance and certification in these extremely regulated industries.

Actual-Time Working System (RTOS)

Selecting the best RTOS for motor management purposes is crucial to making sure excessive efficiency, reliability, and security. The primary issues embody the real-time efficiency of the RTOS, its useful resource effectivity, encompassing reminiscence footprint and CPU utilization, and priority-based preemptive scheduling. Environment friendly and quick interrupt dealing with, together with the reliability and robustness of the system, are additionally key components. Vendor assist and documentation, compatibility with {hardware}, and the supply of improvement instruments (like IDEs, debuggers, and profilers) and the ecosystem (together with libraries and code examples) play vital roles. Lastly, the licensing phrases and price of the RTOS must be taken under consideration.

Contemplating the varied components and particular necessities of motor management purposes, FreeRTOS, a extensively acclaimed open-source real-time working system recognized for its effectivity and flexibility, emerges as an excellent possibility. This selection is especially useful in eventualities the place points reminiscent of cost-effectiveness, operational effectivity, system flexibility, reliability and robustness, ease of use, intensive {hardware} assist, and useful resource effectivity are essential issues.

Software Structure

click on for full measurement picture

Determine 2: Motor Management System Structure Overview

It will be important that structure for a motor management software contains a number of layers and modules:

{Hardware} Abstraction Layer (HAL): Gives a standardized interface for accessing {hardware} peripherals, together with ADCs, PWM controllers, and communication interfaces, facilitating portability and scalability.  It additionally incorporates Board Assist Packages (BSP) and drivers for varied {hardware} peripherals, enabling seamless hardware-software integration.

Core Runtime Layer: This layer encompasses the Actual-Time Working System (RTOS) for environment friendly job scheduling and system useful resource administration. It additionally contains specialised Reminiscence Administration, that includes a Actual-Time Heap Allocator designed for optimized reminiscence allocation in time-critical purposes. Moreover, the layer integrates strong Inter-core and Inter-process Communication (IPC) mechanisms, facilitating seamless knowledge change and synchronization between completely different cores and processes throughout the system. This layer serves because the spine for core operational functionalities, guaranteeing clean and environment friendly runtime efficiency.

Middleware Layer: This layer integrates a number of essential functionalities:

Communication Interface: Manages interactions with exterior programs or units utilizing varied communication protocols.
Tracing and Information Recording: Focuses on tracing and recording particular indicators and occasions, able to real-time knowledge output by means of channels like DAC, IOs, Ethernet, UART, USB, and so on.
Software program Add: Oversees the importing of latest software program variations or updates, guaranteeing seamless integration and system continuity.
Configuration Administration: Handles system configuration settings for personalisation and operational changes.
Diagnostic & Monitoring: Gives instruments for system diagnostics and steady monitoring, important for sustaining system well being and efficiency.
Constructed-In Assessments (BIT): Consists of self-test functionalities to verify the standing and performance of each {hardware} and software program parts.

Motor Management Software Layer: Located on the apex of all layers is the Motor Management Software, a crucial part that executes application-specific workflows. This layer encapsulates:

Management and Sign Processing Algorithms: This contains core management algorithms reminiscent of PID management and Area Oriented Management (FOC), together with sign processing algorithms geared toward optimizing motor efficiency.
Security Logic: Devoted to the security points of the system, this part implements obligatory protocols for emergency conditions and routine security checks, guaranteeing the system operates inside protected parameters.
Software-Particular Workflows: The layer additionally integrates extra, distinctive workflows tailor-made to the precise necessities of the motor management software, guaranteeing complete performance and efficiency.

Software Workflow

Software workflow usually includes a number of key steps:

First Stage Boot Loader (FSBL): This important part is liable for the preliminary levels of the booting course of, together with low-level {hardware} initialization and loading the primary software program parts. An important a part of its function is to load and begin the consumer software. The FSBL operates individually from the applying layer and is often supplied by microcontroller (MCU) or digital sign processor (DSP) producers inside their Software program Improvement Equipment (SDK). Customizing the Board Assist Bundle (BSP) is usually obligatory — for example, including further reminiscence checks or diagnostic capabilities — to make sure the FSBL meets particular system necessities and enhances general reliability.

Platform Setup: Initialization of {Hardware} Elements: This contains organising ADCs (Analog-to-Digital Converters), System Interrupts, PWM (Pulse Width Modulation) modules, communication interfaces (like SPI, I2C, UART), watchdog Timers, and another obligatory {hardware} peripherals.  Establishing the interrupt dealing with mechanisms for responding to occasions like timer overflows, enter modifications, or communication occasions. Configuring the system clock, energy modes, and guaranteeing environment friendly energy administration for the controller and motor.

Software Configuration: This step encompasses the crucial job of defining operational parameters, which is usually achieved by studying configuration recordsdata. These recordsdata specify important particulars reminiscent of motor traits, management parameters, and operational limits. Moreover, configuration settings may be adjusted by means of varied means, together with digital inputs, dip switches, or dynamically by way of a communication interface from exterior PCs or grasp units. This multifaceted method ensures versatile and adaptable configuration administration, catering to a variety of software necessities.

This part additionally contains:

Defining Duties: Creating duties just like the Predominant Management Process, Communication Process, Well being Monitoring Process, and others, that are important for the applying’s performance.
Setting Priorities: Assigning priorities to those duties based mostly on their significance and function within the software. That is essential for guaranteeing that crucial duties (just like the Predominant Management Process) get the required CPU time over much less crucial duties.
Configuring Process Properties: This may embody setting stack sizes, specifying job parameters, and configuring any task-specific properties.
Establishing Inter-Process Communication: Establishing mechanisms for duties to speak with one another, reminiscent of queues, semaphores, or shared knowledge constructions.

Sensor Calibration: In purposes the place sensors are integral, their calibration is essential for guaranteeing accuracy in readings. Particularly, Corridor Impact sensors, that are generally used, exhibit preliminary offsets that should be accounted for. Throughout the calibration part, these preliminary offsets are recognized and subsequently subtracted from present measurements to appropriate the sensor output. This step is important to ensure the precision of sensor knowledge.

Communication and Monitoring: Information Communication: Dealing with communication with exterior units or programs for command and management, diagnostics, or distant monitoring.

Managing Human-Machine Interface (HMI) (if relevant)

Within the context of motor management purposes, HMI can symbolize easy bodily controls and indicators (reminiscent of buttons, LEDs, or shows) or remote-control interfaces.

Predominant Interrupt Processing: This a part of the workflow contains:

Sensor Information Acquisition: Studying and processing knowledge from sensors in real-time, obligatory for suggestions within the management loop.
Actual-time Management Loop Execution: That is the place the first management algorithms (like PID management or Area Oriented Management) are executed, typically in response to timer interrupts for constant timing.
Actuator Command Era: Primarily based on the management algorithms’ output, producing instructions for actuators like motor drivers. It often includes setting particular digital outputs and PWM sign era.
Security and Emergency Dealing with: To make sure instant response to security and emergency occasions, reminiscent of emergency stops, these must be processed sequentially and with excessive precedence on this devoted part. This method not solely minimizes delays in dealing with crucial occasions but in addition enhances the system’s general security and reliability. Moreover, this part encompasses the detection of and response to varied sorts of faults, together with overcurrent, overvoltage, and {hardware} failures. By prioritizing these duties, the system is best geared up to promptly deal with and mitigate potential dangers, thereby guaranteeing a safer operational surroundings.

The important thing precept is to keep up a concise Interrupt Service Routine (ISR) primarily for notifying a Predominant Management Process when additional processing is required. As an alternative of executing your entire management logic throughout the ISR, its main function on this context is to inform a higher-priority job in regards to the incidence of an occasion. For this goal, FreeRTOS gives varied notification strategies, reminiscent of binary semaphores, job notifications, or queues. The Predominant Management Process, an RTOS job, is liable for the primary management algorithm. As soon as it’s notified by the ISR, this job prompts (or unblocks) and carries out all the required steps beforehand described. It’s essential that the Predominant Management Process is assigned an acceptable precedence to make sure the management algorithm is processed promptly following the ISR.

The working of the primary job shall be ensured utilizing a watchdog timer, the place the duty is designed to periodically reset the watchdog timer, demonstrating its correct operation and stopping the timer from expiring and triggering a system reset or error routine.

System Well being Monitoring: Constantly monitoring the system for faults like overheating, or different anomalies and taking acceptable actions if any points are detected.

Logging and Information Recording: Recording vital occasions, errors, and system efficiency metrics for future evaluation or troubleshooting.

click on for full measurement picture

Determine 3: Information Journey: From Motor Controller Recording to PC Evaluation” alt=”undefined” />

Sleek Shutdown: Guaranteeing the motor and controller are shut down safely when the applying is stopped.

If the applying operates on a multicore MCU/DSP/FPGA, an acceptable inter-core communication mechanism should be ensured. This may be achieved utilizing on-chip shared RAM and software program interrupts, although the strategy could differ relying on the platform. Different potentialities embody message passing interfaces, direct reminiscence entry (DMA) channels, or utilizing devoted {hardware} communication blocks particular to the structure.

A typical method includes dedicating one core to deal with communication duties and one other core for the Predominant Management Loop. It’s typical to make use of an RTOS on each cores for environment friendly job administration, however typically, the Predominant Management Core is operated in a bare-metal surroundings for streamlined, low-level management. Varied producers, together with Texas Devices with its Management Regulation Accelerator (CLA), ARM’s Cortex-M DSP extensions, STMicroelectronics’ ART Accelerator, Microchip’s dsPIC, NXP’s motor management co-processors, and Infineon’s XMC Math Co-Processor, provide specialised processing items to reinforce efficiency in particular embedded system purposes. Such extensions improve the general compute bandwidth and frees up the CPU for different duties reminiscent of communications, monitoring and diagnostics.

Additional exploration of motor controller software program implementation, reminiscence administration, and trendy C++ shall be featured in upcoming articles.

Boris Radonic is a Analysis and Improvement Engineer with greater than 30 years of expertise in Digital Engineering, Management Programs, and Software program Engineering, specializing in real-time purposes. He holds an engineering diploma from the College of Zagreb and a Grasp’s diploma from the College of Utilized Sciences and Arts Northwestern Switzerland (FHNW). His open-source contributions are showcased on borisRadonic.

Associated Contents:

Proceed Studying

[ad_2]

Supply hyperlink

Methods to Write a Video Script [Template + Video]

DOJ says Apple’s CarPlay is so good it is anticompetitive — possibly they need to simply unplug it