pkhZVA

Software decoding of rotary transformers based on CW32 microcontroller

 
Overview
 
 
 
 
 
 
I recently started learning about motor control and bought a power steering motor for a car. The position feedback uses a rotary transformer, a sensor also frequently used in electric vehicle motors. I heard that dedicated chips for this type are quite expensive, so I made my own decoder board using a microcontroller. The power supply voltage is +3.3V, suitable for battery power. The data update speed is 10,000 times per second, the data resolution (0-36000, with the last bit skipped, considered 12 bits), the bandwidth is 1591 Hz (I don't understand what bandwidth means), and the theoretical maximum tracking speed is 95,500 RPM (untested). It uses SPI master-slave single-transmit mode, 16-bit format, MSB first, serial clock phase configuration (sampling on the leading edge/shifting on the trailing edge), serial clock polarity configuration (low level in standby), and the receiving slave device needs to be powered on first. I had no prior experience with microcontroller communication, so I set it up as a single-transmit mode, sending one data bit and then pulling the CS high. Automatic zeroing method for resolver at arbitrary angles: Pull CW32 pin 43 low and then pull it high to enter the automatic zeroing program. This operation must be performed on newly programmed microcontrollers. If the deviation is large after automatic zeroing, the zeroing should be repeated. Matching different resolvers requires changing the capacitors connected in parallel to the excitation coil, specifically the four 103 capacitors. The reactance of the resolver excitation coil needs to be measured with an LCR meter. For example, mine is about +200 ohms, so I connected four 103 capacitors in parallel. Hardware part: The microcontroller outputs one 20kHz PWM, which is amplified by LMV to drive the resolver excitation coil. Another op-amp is inverted and connected to another excitation coil. COS and SIN are differentially amplified and then enter the two ADC ports of the microcontroller.
 
 
 
The microcontroller outputs one 20kHz PWM, which is filtered into a sine wave by RC and then amplified by an op-amp. Another op-amp is inverted, and these two op-amps drive the resolver together. The inductance of the resolver
 
 
is measured with an LCR meter, and then a capacitor is connected in parallel to make the resonant frequency the same as the driving frequency. C1 increases stability.
 
 
The COS and SIN of the rotary transformer are fed into two differential amplifiers, and then into the two ADC ports of the
 
 
 
 
CW32 microcontroller. The microcontroller's software
 
circuit works as follows: each port corresponds to a sampling rate of 1MHz. After collecting 100 points, an interrupt is triggered. The real and imaginary parts of the collected COS and SIN sequences are calculated using DFT. The phase is rotated to 0 degrees, and the real part is fed into ATAN2 to calculate the angle. The current angle is saved to a register. After the next angle is measured, the difference is subtracted to calculate the angle difference. Then, the COS and SIN of the angle difference are calculated and fed back to ATAN2. Before this, the angle fed into ATAN2 is rotated to achieve phase locking. Therefore, the obtained angle is independent of the rotational speed, thus offsetting system delay. Phase shift calculation:
zhuansu = 95500shijian = 100xiangyi = 90 - atan2(159155 / (zhuansu / 60), shijian)*180/3.1415927.
 
1.s is the source code, and 1.bin is the firmware. There are two programs: one directly displays the angle using COS12864, and the other outputs through the SPI port. The data must be processed immediately after acquisition, otherwise a large phase shift will occur when the motor speed is high.
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 18:55:56

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号