1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Research controller and benchmark testing for regenerative braking using 3 phase induction motor

133 1 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Research Controller And Benchmark Testing For Regenerative Braking Using 3-Phase Induction Motor
Tác giả Vũ Minh Hiếu, Lê Minh Nhất
Người hướng dẫn Lê Thanh Phúc, PhD
Trường học Ho Chi Minh City University of Technology and Education
Chuyên ngành Automotive Engineering Technology
Thể loại Graduation Project
Năm xuất bản 2023
Thành phố Ho Chi Minh City
Định dạng
Số trang 133
Dung lượng 4,49 MB

Cấu trúc

  • Chapter 1: INTRODUCTION (15)
    • 1.1. Reason to choose the topic (15)
    • 1.2. Goal (15)
    • 1.3. Research subjects and its range (15)
    • 1.4. Limitation of project (16)
    • 1.5. Content of researching (16)
    • 1.6. Method of researching (16)
    • 1.7. Structure of report (16)
  • Chapter 2: LITERATURE REVIEW (18)
    • 2.1. What is Regenerative Braking System? (18)
      • 2.1.1. Definition (18)
      • 2.1.2. Working Principle (18)
      • 2.1.3. Pros and Cons (18)
    • 2.2. EMF and Counter-EMF (20)
    • 2.3. Three-phase Induction Motor (20)
      • 2.3.1. Principle (20)
      • 2.3.2. Mechanical properties of Induction Motor (23)
      • 2.3.3. Braking control of asynchronous electric motor (29)
    • 2.4. How to measure power of electric motor? (33)
    • 2.5. Load generator support frame and test data collector (36)
      • 2.5.1 Load generator support frame (36)
      • 2.5.2. Test data collector (36)
    • 2.6. Pulse Width Modulation (PWM) (39)
      • 2.6.1. Pulse Width Modulation (39)
      • 2.6.2. STM32F103C8T6 (41)
  • Chapter 3: SYSTEM DESIGN (45)
    • 3.1. Inverter circuit design (45)
      • 3.1.1. Isolation using opto (45)
      • 3.1.2. Power semiconductor device (47)
      • 3.1.3. IR2136 power semiconductor lock driver IC (48)
      • 3.1.4. The schematic diagram of the control circuit (49)
    • 3.2. Design of a circuit that recovers energy when generating a load (52)
    • 3.3. Load generator control method (53)
    • 3.4. Data collection method from load generator (56)
  • Chapter 4: BENCHMARK TESTING (59)
    • 4.1. Testing overview (59)
    • 4.2. Completed setup (59)
      • 4.2.1. Benchmark (59)
      • 4.2.2. Measurement Instrument (63)
  • Chapter 5: EXPERIMENT RESULTS AND ANALYSIS (65)
    • 5.1. Result of control signal testing (65)
    • 5.2. Load creation results (66)
  • Chapter 6: CONCLUSION AND RECOMMENDATIONS (70)
    • 6.1. Conclusion (70)
    • 6.2. Recommendation (71)

Nội dung

55In Chapter 5: Trang 14 Abstract The project presents how to control circuit and load generation method for motor power test bench, the load generating part used is a 3-phase asynchron

INTRODUCTION

Reason to choose the topic

Nowadays, the devices using electric motors are becoming more and more popular and are gradually being replaced by fossil fuel engines, so the demand for production and manufacturing of electric motors is being directed by many businesses Not to mention the vehicles using electric motors are also trending in research and development by many countries around the world and Vietnam is certainly not out of the general trend of the world It can be seen that the development potential of electric cars in the Vietnamese market is huge, about 1,100 electric cars are in operation, mainly imported cars, for personal and tourism purposes [1] However, the efficiency and performance of electric motors are still not considered optimal compared to gasoline engines, so Vietnamese consumers have not really embraced electric cars, with 33% of the respondents in the polls Recent survey intends to buy electric car [2] In order to keep up with the continuous development of electric vehicles, and the ability to localize products, it is necessary to have devices for researchers to be able to evaluate engines and improve the efficiency of electric motors Therefore, the research and design of electric motor testing equipment is necessary Although not a pioneer in the field of electric vehicles, but Vietnam is one of the countries being pushed to produce electric vehicles

Since that, electric motor test bench has been researched and designed Later, it would be possible to research, design and manufacture electric vehicles based on common electric motors in Vietnam.

Goal

- Developing a method of generating load of the test bench using an asynchronous motor

- Calculation and design of load-generating control circuit using three-phase asynchronous motor

- Develop a method to control load generation using inverters

- Evaluate the performance of the test bench when measuring a particular electric motor, comparing the results with another test rig.

Research subjects and its range

- Electric motor power test bench

- Load generation method on three-phase asynchronous motor

- Design a power test bench using a three-phase asynchronous motor.

Limitation of project

Due to the limited time, the team only focused on research on load generation control and theories related to the regenerative braking system

The system needs further development, especially for loop control capabilities

Besides, some experimental results have not achieved the desired results

The dynamometer system can only measure regenerative energy and torque without a recovery charger.

Content of researching

- An overview of relevant studies done

- Design the control inverter used to generate load

- Pulse modulation controls the drive circuitry of the inverter's IGBTs

- Experiment to create loads on the test bench with a real 3-phase motor motor

Method of researching

- Document overview: The content is synthesized from reputable scientific sources (Sciencedirect, Springer, IEEE, Elseviser) the content is summarized with the issues under study or unresolved

- The experimental method tests the previously calculated theory: the theoretical contents are tested and adjusted after the experimental process.

Structure of report

The content of the thesis includes the following chapters:

- Chapter 2: Research and design basis

- Chapter 3: Experimental layout and installation

LITERATURE REVIEW

What is Regenerative Braking System?

Regenerative braking is an energy recovery mechanism that slows down a moving vehicle or object by converting its kinetic energy into a form that can be either used immediately or stored until needed

In this mechanism, the electric traction motor uses the vehicle's momentum to recover energy that would otherwise be lost to the brake discs

The most common form of regenerative brake involves an electric motor functioning as an electric generator

Regenerative braking is implemented in conjunction with anti-lock braking systems (ABS), so the regenerative braking controller is similar to an ABS controller, which monitors the rotational speed of the wheels and the difference in that speed from one wheel to another

In vehicles that use these kinds of brakes, the brake controller not only monitors the speed of the wheels, but it can calculate how much torque rotational force is available to generate electricity to be fed back into the batteries

The most important function of the brake controller, however, may be deciding whether the motor is currently capable of handling the force necessary for stopping the car If it isn't, the brake controller turns the job over to the friction brakes, averting possible catastrophe

In vehicles that use these types of brakes, as much as any other piece of electronics on board a hybrid or electric car, the brake controller makes the entire regenerative braking process possible

The electric traction motor uses the vehicle's momentum to recover energy that would otherwise be lost to the brake discs as heat

