• AVR Freaks

Helpful ReplyHot!Field Oriented Control Source Code

Author
Qwertyqwq
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/02/03 12:53:18
  • Location: 0
  • Status: offline
2020/08/07 03:10:14 (permalink)
0

Field Oriented Control Source Code

 
hello i came here from stm32 family and i'm new around here :)
I want to make a pmsm motor driver. This motor driver must contain field oriented control and as you know it requires a microcontroller. As I said before, I was using the STM32 family and now I want to switch to the PIC family. I last coded 16f690 at college so I'm pretty new to this microcontroller. It will be difficult for me to start all over again due to the various workloads. I discovered the pmsm source codes of Microchip's dsPIC33EP series microcontrollers and I want to use this source code in my circuits. But I don't know exactly which one I should use. Because in my researches on the internet, he published many source code free of microchip and made it ideal for his own development boards. But I have my own power board and therefore I want to be able to manipulate it easily. I have questions about this incident right now, maybe I hope you guys can show me a way. Thank you.
post edited by Qwertyqwq - 2020/08/07 07:00:41
#1
du00000001
Just Some Member
  • Total Posts : 3946
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/07 03:41:13 (permalink) ☄ Helpfulby Qwertyqwq 2020/08/08 02:01:14
+3 (3)
A dsPIC33E*MC* might serve your needs best ("MC" stands for Motor Control and the E subfamily is a solid 60 MIPS under all temperatures). Might require porting the source code (most ANs were written for dsPIC30 and/or dsPIC33F), but porting shouldn't be that difficult.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#2
Qwertyqwq
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/02/03 12:53:18
  • Location: 0
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/07 07:07:51 (permalink)
0
du00000001
A dsPIC33E*MC* might serve your needs best ("MC" stands for Motor Control and the E subfamily is a solid 60 MIPS under all temperatures). Might require porting the source code (most ANs were written for dsPIC30 and/or dsPIC33F), but porting shouldn't be that difficult.


Thanks. 
So all I have to do is change the pins, the ports, according to my circuit? What else should I pay attention to? I also have pickit 2 and can I program dsPIC33 series pic with this?
#3
du00000001
Just Some Member
  • Total Posts : 3946
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/07 07:45:33 (permalink)
+1 (1)
I'm not sure about the PICkit2, but it's easy to check:
Start a project with the candidate of your choice in MPLAB X and check the PICkit2's status display (in the debugger section).
 
Re porting:
Might require a bit more of adaptations as the peripherals (PWM, ADC etc) may have somewhat changed. Still doable.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#4
Qwertyqwq
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/02/03 12:53:18
  • Location: 0
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/08 02:33:29 (permalink)
0
du00000001
I'm not sure about the PICkit2, but it's easy to check:
Start a project with the candidate of your choice in MPLAB X and check the PICkit2's status display (in the debugger section).
 
Re porting:
Might require a bit more of adaptations as the peripherals (PWM, ADC etc) may have somewhat changed. Still doable.


Hello I appreciate your referrals, it is very revealing.
I want to go into a little more detail about my project. I want to control a modern servo motor (pmsm) and this motor has an encoder and resolver. The resolver is especially important for determining the rotor angle at the starting position, and in this way I create the control circuit of a motor. For this reason, I am searching for sample source codes that best suit my motor. Unfortunately, I haven't found any sample code published for me yet. I thought maybe it might be a source code publication you know. For this reason, I want your help. Is there any sample code you can find for my application? Thank you very much.
#5
du00000001
Just Some Member
  • Total Posts : 3946
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/08 03:36:43 (permalink)
+2 (2)
Resolver? Why use a resolver when you've got an encoder (with reasonable angular resolution)?
Anyway, if you cannot make your own resolver evaluation software, you may come up with some open source solution: it's hardly more than applying tha arctan() function appropriately. (IIRC, one of the Microchip libraries sports atan() and atan2() - the latter being optimized for the motor control applications.)
 
If you haven't already found these:
Starting point for MC:
https://www.microchip.com...ppliance/motor-control
PMSM (the ANs are to be found somewhat "down the page"):
https://www.microchip.com/design-centers/motor-control-and-drive/motor-types/permanent-magnet-synchronous-motor
 
 

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#6
Qwertyqwq
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/02/03 12:53:18
  • Location: 0
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/08 03:58:57 (permalink)
0
du00000001
Resolver? Why use a resolver when you've got an encoder (with reasonable angular resolution)?
 

