Skip to content

Latest commit

 

History

History
49 lines (28 loc) · 3.67 KB

Readme.md

File metadata and controls

49 lines (28 loc) · 3.67 KB

Control system forming PWM

The control system generates control impulses for invertor.

Description

This repository contains a programm wrote on C packed in Keil uVision 5 project. The program code works on the basis of STM32 «F767ZI» debug board.

Development

In the inverter under consideration, the control signals of the converter keys are formed by comparing two analog signals. These signals are fed to different inputs of the comparators, and in the case when the signal at the non-inverting input of the comparator is greater in value than at the inverting one, a logical “1” is formed at the output of the comparator, otherwise “0”. Timers were used to generate control signals using a microcontroller based on a debug board.

timers description

fig.1 - timers' description

Each clock pulse arriving at the counting input changes the value in the CNT counting register by one. In bi-directional counting mode, the timer counts up first from 0 to the limit value, then down to 0. The count limit is determined by the value written to the ARR register. The value itself is calculated using the following formula:

ARR value

fig.2 - Value for auto reload register

If the value in the counting register CNT coincides with the value written in the capture / compare register (CCR) of any timer channel, the logical states of the outputs of this channel are switched, which is similar to the formation of a PWM signal using a comparator. On the counting period of the timer, there are two such switchings on each channel. The values in the CCR register change from period to period of the count, reproducing in the form of a code, in fact, a sinusoidal reference signal. The recalculation of sinusoidal signals and updating the values for the CCR registers can be done in an interrupt routine.

Sin formulas

fig.3 - Sin formulas

The generated program code was uploaded to the debug board in order to test the correct operation of the generated signals. The figure shows oscillograms of two complementary signals:

Complementary signals

fig.4 - Complementary signals

Speed feedback formation

The speed sensor used in the tests sends 60 pulses per 1 full revolution. At a nominal rotation speed of 1000 rpm, the sensor will send 60000 pulses/min. It was decided to evaluate the number of pulses coming from the sensor in 1 second. Thus, at a speed of 1000 rpm, we get:

Pulses formula

fig.5 - Pulses formula

Two timers were used to implement pulse counting. TIM6 is used for timing in the form of 1 second. TIM2 is used to count pulses for the specified time. At the end of the TIM6 count, the resulting value of the pulses is converted into a frequency, after which the points parameter is overwritten and the subsequent recalculation of the sin formulas. Testing and debugging of this algorithm was carried out using the debug mode in the Keil uVision 5 environment, together with tracking real indicators using the MAGTROL DSP6001 dynamometer controller.

Pulses counting

fig.5 - Pulses counting in debug mode (Keil uVision 5)

Links

Telegram Youtube