To improving the overall efficiency of the vehicle, regeneration can significantly extend the life of the braking system as the mechanical parts will not wear out quickly

In battery electric and hybrid electric vehicles, the energy is stored chemically in a battery, electrically in a bank of capacitors, or mechanically in a rotating flywheel

Hydraulic hybrid vehicles use hydraulic motors to store energy in the form of compressed air In a hydrogen fuel cell powered vehicle, the electrical energy generated by the motor is stored chemically in a battery, similar to battery- and hybrid electric vehicles

Regenerative braking is not by itself sufficient as the sole means of safely bringing a vehicle to a standstill, or slowing it as required, so it must be used in conjunction with another braking system such as friction-based braking

- The regenerative braking effect drops off at lower speeds and cannot bring a vehicle to a complete halt reasonably quickly with current technology However, some cars like the Chevrolet Bolt can bring the vehicle to a complete stop on even surfaces when the driver knows the vehicle's regenerative braking distance This is referred to as One Pedal Driving

- Current regenerative brakes do not immobilize a stationary vehicle; physical locking is required, for example to prevent vehicles from rolling down hills

- Many road vehicles with regenerative braking do not have driven motors on all wheels (as in a two-wheel drive car); regenerative braking is normally only applicable to wheels with motors For safety, the ability to brake all wheels is required

- The regenerative braking effect available is limited, and mechanical braking is still necessary for substantial speed reductions, to bring a vehicle to a stop, or to hold a vehicle at a standstill

Once again, Regenerative and friction braking must both be used, creating the need to control them to produce the required total braking

EMF and Counter-EMF

Electromotive Force is defined as the electric potential produced by either an electrochemical cell or by changing the magnetic field EMF is the commonly used acronym for electromotive force

A generator or a battery is used for the conversion of energy from one form to another In these devices, one terminal becomes positively charged while the other becomes negatively charged Therefore, an electromotive force is a work done on a unit electric charge

Electromotive force is used in the electromagnetic flowmeter which is an application of Faraday’s law

Following is the formula for electromotive force: ε = V + Ir

V is the voltage of the cell

I is the current across the circuit r is the internal resistance of the cell ε is the electromotive force

The unit for electromotive force is Volt

EMF is numerically expressed as the number of Joules of energy given by the source divided by each Coulomb to enable a unit electric charge to move across the circuit

Therefore, Counter Electromotive Force (counter EMF, CEMF, back EMF) is the electromotive force (EMF) manifesting as a voltage that opposes the change in current which induced it CEMF is the EMF caused by electromagnetic induction.

Three-phase Induction Motor

An induction motor or asynchronous motor is an AC electric motor in which the electric current in the rotor needed to produce torque is obtained by electromagnetic induction from the magnetic field of the stator winding An induction motor can therefore be made without

15 electrical connections to the rotor An induction motor's rotor can be either wound type or squirrel-cage type

- Includes steel core and stator winding

- The steel core in the shape of a drop is joined by electrical engineering steel sheets with grooves joined together to form axial grooves The steel core is pressed in connection with the motor housing

- Stator winding is in the form of copper wire or aluminum wire with insulation layer

- The steel core is assembled from paraelectric steel sheets, the grooves on the steel core form axial inclined grooves

- There are two types: wound rotor and squirrel cage rotor

To create a rotating magnetic field, three phases of alternating voltage are applied to the ends of the windings on the stator as shown in the figure

Figure 2 1: Current distribution and dynamic force in a 3-phase winding

The equation of current per phase:

With a three-phase asynchronous motor with three-phase combing, windings AX, BY, and

CZ are placed in the stator slots The windings have their shafts separated by an electrical angle of 120 degrees (Figure 2.4) The flow direction is conventional with the "+" sign as the input direction, the "-" sign as the output direction

Figure 2 2: 3-phase rotating magnetic field (electrical-engineering-portal.com)

At each time in the Sine voltage cycle, we have the following magnetic field values in the following phases:

 , we have I A is maximum, I B, I C < 0, then the maximum phase A magnetic force, F A = F m Based on the relationship of the dynamic magnetic force vectors of the three phases, we have: m A p

- Similar to the time of

t = + , I B is maximum, I A, I C< 0, now the B phase dynamic magnetic force is maximum, F B = F m And: m B p

- Next at the time of

 , I C is maximum, I B, I A< 0, this time the maximum

Such that, at the end of a rotation cycle (2), the current and magnetic force values return to their original values When the magnetic strength of the phases changes according to the trigonometric principle, a rotating magnetic field will be generated, the speed of this rotating magnetic field depends on the angular speed of the sine voltage and the number of stator magnetic poles Therefore, in a symmetrical 3-phase AC motor, the magnetic field has a constant value, but the direction and direction will change in a circular pattern in space, also known as the rotating magnetic field.[8]

A 3-phase current in a symmetrical 3-phase winding creates a rotating magnetic field in a machine The rotating magnetic field cuts the rotor winding conductors and induces current in the rotor short-circuited conductors The magnetic force between the rotating magnetic field and the rotor current pulls the rotor to rotate in the direction of the magnetic field and the rotor to rotate at a lower speed.[8]

2.3.2 Mechanical properties of Induction Motor

In order to understand the regenerative braking ability in the asynchronous motor, we need to understand the electromechanical relationship in the asynchronous motor so that we can understand the equations setting the mechanical properties of the electric motor synchronized Hypotheses are proposed to be able to investigate the mechanical properties of asynchronous motors [15]:

- The parameters of the circuit do not depend on temperature, frequency, magnetic circuit is not saturated, so resistance, reactance, do not change

- The total conductivity of the magnetizing loop does not change, the magnetizing current does not depend on the load, only depends on the stator voltage

- Ignore losses due to friction, current losses in the steel core

From the above hypothesis, we have a replacement diagram for a single phase on an asynchronous motor:

Figure 2 3: Alternative diagram for single phase on asynchronous motor

(www.voer.edu.vn) Where:

- U 1f is the r.m.s value of the stator phase voltage (V)

- I 1 , I μ , I’ 2 are the currents in the stator, the magnetizing circuit current and the rotor current converted to the stator (A)

- X1, X μ , X’2 are stator reactance, magnetic circuit, and rotor reactance converted to stator

- R1, R μ , R’2 are stator resistance, magnetic circuit resistance, and rotor resistance converted to stator

- R’2f is the auxiliary resistance (if any) in each phase of the rotor converted to the stator, for a squirrel-rotor asynchronous motor there will be no such resistance

- s is the slip coefficient of the asynchronous motor: s = ω 1 −ω ω 1 = ω 0 −ω ω 0

- ω 1 , ω 0 is the speed of the angle of the magnetic field inside the stator aka synchronous speed (rad/s):

- f1 is the frequency of the source voltage applied to the stator (Hz)

- p is the number of pole pairs of the motor,