Hello, first of all thank you very much.
I want to use the motor on some kind of machine tool. For this reason, when the motor is energized, the rotor position must be learned before the motor is moved. For this reason, I want to use the resolver on it. This is impossible to accomplish with an incremental encoder (as far as I know). It already has an incremental encoder and a resolver on the motor. I plan to get speed information from motor with encoder. I will only use the resolver for position sensing. Do you think there is a more practical and easier way to do this job? thanks again...
#7
crosland
Super Member
  • Total Posts : 2041
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Warks, UK
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/08 10:24:05 (permalink)
0
Qwertyqwq
du00000001
Resolver? Why use a resolver when you've got an encoder (with reasonable angular resolution)?
 

Hello, first of all thank you very much.
I want to use the motor on some kind of machine tool. For this reason, when the motor is energized, the rotor position must be learned before the motor is moved. For this reason, I want to use the resolver on it. This is impossible to accomplish with an incremental encoder (as far as I know). It already has an incremental encoder and a resolver on the motor. I plan to get speed information from motor with encoder. I will only use the resolver for position sensing. Do you think there is a more practical and easier way to do this job? thanks again...


It would have helped all involved if you had stated up front that it was an incremental, rather than absolute encoder.
 
Why use the encoder for speed sensing when you can use the resolver? It's easier to work with ONE source of feedback for both position and speed. Speed is simple the differential of position.
 
You do realise the resolver will require external signal processing, don't you?
 
#8
Qwertyqwq
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/02/03 12:53:18
  • Location: 0
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/08 10:44:18 (permalink)
0
crosland
Qwertyqwq
du00000001
Resolver? Why use a resolver when you've got an encoder (with reasonable angular resolution)?
 

Hello, first of all thank you very much.
I want to use the motor on some kind of machine tool. For this reason, when the motor is energized, the rotor position must be learned before the motor is moved. For this reason, I want to use the resolver on it. This is impossible to accomplish with an incremental encoder (as far as I know). It already has an incremental encoder and a resolver on the motor. I plan to get speed information from motor with encoder. I will only use the resolver for position sensing. Do you think there is a more practical and easier way to do this job? thanks again...


It would have helped all involved if you had stated up front that it was an incremental, rather than absolute encoder.
 
Why use the encoder for speed sensing when you can use the resolver? It's easier to work with ONE source of feedback for both position and speed. Speed is simple the differential of position.
 
You do realise the resolver will require external signal processing, don't you?
 


yes I should have said that beforehand. sorry.
yes it will just be simpler to use the resolver, collecting data from multiple sensors is more difficult. But the problem is, I don't have a code for resolver, unfortunately. that's why I don't trust the code to write myself. I am sure it will be a program that unnecessarily tired the processor if I cannot find a sample code. so i am concerned about reading resolver.
and yes again. The resolver requires a primary signal circuit. Actually, it only took me 1 day to design this circuit. So the primary signal circuit is ready. Currently, the only shortcoming of the system is a microcontroller containing all this control algorithm. If I add the microcontroller to the system, the system will be ready for operation.
#9
crosland
Super Member
  • Total Posts : 2041
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Warks, UK
  • Status: offline
Re: Field Oriented Control Source Code 2020/08/08 12:02:40 (permalink)
0
Qwertyqwq
yes it will just be simpler to use the resolver, collecting data from multiple sensors is more difficult. But the problem is, I don't have a code for resolver, unfortunately. that's why I don't trust the code to write myself. I am sure it will be a program that unnecessarily tired the processor if I cannot find a sample code. so i am concerned about reading resolver.
and yes again. The resolver requires a primary signal circuit. Actually, it only took me 1 day to design this circuit. So the primary signal circuit is ready. Currently, the only shortcoming of the system is a microcontroller containing all this control algorithm. If I add the microcontroller to the system, the system will be ready for operation.


You have designed the interface to the resolver. Presumably this outputs absolute position data, or feeds into the uC's ADC for further processing. Once you have the position data, the code is no different whether you use a resolver or other form of absolute encoder.
 
Differentiate the position and you have the speed. Again, the code is no different to any other form of speed encoder.
 
All that varies are the scaling factors between raw data and RPM, etc.
 
#10
Jump to:
© 2020 APG vNext Commercial Version 4.5