- ω 0 angular speed of the rotor (rad/s)

❖ Equations and mechanical properties of the motor:

From the substitution diagram, we can calculate the stator current:

- R’ 2Σ = R’ 2 + R’ 2f is the total resistance of the rotor circuit

- Xnm = X1 + X’2 is the short circuit reactance

From the stator current characteristic equation, we have:

When ω = 0 leads to slip s = 1, we have: I=I1 –I1nm short circuit of stator

When ω0 = ω leads to slippage s = 0 we have:

When operating at co-winding speed, the stator coils still have current to create a rotating magnetic field

Number of rotor currents when converted to stator:

The above equation shows the relationship between the current I'〗_2 in the rotor and the slip s or between the current I'〗_2 and the slip ω

= I 2nm ′ also known as rotor short- circuit current or inrush current

We have the equation for setting the electromechanical properties of the parabolic form as shown below:

Figure 2 4: Graph of electromechanical characteristics

Based on the power balance condition, we can find the mechanical equation Electrical power transferred from stator to rotor: P12 = Mđt 0 where Mđt is the electromagnetic torque, if the auxiliary losses are ignored:

- Mechanical power on motor shaft Pco = M.

- Copper power loss in rotor P2 = 3.I’2 R’2

Substitute into the power balance equation:

Substitute the expression for the rotor current:

The above equation M is also known as the mechanical characteristic equation of the asynchronous electric motor Based on the above expression, we can know that the line graph has the form of a curve The extreme points are determined when taking the derivative dM ds = 0, we get critical values such as slip sth and moment M th :

Figure 2 5: Asynchronous motor characteristic curve graph

Depending on the working mode, the sign in front of the expression will be different with (+) corresponding to the engine mode (-) corresponding to the generator mode

In many other cases it is possible to use approximate equations by linearizing the mechanical properties in the working section

In the region with slip s < 0,4s th , then we consider S s th =0, we have the equation to set the equation:

It is also possible to linearize the calculation line through two points, the rated working point and the no-load point The equation has the following approximate form:

M = 2M đm s đm s Based on the natural mechanical properties, replacing M = Mđm, Mth = λMđm, we have: sth = sđm( + √ 2 − 1 )

Through the form of natural mechanical properties, we can approximate the stiffness of the mechanical properties in the working section:

|β| =dM dω = 1 ω 0 dM ds = M đm ω 0 s đm β ∗ =dM/M đm dω/ω 0 = 1 s đm For feature segment with s >> sth, consider sth/s ≈ 0 and we have:

In this segment, the stiffness β > 0 and its value changes, this is usually the starting motor segment

2.3.3 Braking control of asynchronous electric motor

The principle of load generation is based on the regenerative braking operating mode on the asynchronous motor Based on the mechanical properties of the asynchronous electric motor in regenerative braking mode In this mode we have >ω_0 which means that the speed of the rotor rotates faster than the synchronous speed, then the electromotive force of the motor is greater than the source voltage E>U, at this time the current and braking torque will change direction compared to the synchronous speed motor mode, we obtain a parallel energy source returned to the grid [14] More specifically, to bring the asynchronous motor to the regenerative braking state, we create sine voltages through the use of VDF inverters, these voltages create a rotating magnetic field through the windings

In the stator, the speed of the rotating magnetic field depends on the frequency of the sine wave obtained from the inverter and the number of pole pairs, that relationship is expressed through the formula: ω 0 = 2πf p

- ω 0 synchronous speed of the motor rotor (rad/s)

- f is the frequency of the sine voltage wave applied to the stator

- p number of pole pairs of the motor

Then the mechanical property equation has the form:

M ≈ 2M th s s th +s th s With: s th ≈ 𝐑 𝟐𝚺 ′

Figure 2 6: Graph of mechanical characteristics in regenerative braking mode

Since then, through frequency adjustment f and number of pairs of poles p can create different rotational speed of the magnetic field From there the slip of the asynchronous motor can be changed From the rotating wall ω 0 is controlled so that the rotation direction is in the same direction as the rotor rotation and the angular speed is always lower than the rotor speed ω The magnetic force between the rotor and the stator in the asynchronous motor produces the same magnetic force as the working principle of the three-phase asynchronous motor The critical torque of a three-phase asynchronous motor is also considered as the maximum braking torque of the load generator It can be seen that changing the parameters affecting the motor's mechanical setting line as the above parameters will directly affect the mechanical setting line of the asynchronous motor

In order to control the braking torque during load generation, we can change the parameters affecting the mechanical properties of the asynchronous motor during regenerative braking The influence of these parameters during regenerative braking is similar to that of the operating mode Influential factors include:

When the mains voltage is significantly low, the critical torque M th will decrease with the square of the voltage attenuation U L While the synchronous speed ω 0 and the critical slip s th will not change, we have the mechanical property when U L changes

Figure 2 7: Graph of mechanical properties affected by voltage

Based on the graph, a specified resistance torque value (Mc), the lower the grid voltage, the smaller the steady-state speed On the other hand, because the starting torque Mkđ =Mnm and the critical torque Mth both decrease with the voltage, the overload and starting decrease gradually So, if the voltage U2 is too small, the upper drive system may not start or not work

• Effect of resistance, stator circuit impedance

When the resistance or resistance of the stator circuit is changed (additional impedances

Rlf, Xlf), if ω 0 = const, the torque Mth and sth both decrease, so the mechanical characteristics are as shown

Figure 2 8: Graph of changing mechanical properties affected by impedance and stator resistance (www.voer.edu.vn)

Through the grap, with the moment Mkđ = Mnmf, the working part of the mechanical characteristic with auxiliary reactance Xlf will be stiffer than the characteristic with Rlf When using Xlf or Rlf for starting to limit the inrush current, short circuit impedance triangle can be used to determine Xlf or Rlf sth both decrease with increasing Xlf or Rlf, then Mth.

• Effect of resistance, impedance of the rotor circuit

When additional impedances (R2f, X2f) are added to the rotor circuit, then ω 0 = const and

Mth = const; and sth will change, so the mechanical properties will look like the figure below

Figure 2 9: Graph of mechanical properties changed by impedance and rotor resistance

How to measure power of electric motor?

Based on the basic principle the rotor of the element under test is directly coupled to the rotor shaft of the power test bench When the test motor rotates, the rotor shaft of the dynamometer rotates At this time, in order to stop the rotation of the rotor, a magnetic force from the interaction between the stator and the rotor of the test bench is generated, the principle of load generation is based on the principle of breaking a 3-phase asynchronous motor The sensors will be arranged to measure the motor rotation speed, the load cell load sensor will be mounted on the test bench, the interaction force between the rotor and the stator will create a load acting on the load cell through a lever arm The load torque force will be calculated according to the formula: T=F.B

Figure 2 11: Method of determining moment

The power P of the object to be tested is calculated based on the measured load and the rotational speed of the motor

Since the variables in the above formula are used from the actual measured signals from the peripheral sensors, the power calculated according to the above method is called the True Power or the actual power of the device engine For each pair of torque and rotational speed values, we will calculate the actual power of the motor The values will be shown directly on the power chart of the engine, including the vertical axis is the torque generated by the motor, the horizontal axis is the actual speed of the motor The achieved results can be evaluated with the apparent power parameters of the engine that the manufacturer gives

Figure 2 12: Graph form when measuring engine power

Normally, the electric motor power test bench is usually designed based on the intended use of the motor to be tested There are two basic types of electric motor testing, the first is the test of a motor powered directly from the mains with a fixed voltage and frequency source, and the second is a test motor controlled by an inverter multimeter, depending on the type of electric motor, there will be different types of inverters, in which inverters used to control electric motors of cars are now tested more The testing process of electric motors is usually distinguished between four types of requirements such as efficiency, endurance, maximum limit and reference measurement with theory

In this article, we only focus on the load-generating capacity of the test bench During the test, the test motor will be mounted on the test stand and powered directly from the three- phase grid with frequency and voltage fixed, the load generator shall be coaxially coupled to the test motive via flexible coupling Then the load is placed through the inverter control, when the load is generated, the data from the sensors will be transmitted directly to the computer through communication with the microcontroller and calculated and given to the computer Output test graph directly from Matlab calculation software

In addition to the design of the test bench holder, the control circuit and the method of loading also play an important role in the operation of the test rig Design parameters must be calculated based on the testing purpose of each type of motor so that different load states can be generated for research and development of electric motors Moreover, the control

30 circuit also requires the selection and arrangement of electronic components in a reasonable way so that the test bench can operate stably and with high reliability

The author has selected a load generation method based on the braking principle of 3- phase asynchronous motors, specifically the regenerative braking method applied on asynchronous motors.

Load generator support frame and test data collector

The load generator used is an asynchronous motor 3 The motor holder is designed to hold the 2 axes of the motor to rotate freely in a ball bearing, the motor housing is connected to the swing arm, arm The rod is connected against the frame of the support The interaction force of the motor rotor and stator is transmitted through this lever arm, through the force sensor, the force through the lever arm can be determined The torque of the motor can be calculated through the length and geometric position of the swing arm The fixture requires a high degree of accuracy to ensure that the devices receive the measured data with as little interference as possible Therefore, the shaft end bearing of the motor must be concentric with the shaft of the motor to limit vibration during the test [13]

To be able to collect data from the sensors to the computer to perform calculations and graphs ARDUINO microprocessor is used ARDUINO receives signals from sensors through GPIO pins These signals are then transmitted directly to the computer via serial communication So the data can be directly monitored in real time

Sensors used to collect data include:

- Rotation speed sensor using optical encoder

Figure 2 15: HX711 The working principle of load cell is based on two main parts including Strain gage and Load In which the strain gage is glued to the loadcell deformation surface The deformation part is mainly located in the middle of the loadcell The commonly used load cell material is elastic and depending on the intended use, the load cell is designed in many different shapes, usually aluminum alloy and stainless steel Strain gage is a special resistor whose value varies with strain and has high stability.[16]

Figure 2 16: Formula of Resistant in loadcell Where:

A = Cross-section of strain gauge (m 2 ) r = Resistivity of strain gauge material

When a metal wire is subjected to a force, its resistance changes When the wire is compressed, the strain gauge length decreases, and the resistance decreases When the dynamometer is stretched, the strain gauge length increases, the resistance increases

A voltage is supplied to the loadcell of the Wheatstone resistor bridge) and the output voltage is measured between two other angles In the state when there is no load, the voltage signal is very small, close to zero When there is a load applied, the load cell body is deformed (expanded or compressed), resulting in a change in the size of the metal filaments of the strain gage -> change in the electrical value resistor -> change the output voltage, change the output voltage before going to the microcontroller to read the voltage values that need to go through an amplifier To make it simpler to read the load cell parameters, the HX711 ADC converter circuit is used This converter module allows the conversion of voltage changes from the load cell to digital signals These data are interpreted using a library available in the Arduino Through this library, users can calibrate the load cell values to be more accurate and easier to measure

Figure 2 17: Optical encoder The speed sensor used is an optical form sensor The rotational speed sensor is arranged on the motor shaft consisting of a perforated plate and the optical sensor is fixed on the fixture The working principle of this optical speed sensor consists of a luminescent ball and a receiver ball, when the shaft of the optical disc rotating motor rotates in the optical ecoder's groove, through the slots on the disc ecoder will output continuous signals in the

33 form of pulses These pulses will be processed through the arduino so that the number of revolutions of the motor can be determined [12]

There are two ways the rotational speed can be determined First, we can count the number of rising edges of the voltage pulse, the sampling rate to calculate the speed is 1 second Then we have the rotational speed formula:

Where: ω is the rotational speed to be determined n is the number of rising edge pulses counted in 1 second i is the number of tracks on the encoder

The second way is the sampling method when turning one ecoder revolution will count all the grooves on the ecoder disc, after counting one revolution, the time to complete that revolution will be used to calculate the engine rotation speed according to formula:

Where t is the time to count the number of tracks available on 1 turn of the ecoder.

Pulse Width Modulation (PWM)

Pulse-width modulation (PWM), or pulse-duration modulation (PDM), is a method of controlling the average power delivered by an electrical signal The average value of voltage (and current) fed to the load is controlled by switching the supply between 0 and 100% at a rate faster than it takes the load to change significantly The longer the switch is on, the higher the total power supplied to the load Along with maximum power point tracking (MPPT), it is one of the primary methods of reducing the output of solar panels to that which can be utilized by a battery PWM is particularly suited for running inertial loads such as motors, which are not as easily affected by this discrete switching The goal of PWM is to control a load; however, the PWM switching frequency must be selected carefully in order to smoothly do so

The PWM switching frequency can vary greatly depending on load and application For example, switching only has to be done several times a minute in an electric stove; 100 or

120 Hz (double of the utility frequency) in a lamp dimmer; between a few kilohertz (kHz) and tens of kHz for a motor drive; and well into the tens or hundreds of kHz in audio amplifiers and computer power supplies Choosing a switching frequency that is too high for the application results in smooth control of the load but may cause premature failure of the mechanical control components Selecting a switching frequency that is too low for the application causes oscillations in the load The main advantage of PWM is that power loss in the switching devices is very low When a switch is off there is practically no current, and when it is on and power is being transferred to the load, there is almost no voltage drop across the switch Power loss, being the product of voltage and current, is thus in both cases close to zero PWM also works well with digital controls, which, because of their on/off nature, can easily set the needed duty cycle PWM has also been used in certain communication systems where its duty cycle has been used to convey information over a communications channel

In electronics, many modern microcontrollers (MCUs) integrate PWM controllers exposed to external pins as peripheral devices under firmware control by means of internal programming interfaces These are commonly used for direct current (DC) motor control in robotics, switched-mode power supply regulation, and other applications

The term duty cycle describes the proportion of 'on' time to the regular interval or 'period' of time; a low duty cycle corresponds to low power, because the power is off for most of the time Duty cycle is expressed in percent, 100% being fully on When a digital signal is on half of the time and off the other half of the time, the digital signal has a duty cycle of 50% and resembles a "square" wave When a digital signal spends more time in the on state than the off state, it has a duty cycle of >50% When a digital signal spends more time in the off state than the on state, it has a duty cycle of 8 V, the FAULT pin returns to the high voltage state Component manufacturer recommends resistor: R = 2 MΩ, C = 1 nF then TFLTCLR = 2 ms In the design circuit using resistor R130Ω capacitor C11=1àF gives time TFLTCLR =0.1 ms

Led D4 is connected to the FAULT pin to report an error when there is an induced overcurrent at the ITRIP pin In order for the drive circuit to be activated, a 5V signal must be input to the EN pin

Figure 3 6: The schematic diagram of the power semiconductor locking circuit

The resistor on the G pin of the semiconductor key is to use a resistor with a capacity of 1/4W

The resistance when there is a control signal including R10, R9, R8, R7, R11, R13 has the value:

Resistors when disconnecting the signal, including R12, R15, R16, R17, R18, R19, have the following values:

BW LS dVs g GC dt

There are 2 resistors 100Ω and 48Ω to replace the 2 resistors above

The capacitors C12, C15, C16 are high voltage 400V 10uF capacitors that are responsible for stabilizing the source voltage when the transistors operate at high frequencies

Figure 3 7: Principle diagram of inverter circuit using power semiconductor switch

Design of a circuit that recovers energy when generating a load

The energy recovery circuit when generating resources is a diode rectifier bridge system using 6 diode components to rectify three-phase alternating current when the regenerative braking state is activated In the regenerative braking state, the regenerative voltage will be returned in parallel with the AC voltage supplied to the three phases of the motor The

47 energy recovery circuit is connected in parallel with the three voltage phases of the motor to collect feedback energy The feedback voltage will be stabilized by the output capacitor after rectification On the output side of the load generator can use purely resistive loads for easy power management

Figure 3 8: Energy recovery rectifier circuit

Load generator control method

The load generator controller reads the input signal voltage of the signal load adjustment knob, depending on the variable value, it will change different frequencies to be able to change the frequency of controlling the asynchronous motor suitable for loading conditions More specifically, the asynchronous motor control frequency must be combined with the actual speed of the motor under test, so that the motor can achieve the desired slip, as described in the theoretical basis For load generation using inverter, relative slip and braking torque will be more concerned but the control principle remains unchanged compared to the working mode, when controlling the control frequency generated from The field rotates at a rate that is always less than the actual speed When the load is generated parameters such as load torque, the actual speed under the load is recovered through the microcontroller, and then directly recovered by the computer in real time to plot the motor calculation line

According to the law of conservation of energy, when an energy source is used to generate a test load of an energizing motor, the regenerative energy recovery unit operates as soon as the load is generated

Figure 3 9: Load generator system diagram

The control circuit will receive the signal as a voltage signal with a value from 0-5V Next, the microcontroller will perform the output frequency calculation (f) After the calculation is complete, the microcontroller will output square pulses with pulse width (Duty Cycle) continuously changing after each pulse cycle, the pulse width value is updated in the sinusoidal lookup table, so that the power The output voltage is similar to a sine wave This

Exp an sion jo in ts

Power semiconductor locking inverter MCU

Re n e w ab le en er gy

49 signal is then transmitted to a set of power locks (Power Driving) to control the engine After each sinusoidal cycle the microcontroller continues to read the input voltage signal to calculate the control frequency for the next cycle

This is an open loop control method, the control frequency depends only on the input voltage signal Therefore, the slip will tend to change until the motor reaches steady state

• Method of recovering energy when generating load

With the control method of the inverter, each different frequency will change the speed of the rotating magnetic field, this speed directly affects the slip, so the energy source also depends on the control frequency The energy source instead of being returned to the grid in parallel, it will be recovered through a 3-phase 6-diode rectifier connected in parallel with the inverter, after being rectified, it will reach the consumed load, which is the light bulb 60W filament The problem occurs when operating, the power supplied to the inverter is also supplied to the rectifier, so the voltage is difficult to control To facilitate load generation testing, a Dimer is used, which is connected in series with the consuming load Energy flow can be understood as shown below

Figure 3 10: Energy flow when the motor is regenerative braking

Figure 3 11: Schematic diagram of the energy recovery circuit

Data collection method from load generator

The test bench uses two types of sensors with two different return data types This data acquisition and analysis is done on the Arduino IDE software For the Ecoder speed sensor, the return data is in the form of square pulses, so the speed calculation is as stated in the theoretical basis, the encoder's sampling time is 1 revolution Below is the flowchart of the data processing algorithm obtained from Encoder

With the load cell, because the signal decoder module is in the form of a Digital digital signal, the weight parameter is analyzed thanks to the library of the HX711 module written for use with the Arduino, so the data is easily obtained, but in addition, The load cell needs to be calibrated every time to get accurate readings From the loadcell data, we can calculate the load torque through force analysis as shown in figure:

Then the torque is calculated according to the formula M = 𝑇 2 2,016 10 -3

To be able to transmit data directly from the Arduino to the computer as a continuous and small-latency signal (streaming data) The author uses the method of transmitting data between the computer and the Arduino in the form of serial communication The data from the 2 sensors is sent to the arduino, then it is calculated and processed into the desired data, which is the rpm and torque N.m, these two data will be output as a string, each time taken The sample will be processed to produce a matrix with 1 row and 2 columns This matrix is also transferred to Matlab after each sampling and converted to float type so that a point on the coordinate system can be created, the coordinate system has a vertical axis of Moment (N.m) and a horizontal axis of speed (rev/) minute) Thus data pairs will be transmitted continuously and points on the coordinate system are created After running the test cycle The points will be joined together to create the test engine's characteristic curve Use the curve fitiing tool to output the motor calculation curve when creating a load as shown below

Figure 3 12: Force analysis Load torque

52 Figure 3 13: Sample data obtained and processed through the Curve fitting tool

BENCHMARK TESTING

Testing overview

The test shall be carried out on the basis of the provisions given in Chapters 2 and 3 Given the above conditions and the parameters given by the motor manufacturer for the motor used to generate the load, the load generator A braking torque of about 15 N.m can be produced when the test motor rotates at 1400 rpm calculated based on the formula:

After the actual design and construction of the inverter circuit and motor fixture, the control pulses are checked through the pulse meter before testing to ensure the control of the power drive circuit Then the frequency plate is used to control the no-load rotation of asynchronous motors with capacities from small to large After many tests the carrier and control wave frequencies are adjusted to the operation of the power transistors

Finally, the load-generating motor is mounted on the fixture to begin the test, the results obtained are compared directly on an existing load-generator connected to the other end of the test motor From there, evaluate the responsiveness of the load generator Experiments were conducted for the purpose of evaluating the ability to generate loads, the ability to operate the circuit under laboratory conditions, thereby evaluating the reliability of the system (safety, stability)

Completed setup

Initially, small capacity motors were used in no-load operation with a DC voltage of 60V- 180W to ensure safety After many tests and evaluations, a motor with a higher capacity - Hong Ky motor with rated capacity of 2.2kW and using a 220VAC residential DC power

Test Load Generator Load generator available

54 grid rectifier - was put to the test During each test, the author will collect important data including: control signal, operating temperature of IGBTs, amperage, voltage and motor speed

Figure 4 2: 2.2kW Hong Ky motor control test

Table 4 1: Parameters of 2.2kW motor

Next to evaluate the ability to generate loads, the motor is installed on a fixture designed in the form of aluminum profiles German motor and bench test kit with code VDE 0530/72 is used to compare load generation, the other end of the motor on this test set is connected to the shaft of the conveyor under test through a joint soft connection In which, the three- phase asynchronous motor has a nominal power of 0.3kW and is connected in a star pattern to match the three-phase power available in the laboratory

Figure 4 3: The motor is fed into the test load generator

Table 4 2: Parameters of 0.3kW motor

Parameters Giá trị Đơn vị

The motor power test bench is used to compare the results of using Eddy current to create a load, when supplying power, the eddy current will act on the rotor to make the rotor suck the stator The stator of the test bench is designed with a counterweight The outside of the test bench has a range of numbers that evenly divide the torque force from 0 to 3.2 Nm In addition, the rotational speed of the dynamometer is determined through the voltage generated by a small power generator located behind the dynamometer

Figure 4 4: Speed signal reading instrument The motor and the test bench are coaxial with each other through a flexible coupling, fixed on two metal supports to increase stability during operation

Figure 4 5: Actual experimental installation layout The phase wires of the test motor are connected directly to the 3-phase mains The 3 phase wires of the load generating motor are connected to the inverter and the load generating energy recuperator

Up to 70 MHz bandwidth, 1 GS/s maximum sample rate and 3% vertical accuracy Tektronix TBS1072C The machine has 2 channels with a measured voltage range from 0 to 1000V

• Hikvision DS-2TP31B-3AUF Long Range Thermometer

In addition, there are other measuring devices such as voltage, amperage, and electronic temperature gauges arranged below the IGBTs

In order to obtain data to directly compare the results of the test load generator with the available load generator, the sensors are designed and arranged as shown

Figure 4 7: Encoder measuring engine speed

Figure 4 8: Loadcell measuring torque when generating load The other two sensors are transmitted data directly to the computer The parameters are transmitted to the computer through the Arduino microcontroller

EXPERIMENT RESULTS AND ANALYSIS

Result of control signal testing

In this experiment, the control circuit is set to the carrier frequency of 6 kHz and the fundamental frequency at 43 Hz, for the purpose of testing the output control signal from the microcontroller

There are a total of 6 control pulse signals output from the microcontroller to the IR2136 power lock drive circuit, which is divided into 3 pairs Figure below shows the output signal of a pair of two signals In which, channel 1 is the signal to control the HO transistor of IR2136 and channel 2 is the LO pin signal

Figure 5 1: Waveform of the control signal Specifically, If HIN and LIN are high, the high-side IGBT lock will be enabled, the low- side IGBT lock will trip Otherwise, when the HIN and LIN signals are low, the high-side IGBT lock will be deactivated, and the low-side IGBT lock will turn on IGBT transistors perform a continuous DC voltage conduction interrupt to produce a voltage variation such that the overall voltage at the output of each phase is similar to a sinusoidal voltage To be able to measure phase voltage, we use 3 incandescent bulbs in a star pattern instead of 3 phase motors to easily observe the control pulse signals The figure above shows the output voltage waveform of the two phases 120° apart at the fundamental frequency

Figure 5 2: Output voltage waveform at fundamental frequency

Load creation results

For load generators using asynchronous motors, the interaction between the stator and the rotor occurs only when the motor starts to rotate So, the test motor at the beginning of the measurement will be supplied with the laboratory's 380V 3-phase power supply with the motor's rated power, then the motor has a measured speed of 1350 rpm, so the starting point The beginning of the power measurement graph will be started at 1350 rpm The figure below shows the results obtained with the plotted points on the Matlab, the results when the test motor rotates at no load, then the torque obtained from the loadcell sensor ranges from 0.04 N.m to 0.08 N.m

61 Figure 5 3: Graph obtained after generating load at 45Hz

Figure 5 4: Characterization graph when the load is generated at 43Hz

Figure 5 5: Calculation line when generating load at 40Hz

Two load generation results at 43 and 40 hz are tested on the actual test bench When the test checks the results on the actual test bench, the load is controlled so that the motor is slowed down to 3 speeds at 3 frequencies of the test load generator, then the actual braking torque will be recorded again Carry out the test for each speed with the comparison results as shown in the following table:

Table 5 1: Comparison of actual and tested dynamometer results

Test Load Generator Load generator VDE 0530/72

Speed (rpm) Moment (N.m) Speed (rpm) Moment (N.m)

After load generation test, it shows that with 3 test load generating frequencies, the results are close to the available load generator However, the oscillation of the torque sensor is still high, so the exact result of the braking torque cannot be determined exactly, but only the average value is obtained

Monitor the regenerative braking voltage after being rectified at 40Hz as 120V, the current consumed by the lamp load is 2A Meanwhile, the voltage applied to the load generator is 60V and the current consumed is 2A Through this experiment, we can also see the regenerative capacity of the asynchronous motor so that we can study more about regenerative braking for three-phase asynchronous motors used on electric vehicles

CONCLUSION AND RECOMMENDATIONS

Conclusion

With the goal of researching the loaders used to test electric motors, thereby helping the research and production of control systems and classic motors can develop more, along with it is a domestic problem chemical components of Vietnamese electric vehicle products

In terms of science, initially succeeded in researching load generation from asynchronous motors In parallel with it, load generation can be applied in energy recovery on electric vehicles when regenerative braking Tests are still being carried out in the laboratory on various asynchronous motors and inverter circuits to evaluate the ability to generate stable loads and control regenerative energy

With the basis and method of load generation mentioned in the theoretical basis and system design The load generator has succeeded in generating the load based on the characteristics of the asynchronous motor with three fixed load generation control frequencies 40Hz, 45Hz The results obtained from the data collectors after testing at 3 frequencies when compared with the available test benches are almost equivalent Energy recovery source with voltage 120V and current 2A The hottest working area of the inverter is in the transistors that oscillate about 50℃ It can be seen that the motor load generator control method is being implemented with the open control method, so the load generated is not fixed but depends on the slip of the asynchronous motor, on the other hand There are few frequency ranges to control the load generation frequency, so the closed control is being further studied to be able to meet the ability to simulate the load conditions as in reality

The retrieval and analysis of the data from the load generator is done through the IDE and Matlab software and the desired results are obtained In addition, the mechanical details of the spreader are designed through Inventer software to meet the structure and performance when the engine generates load However, when the load generator is not optimized, some speeds will cause resonance, affecting the parameters of the load cell load cell

In summary, the experimental results show that the designed inverter and current control method can generate loads and recover energy from the asynchronous motor The data recovery method and the design of the load generating bracket were initially successful, so the load generator could be tested with electric motors

Recommendation

During the research period, there were a number of issues that needed to be clarified in order to develop a more efficient load generator The first is that the circuit needs to be designed to minimize noise during the control process The selection of components as a power semiconductor key is only for reference and trial and error do not have specific data to be able to choose a suitable semiconductor key in a 3-phase inverter circuit The control algorithm needs to be optimized to limit the delay when switching the control frequency The second is that the mechanical design of the test bench has not been performed with high precision to limit the generated vibration Besides, more tests need to be done on different engines to accurately assess the ability to generate loads The next direction is to design a load generator with high stability and noise reduction along with a closed control method using only one microcontroller, from which it is possible to combine CarSim simulation software to generate loading mode more similar to reality

To obtain the above results, the studies were carried out in the electric vehicle laboratory of the University of Technology and Education of Ho Chi Minh City HCM with a full range of testing equipment, it is a favorable condition for research and development Therefore, based on the existing equipment and facilities, the research on electric vehicles in general and electric motors in particular is still going on to be able to serve the electric vehicle industry of Vietnam today, a more developed

[1] Nguyen, X T and Nguyen, Q H., “Service Issues: Overview of Electric Vehicles Use in Vietnam,” Armand Peugeot Chair International Conference: 3rd Electromobility Challenging Issues, Dec 2015, Singapore, https://hal.archives-ouvertes.fr/hal-01239618/ (Accessed June 2, 2021) Carl Vogel Build Your Own Electric Motorcycle McGraw-Hill Companies, July 2009

[2] Nguyen, K M., “Features and Prospects of the Electric Vehicle in the Vietnamese Automobile Market”, IOP Conference Series: Materials Science and Engineering, IOP Publishing, 2020, 012007

[3] Lê Duy Hưng, Trịnh Xuân Bình “Nghiên cứu chế tạo bộ đo momen xoắn sử dụng cảm biến dạn kết hợp với trục xoắn”

[4] Richard D Atkins-An “Introduction to Engine Testing and Development”-SAE International (2009)

[5] Izhar, T., Ali, M., Sohaib, M., & Nazir, A (2017) “Development of a motor test bench to measure electrical/mechanical parameters” 2017 International Conference on Energy Conservation and Efficiency (ICECE)

[6] P Fajri, S Lee, VA Prabhala, M Ferdowsi “Modeling and Integration of Electric Vehicle Regenerative and Friction Braking for Motor/Dynamometer Test Bench Emulation” IEEE Transactions on Vehicular Technology 65 (6), 4264 – 4273

[7] Trần Minh Sơ Giáo trình kỹ thuật điện NXB Đại học Sư Phạm Hà Nội, 2004

[8] Đặng Văn Thành Kỹ thuật truyền động điện NXB Khoa học và kỹ thuật Hà Nội,

[9] Le Thanh Phuc, Nguyen Le Khuong Duy Research on regenerative braking on squirrel cage induction motor

[10] “IGBT – Working, Types, Structure, Operation & Applications” Internet: https://www.electricaltechnology.org/2021/08/igbt.html, 6/2022

[11] Đinh Cao Trí “Tính Toán, Thiết Kế Hệ Thống Điều Khiển Trên Xe Máy Điện”

[12] Tian Fu Loke-Cytron Technologies Sdn Bhd “Getting Started with Encoder Sensor Module (SN-ENC-MOD)” July 12, 2017

[13] Trần Minh Sơ Giáo trình kỹ thuật điện NXB Đại học Sư Phạm Hà Nội, 2004

[14] Phạm Khánh Tùng Giáo trình Cung cấp điện, Nhà xuất bản Đại học Sư phạm, 2003

[15] Đặng Văn Thành, “Giáo trình kỹ thuật điện,” NXB Đại học Quốc gia Tp HCM,

[16] John X.J Zhang, Kazunori Hoshino, “Molecular Sensors and Nanodevices” Chapter 6 - Mechanical transducers: Cantilevers, acoustic wave sensors, and thermal sensors (Second Edition), 2019

TIM_HandleTypeDef htim3; void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_TIM1_Init(void); static void MX_TIM2_Init(void); static void MX_TIM3_Init(void); static void MX_ADC1_Init(void); volatile uint16_t numberS=0; uint16_t Gear1=0; uint16_t Gear2=0; int count=0; uint16_t i0=0; uint16_t seclect, check_adc; float error; uint16_t ADC_Sensor , old_adc;

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

HAL_TIM_Base_Start_IT(&htim2);

HAL_TIM_Base_Start_IT(&htim3);

HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);

HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);

HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3);

HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);

HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);

HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);

HAL_ADC_PollForConversion(&hadc1,HAL_MAX_DELAY);

ADC_Sensor HAL_ADC_GetValue(&hadc1);

HAL_ADC_Stop(&hadc1); if ( ADC_Sensor < 1200)

} else if ( (ADC_Sensor > 1200)&&(ADC_Sensor < 2000) )

{ seclect = 3; numberS = 320; check_adc = 1 ; continue;

} void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim2)

/** Initializes the RCC Oscillators according to the specified parameters

* in the RCC_OscInitTypeDef structure

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

/** Initializes the CPU, AHB and APB buses clocks

RCC_ClkInitStruct.ClockType RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) ! HAL_OK)

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;

PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

*/ static void MX_ADC1_Init(void)

/* USER CODE BEGIN ADC1_Init 0 */

/* USER CODE END ADC1_Init 0 */

/* USER CODE BEGIN ADC1_Init 1 */

/* USER CODE END ADC1_Init 1 */

*/ hadc1.Instance = ADC1; hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; hadc1.Init.ContinuousConvMode = DISABLE; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.NbrOfConversion = 1; if (HAL_ADC_Init(&hadc1) != HAL_OK)

*/ sConfig.Channel = ADC_CHANNEL_4; sConfig.Rank = ADC_REGULAR_RANK_1; sConfig.SamplingTime = ADC_SAMPLETIME_55CYCLES_5; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

/* USER CODE BEGIN ADC1_Init 2 */

/* USER CODE END ADC1_Init 2 */

*/ static void MX_TIM1_Init(void)

/* USER CODE BEGIN TIM1_Init 0 */

/* USER CODE END TIM1_Init 0 */

/* USER CODE BEGIN TIM1_Init 1 */

/* USER CODE END TIM1_Init 1 */ htim1.Instance = TIM1; htim1.Init.Prescaler = 0; htim1.Init.CounterMode = TIM_COUNTERMODE_CENTERALIGNED2;

112 htim1.Init.Period = 5249; htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim1.Init.RepetitionCounter = 0; htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; if (HAL_TIM_Base_Init(&htim1) != HAL_OK)

} sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) {

} if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)

} sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) ! HAL_OK)

} sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = 0;

113 sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) ! HAL_OK)

} sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; sBreakDeadTimeConfig.DeadTime = 0; sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) ! HAL_OK)

/* USER CODE BEGIN TIM1_Init 2 */

/* USER CODE END TIM1_Init 2 */

*/ static void MX_TIM2_Init(void)

/* USER CODE BEGIN TIM2_Init 0 */

/* USER CODE END TIM2_Init 0 */

/* USER CODE BEGIN TIM2_Init 1 */

/* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; htim2.Init.Prescaler = 0; htim2.Init.CounterMode = TIM_COUNTERMODE_CENTERALIGNED1; htim2.Init.Period = 5249; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

115 htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; if (HAL_TIM_Base_Init(&htim2) != HAL_OK)

} if (HAL_TIM_PWM_Init(&htim2) != HAL_OK)

} sSlaveConfig.SlaveMode = TIM_SLAVEMODE_TRIGGER; sSlaveConfig.InputTrigger = TIM_TS_ITR0; if (HAL_TIM_SlaveConfigSynchro(&htim2, &sSlaveConfig) != HAL_OK)

} sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) ! HAL_OK)

} sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = 0; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;

116 if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) ! HAL_OK)

} if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) ! HAL_OK)

} if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_3) ! HAL_OK)

} sConfigOC.OCMode = TIM_OCMODE_PWM2; if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) ! HAL_OK)

/* USER CODE BEGIN TIM2_Init 2 */

/* USER CODE END TIM2_Init 2 */

*/ static void MX_TIM3_Init(void)

/* USER CODE BEGIN TIM3_Init 0 */

/* USER CODE END TIM3_Init 0 */

/* USER CODE BEGIN TIM3_Init 1 */

/* USER CODE END TIM3_Init 1 */ htim3.Instance = TIM3; htim3.Init.Prescaler = 0; htim3.Init.CounterMode = TIM_COUNTERMODE_CENTERALIGNED1; htim3.Init.Period = 5249; htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

118 htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; if (HAL_TIM_Base_Init(&htim3) != HAL_OK)

} if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)

} sSlaveConfig.SlaveMode = TIM_SLAVEMODE_TRIGGER; sSlaveConfig.InputTrigger = TIM_TS_ITR0; if (HAL_TIM_SlaveConfigSynchro(&htim3, &sSlaveConfig) != HAL_OK)

} sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) ! HAL_OK)

} sConfigOC.OCMode = TIM_OCMODE_PWM2; sConfigOC.Pulse = 0; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;

119 if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) ! HAL_OK)

} if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) ! HAL_OK)

/* USER CODE BEGIN TIM3_Init 2 */

/* USER CODE END TIM3_Init 2 */

*/ static void MX_GPIO_Init(void)

/* USER CODE BEGIN MX_GPIO_Init_1 */

/* USER CODE END MX_GPIO_Init_1 */

HAL_RCC_GPIOC_CLK_ENABLE();

HAL_RCC_GPIOD_CLK_ENABLE();

HAL_RCC_GPIOA_CLK_ENABLE();

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);

GPIO_InitStruct.Pin = GPIO_PIN_13;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/* USER CODE BEGIN MX_GPIO_Init_2 */

/* USER CODE END MX_GPIO_Init_2 */

* @brief This function is executed in case of error occurrence

/* USER CODE BEGIN Error_Handler_Debug */

/* User can add his own implementation to report the HAL error return state */

/* USER CODE END Error_Handler_Debug */

* @brief Reports the name of the source file and the source line number

* where the assert_param error has occurred

* @param file: pointer to the source file name

* @param line: assert_param error line source number

*/ void assert_failed(uint8_t *file, uint32_t line)

/* User can add his own implementation to report the file name and line number,

122 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

// HX711 circuit wiring const int LOADCELL_DOUT_PIN = 2; const int LOADCELL_SCK_PIN = 3;

Serial.println("Initializing the scale"); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

Serial.println("Before setting up the scale:");

Serial.println(scale.read()); // print a raw reading from the ADC

Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC

Serial.println(scale.get_value(5)); // print the average of 5 readings from the ADC minus the tare weight (not set yet)

Serial.println(scale.get_units(5), 1); // print the average of 5 readings from the ADC minus tare weight (not set) divided

// by the SCALE parameter (not set yet) scale.set_scale(-15484);

//scale.set_scale(-471.497); // this value is obtained by calibrating the scale with known weights; see the README for details scale.tare(); // reset the scale to 0

Serial.println("After setting up the scale:");

Serial.println(scale.read()); // print a raw reading from the ADC

Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC

Serial.println(scale.get_value(5)); // print the average of 5 readings from the ADC minus the tare weight, set with tare()

Serial.println(scale.get_units(5), 1); // print the average of 5 readings from the ADC minus tare weight, divided

// by the SCALE parameter set with set_scale

Serial.print(scale.get_units(), 1);

Serial.println(scale.get_units(10), 5); delay(5000);

Code for Encoder Module signed int motor1Speed; int encoder_pin = 2; // The pin the encoder is connected unsigned int rpm; // rpm reading volatile byte pulses; // number of pulses unsigned long timeold;

// The number of pulses per revolution

// depends on your index disc!! unsigned int pulsesperturn = 20; void counter()

Serial.begin(9600); pinMode(encoder_pin, INPUT); pinMode(motor1Speed , OUTPUT); attachInterrupt(0, counter, FALLING); pulses = 0; rpm = 0; timeold = 0;

{ if (millis() - timeold >= 1000){ /*Uptade every one second, this will be equal to reading frecuency (Hz).*/

//Don't process interrupts during calculations detachInterrupt(0);

//Note that this would be 60*1000/(millis() - timeold)*pulses if the interrupt

//happened once per revolution rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses; timeold = millis(); pulses = 0;

//Write it out to serial port

//Restart the interrupt processing attachInterrupt(0, counter, FALLING); int potvalue = analogRead(1); // Potentiometer connected to Pin A1 int motorspeed = map(potvalue, 0, 1023, 255, 0); analogWrite(motor1Speed, motorspeed); digitalWrite(motor1Speed, 1);

Ngày đăng: 22/02/2024, 12:39

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w