你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【电机控制】手把手一起玩转电机库SDK  

[复制链接]
努力的人 发布时间:2017-8-28 13:56
相关阅读:; w, X# d1 c) }: Z! O. B2 y0 R4 A
电机培训 - 三个任务主函数及中断程序( j; B6 ]0 p1 o
电机培训 - 让你可以深入研究的PMSM/BLDC文档
9 C  J. |) Q8 \' m) N9 L! O, _
5 C2 F* c; m- g7 YPS:如果大家觉得帖子还可以的话,请到社区之星评选为我投出你宝贵的一票谢谢
点击进入投票/ K0 a  e& N7 F! q) Q8 a  E
很高兴参加了ST的电机控制培训,先上几张图,我也悄悄地在提问窗口回复了坛友的问题
1.jpg

* f/ O/ M4 |6 q
& G2 ?5 j0 h& ]; I# [ 2.jpg 3 |- M! X- N" C+ E

  g1 y; b+ j0 U" t) G8 i ST研讨会.jpg / O+ k/ |. L$ N9 P0 ^: Y
下面开始步入正题吧!我的主函数程序下载 main.rar (3.98 KB, 下载次数: 113)
赞 收藏 10 评论49 发布时间:2017-8-28 13:56

举报

49个回答
努力的人 回答时间:2017-8-31 10:33:33
donatello1996 发表于 2017-8-30 23:35
: Y$ M1 P2 P( b$ _) ~对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊? ...
  v+ N6 b! a  D: Y# g. g+ \
1.jpg
+ `1 V" l( ?; S, D! `" t: [( k母线电压是ADC采样的! _3 h: @8 x: R- Q  m. ?3 [
所有的函数都在这里,你自己查 STM32 FOC PMSM FW library developer Help file.chm (1.14 MB, 下载次数: 78)
努力的人 回答时间:2017-8-28 13:58:01
本帖最后由 努力的人 于 2017-8-28 15:07 编辑
$ ^$ `; G6 a5 L) H/ t( B! [+ Y' u! i3 r: P
TASK3
6 H; P1 Q+ V' g2 d$ e$ X    首先还是上传一下源码8 C7 h& ~" z6 Z  |% M
  1. //TASK3 源码
    6 h2 {$ l$ a3 c* ?: f$ t5 F
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);3 A, T! s& M. [7 [7 F9 W% c8 S+ v
  3.         MCI_StartMotor(oMCI[0]);
    4 _1 E6 C1 `* U) ]1 Y5 P! y
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);0 g! {' F' l' i0 V: M+ j5 H
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
    " K( ]0 R1 ]6 v' U+ a
  6.         //STM_NextState(oSTM,STOP_IDLE);
      y+ v/ I. G/ D
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );
    # e3 D- M% m5 i& s
  8.         while(1)
    . I! G5 V" J4 @3 ^( \  _" @
  9.           {
    7 Q$ G: Q) Q" `# T4 u5 |
  10.                 ( K6 @! v( x. l+ U4 w$ T& p/ f
  11.                
    8 n0 Y  u/ {7 L7 [  G$ ^
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);
    9 D( o+ R, M7 L* J$ c
  13.         if(Fault_Type == MC_SPEED_FDBK)
    6 U% p- E4 n; y9 S$ I
  14.         {
    3 R- d1 ~+ l  w, k4 m
  15.                 //MCI_FaultAcknowledged(oMCI[0]);' V$ u; L* g" g: y2 C6 @) a: |
  16.                 //MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);. G: j( {1 V/ j$ q
  17.                 //MCI_StartMotor(oMCI[0]);
    : F  ?9 o, u+ e" z2 Z6 Y
  18.         }
复制代码
将程序写好后,下载到板子中,我们可以看到致故障的上位机界面4 ?5 Y: p$ }/ P1 o! e
致故障.jpg
4 g" l' Z  u+ c# ~; ]/ }然后我们将下面的代码下进板子中
6 u& ?# R: V1 i9 l4 F: K& o4 y
  1. //TASK3 源码3 v& L& I$ |8 u. }
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);
    % m4 n! B8 D/ b6 o/ N, w
  3.         MCI_StartMotor(oMCI[0]);
    ) A* h8 V/ `1 F. r/ l& H* h
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);
    & i9 W0 j2 F# K0 u! N5 y% Z5 r6 [
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);8 N6 }: n% ^3 N; \
  6.         //STM_NextState(oSTM,STOP_IDLE);
    . Q) @" E! s$ b! s1 j, W
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );
    3 _1 B; X8 t" @( e2 C% p" _' u
  8.         while(1)0 j& e2 |7 w, F* a& f1 |
  9.           {: p1 G  ~" V* D
  10.                
    & Z$ r( K( q5 i) [
  11.                
    ' F# ]6 e& i1 @  b/ q
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);( N8 z/ u$ S% E. v
  13.         if(Fault_Type == MC_SPEED_FDBK)5 e/ x/ E2 |: z4 v$ u$ F
  14.         {  Z- L8 M" {/ h
  15.                 MCI_FaultAcknowledged(oMCI[0]);2 W5 L% Z5 H/ r' _, \
  16.                 MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);
    " \. O) w* X. N1 Q2 O1 T
  17.                 MCI_StartMotor(oMCI[0]);
    4 c( I  z2 f" J+ ^  f9 e: n
  18.         }
复制代码
可以发现电机正常反转。
- E5 Q/ P. \. g/ K0 u关于故障代码可以参考: 故障代码查询.jpg
- ~( i9 s! f# J1 _2 t. a+ D4 W8 B关于至状态机故障和清除故障的程序,大家参考StateMachineClass.h
) r! _: b2 m! u  J6 j; e
  1. /**2 \; b3 |# l4 n
  2.   ******************************************************************************- n" q0 @: }; U- q- a: s
  3.   * @file    StateMachineClass.h6 a6 R( a8 k, z0 O
  4.   * @author  STMicroelectronics - System Lab - MC Team
    3 w0 q! c5 F' X, b; Z8 D% i
  5.   * @version 4.3.00 Y8 u9 j" {+ X: f! P" F; o
  6.   * @date    22-Sep-2016 15:29
    4 ~$ }9 ^; y) R- b% R/ W
  7.   * @brief   This file contains interface of StateMachine class      / U4 D9 N4 M" N5 t8 h
  8.   ******************************************************************************
    % s" _3 N, q+ i& ?
  9.   * @attention
    ; a2 @3 E; W; b5 q
  10.   ** |( e9 Z- s# C' a* t
  11.   * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>
    - ?& F  N2 K) q! ?. q# f0 K
  12.   *
    . ?) L9 B  C) Y! q
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
    + P$ W' w1 @0 Z' ]6 s
  14.   * You may not use this file except in compliance with the License.2 l& r2 G8 D+ Q# W/ p; A, d* `
  15.   * You may obtain a copy of the License at:
    * ~, T3 v, P9 i8 @+ i
  16.   *
    9 \5 F5 s, U1 t6 T$ ~
  17.   *        http://www.st.com/software_license_agreement_liberty_v2+ U8 {7 K# z* V" B- l7 w7 l# X
  18.   *
    1 H, l2 o# A. t
  19.   * Unless required by applicable law or agreed to in writing, software . ~6 a0 J, |2 _  j0 G9 f! L/ g
  20.   * distributed under the License is distributed on an "AS IS" BASIS,
    " k* t  I  {& d% A
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    ; L! c/ \* p# l4 d& Y
  22.   * See the License for the specific language governing permissions and
    6 Y$ J7 r2 Z. O3 K
  23.   * limitations under the License.2 Y  A: a* p0 T% Q# \
  24.   *1 _6 `/ A6 }7 S/ a  c2 Y3 A7 k
  25.   ******************************************************************************. l2 A; D: T, d: ]) H& u
  26.   */
    . E$ E5 ]: T  S' Y9 I3 r% G

  27. 4 e' u0 ~; E4 a% }9 ?: [. l
  28. /* Define to prevent recursive inclusion -------------------------------------*/- S: E+ T8 n4 s9 J+ g2 d# v" Y
  29. #ifndef __STATEMACHINECLASS_H
    3 c" b& Y, C5 L1 k5 w, W
  30. #define __STATEMACHINECLASS_H! J; K4 b' Q& D1 {+ `9 r. o1 ~

  31. & ]; t6 G6 t" P6 Y
  32. /* Includes ------------------------------------------------------------------*/
    . t! U$ c4 b& ?/ M* Y3 n# s3 H
  33. #include "MC_type.h"
    " I7 U( z" k9 N' t: `' n, ]. U( N
  34. : y+ ^- @' ^4 F' a% H/ [1 U
  35. /** @addtogroup STM32_PMSM_MC_Library1 o$ U4 C/ W2 L( h. G
  36.   * @{
    7 n, A# D$ x/ {! _
  37.   */, I* T" D1 E+ F5 @+ E. p. i

  38.   E+ D4 ^, {7 w
  39. /** @addtogroup StateMachine8 _- I: _. A+ H8 ~6 `
  40.   * @{
    7 [! F4 {' x& |
  41.   */9 o6 u2 t% X' Q" }& E8 t5 o
  42. ! V5 O- v$ A- j1 B9 }: ^# o
  43. /** @defgroup StateMachine_class_exported_constants StateMachine class exported constants# B& b2 I- P2 k# O/ j& n: X
  44.   * @{! h4 }( |1 i2 q8 M: ]
  45.   */0 [2 m1 `6 ~0 G7 a1 W

  46. 8 A+ F$ `! V2 {% }! @6 _# B
  47. % }% v- a' ~( t2 Y
  48. /**
    4 e, s, ?, k) V& E5 C
  49. * @}
    # x4 t1 a, g: r& e8 `
  50. */
    6 p# b; T4 A/ O+ z% {; ]
  51. , ^( ~( F- z2 [# |6 V* x
  52. /** @defgroup StateMachine_class_exported_types StateMachine class exported types1 T" r  E2 _* g2 K7 R
  53. * @{
    . o, K! r2 {8 K9 \; [
  54. */! ]5 d  \5 q4 _2 y
  55. + A' X6 Z2 n! P* H

  56. , D* j/ z- M5 o4 K$ |
  57. /**   V. m( J3 @) z% J. ]
  58.   * @brief  Public StateMachine class definition
    4 ~5 X' h) ~( X  Z0 u1 |" P
  59.   */- ~+ ?$ d3 I7 N
  60. typedef struct CSTM_t *CSTM;2 X: `& U% p" m) Y7 C' X

  61. . B0 K! k1 u. C
  62. /**
    ; K) r# [5 `5 V. t
  63. * @}. m: H$ I+ c6 O1 Y* f
  64. */
    & _- }8 H4 H4 T

  65. - g+ T! g5 t$ f! M0 C; _. B
  66. /** @defgroup StateMachine_class_exported_methods StateMachine class exported methods: X# d4 ?# j7 W9 c0 x+ K
  67.   * @{
    : Q% }" ?) B: J& U! W
  68.   */
    . F1 m. ]& O0 m5 ?% Q( ?

  69. 3 Y5 I4 Q, T& G; r( H" f" f
  70. /**
    1 g& _  I3 A& K' f8 U. w
  71.   * @brief  Creates an object of the class StateMachine.5 X8 p1 A% M4 _6 Y
  72.   * @param pStateMachineParams pointer to a StateMachine parameters structure.& ^8 z5 y) t: `- G$ \* K
  73.   * @retval CSTM new instance of StateMachine object.
    / Q9 W& c% G4 h, v- t3 g7 d9 e
  74.   *// X" [- b5 r3 r1 h3 H
  75. CSTM STM_NewObject(void);
    2 x( y& w# k8 D% c

  76. ' J& T% Y, G# i6 r; b
  77. /**( Z6 E+ r6 i) {2 G. l
  78.   * @brief  Initializes all the object variables, usually it has to be called - |% X" Y2 C. D9 {' {
  79.   *         once right after object creation.
    - v- o$ Y" j8 d0 S0 @
  80.   * @param this related object of class CSTM.
    5 G: M5 I! i* q3 m# O0 `8 ?' p$ n
  81.   * @retval none.$ o" J& @3 X2 u% K( y2 }3 l
  82.   */
    # q2 s; P0 k; F! f1 Q% x
  83. void STM_Init(CSTM this);0 f! Y5 _4 ^# Y" N

  84. 8 ^1 c9 V! S- ?
  85. /**
    8 F$ d( W: Y' J9 A
  86.   * @brief It submits the request for moving the state machine into the state % a- v1 O$ X3 ?5 s% b
  87.   *        specified by bState (FAULT_NOW and FAUL_OVER are not handled by this
    # Z) U1 d0 S- w0 j' ]
  88.   *        method). Accordingly with the current state, the command is really
    8 p- `: T8 ^/ d8 a5 a* V
  89.   *        executed (state machine set to bState) or discarded (no
    $ u- g* p+ a" q, o; ^5 ?: C
  90.   *        state changes) ! K2 C9 x# U% L0 D
  91.   * @param this related object of class CSTM.
    0 b" r7 K$ G) L
  92.   * @param bState New requested state. y) h0 Z8 j! x  [8 Q- ?. `
  93.   * @retval bool It returns TRUE if the state has been really set equal to
    # ~/ }. |* \4 G: B
  94.   *              bState, FALSE if the request has been discarded
    / X, N" K' U! X' l
  95.   */
    % x7 F% f- L7 V0 q+ E% I' o+ ^
  96. bool STM_NextState(CSTM this, State_t bState);
    * }0 c& I0 i8 F. r
  97. * Y' b; o0 G" h; a. P' L% u8 K9 E
  98. /**$ e9 g/ D) d9 A, ~
  99.   * @brief It clocks both HW and SW faults processing and update the state 7 @2 {. Q. R; U
  100.   *        machine accordingly with hSetErrors, hResetErrors and present state. 6 b7 i* @5 ^+ I
  101.   *        Refer to State_t description for more information about fault states.) P- h8 c# Z7 K
  102.   * @param this object of class CSTM
    , K  \, `  u' M2 Q- F, ]! i! X" Y
  103.   * @param hSetErrors Bit field reporting faults currently present
    ' K. t( L8 B- T& M# O
  104.   * @param hResetErrors Bit field reporting faults to be cleared
    " F1 R# R7 |0 f+ J7 ]6 Z' @) @# l
  105.   * @retval State_t New state machine state after fault processing
    & |$ T( O. G0 C$ e0 W
  106.   */
    5 l& o! O3 _' {4 F4 J- q1 h+ Q
  107. State_t STM_FaultProcessing(CSTM this, uint16_t hSetErrors, uint16_t , g! F& ~0 Q  n7 Y* |
  108.                                                                   hResetErrors);
    # o/ N) h4 h. s' `' J

  109. . f' Z! O8 U" t5 F
  110. /**
    6 Y2 p3 D7 B' K8 y1 ?
  111.   * @brief  Returns the current state machine state5 z) S6 V( e4 }; _2 F! h9 S( `! u' X3 G
  112.   * @param  this object of class CSTM
    : z1 H* B& W" V" v
  113.   * @retval State_t Current state machine state
    # p! S' Y0 a' P! [6 H6 f
  114.   */5 b9 J; j1 U$ d
  115. State_t STM_GetState(CSTM this);
    8 m- Y9 ?: ]  Y+ `  g" d" f

  116. % P; |5 u: S4 G5 [% i$ x
  117. /**
    8 o% a4 K( m) a' y& [) L
  118.   * @brief It reports to the state machine that the fault state has been # B6 _) _4 s7 t+ B* ~) y
  119.   *        acknowledged by the user. If the state machine is in FAULT_OVER state
    - |7 a9 A# n; p7 s( b. n8 K! ~
  120.   *        then it is moved into STOP_IDLE and the bit field variable containing - x* f; q( {) F! H7 M
  121.   *        information about the faults historically occured is cleared.
    * }( u6 X! N) k- S6 K6 ]5 H+ l
  122.   *        The method call is discarded if the state machine is not in FAULT_OVER- v% s% e1 J6 _- u+ `; n
  123.   * @param this object of class CSTM
      P+ S; B7 x( H0 a5 r% f6 m8 J
  124.   * @retval bool TRUE if the state machine has been moved to IDLE, FALSE if the 4 {+ h' n( y( j) P9 c3 |+ u
  125.   *        method call had no effects
    ) Z) p* f; w& a7 t' }$ w
  126.   */
      i. I* M- _0 B) }8 O$ @
  127. bool STM_FaultAcknowledged(CSTM this);
    1 L: t5 J1 M, G; u* c
  128. ! F: G7 d$ ~, s# u% X! D
  129. /**# J: Q- |2 X& w4 j! Z) Q2 e! S
  130.   * @brief It returns two 16 bit fields containing information about both faults0 t& G! S, H. ~+ K5 z- d
  131.   *        currently present and faults historically occurred since the state
    " ^: F1 K+ b' g" S# q" L3 M
  132.   *        machine has been moved into state
    + W5 }# f8 e6 R. k% H* b
  133.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink' L6 L  F! K7 e( _
  134.   * @param this object of class CSTM.8 y' I; K$ a9 [! i) x
  135.   * @retval uint32_t  Two 16 bit fields: in the most significant half are stored
    3 S2 z: W. Q# A" |
  136.   *         the information about currently present faults. In the least 3 L/ P+ x5 t9 @( U
  137.   *         significant half are stored the information about the faults
    . |! Y1 B. |/ g+ `) b
  138.   *         historically occurred since the state machine has been moved into 6 X: S& v, L$ j* e* o' A, b$ ~
  139.   *         FAULT_NOW state$ k! r% G2 o: w: |+ M  a
  140.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    6 j4 F$ `# h* T( T- b* k
  141.   */5 C/ G; v/ V; e. y" G2 j
  142. uint32_t STM_GetFaultState(CSTM this);& m) g$ [- @+ W/ k  t- o/ ~
  143. 3 d. ^5 K$ y: O' T' o- p
  144. /**6 b2 L$ ?# K9 G( I
  145.   * @}
    $ i+ O: K$ o( V: U) |- p
  146.   */0 ]# W* {9 t) F, _
  147.   ! @! g1 `1 q) n& t2 w( N9 Y
  148. /**) I3 O  t! `' @. f
  149.   * @}% O2 W* {- v5 O6 N9 k  q7 @
  150.   */
    5 u! E9 m- ?! e% E3 n+ z

  151. ! |+ c: D# x3 |" o' t- ]. I6 M+ k: _
  152. /**
    : v; [4 s& {3 O0 W2 [% `  i" N
  153.   * @}$ B5 P' G! E) [/ i% g9 o
  154.   */2 [2 ?" R$ E1 ^" h

  155. 8 ]1 W* F: O" V1 u$ C# o! H" V( Q
  156. #endif /* __STATEMACHINECLASS_H */
    6 K7 E, q6 I1 r8 ~" g

  157. 9 C/ z' l3 w' ^) X) d1 N
  158. /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/8 Q# g5 F+ \; F( x; X9 d' k& g
复制代码
1 T. C5 ~* G& T! k& n- f
状态机看这个图: 状态机.jpg
) C: e4 f* d7 m# X  s3 C% D+ s6 i, |( W& y2 {! t
) Q" R; u. d& ?
/ U1 t3 r6 A- R" H$ g  S: d+ z
努力的人 回答时间:2017-8-28 13:57:18
本帖最后由 努力的人 于 2017-8-28 15:19 编辑
$ h8 n% e" j, T+ a) ^. P
! J' }" n7 m9 R: \8 F2 R% t二、TASK1 5s转动、5s停止       
  \6 Z, h5 J8 ^; v% @

% \' M3 G: g$ v    首先上传一下源代码,因为systick的500us的定时与SDK中一些任务的处理速度相关,这里我觉得还是不要修改定时时间比较好,我的代码如下:
! \3 e8 J2 N& w, d1 \说明:在main.c中定义uint16_t mytime; 在stm32f30x_it.c中定义extern uint16_t mytime;5S就是10000*500us,所以就可以转5S停5S了0 e! R3 \! O; B( d$ d
  1. //TASK1 源码
    9 b( \! K! J& w: T$ D4 F
  2. /////main.c//////////////
    * b5 i' p  h1 y1 k9 S" J) l% M
  3. uint16_t mytime;* L2 E3 T4 ]/ f
  4.   while(1)& ~! J, ?9 N7 T6 O2 K/ M! o
  5.   { " L  I( [/ e# X
  6.                 if(mytime==0)
    + R$ |/ l, z8 v9 e3 u9 x- ?( r. \
  7.                 {
    5 i$ r$ {5 G/ f
  8.                         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);4 `9 v0 e4 V  j+ G. u6 v5 n
  9.                         MCI_StartMotor(oMCI[0]);" \1 Y$ F! ]- a% l6 Q8 H0 D- X
  10.                 }/ W8 ]( e# p$ m1 ?* `4 c8 u
  11.                 if(mytime==10000)
    ( ]0 r3 E9 n; D2 K% X
  12.                 {
    . p3 Z6 i! ]3 h+ s! v: X
  13.                         MCI_StopMotor(oMCI[0]);) ]' m; Y% p* u1 q8 \
  14.                 }" @1 _1 \4 g1 T- A

  15. : ~8 L) v7 Q( ?2 O  w" V$ Z+ [$ z9 d
  16.    
    6 W" S8 n& I5 C. u7 ]+ k$ l
  17.   }
    * R: z' K  S/ n/ r6 ?0 ^
  18. //stm32f30x_it.c
    " L6 M! B0 }+ U; {/ C& s! ^
  19. extern uint16_t mytime;
    7 a/ p/ \3 l3 |/ D' a! }1 L
  20. void SysTick_Handler(void)4 |8 |& v& n0 I0 [$ k* I" H7 c5 q
  21. {
    * j# m/ j" h" e: y# d
  22.   TB_Scheduler();8 @. p7 o5 [5 @( |2 M3 r  W
  23.         mytime++;3 G7 O) s: i5 |; o" ?+ F5 h- U
  24.         if(mytime == 20000)7 b2 X" F4 Q7 Z. D3 Z5 F) ^4 ]
  25.         {mytime=0;}2 A! T( `3 I+ v+ K" `
  26. }
复制代码

2 U* _5 q/ Q2 O, u) j视频:
* f/ o5 z2 }. @+ L
( k; F! a  R, v# @7 d) c- t5 N6 [8 C& n2 G
' Z: a, \8 w; P% Z8 \5 h0 B  K+ s
努力的人 回答时间:2017-8-28 13:57:36
本帖最后由 努力的人 于 2017-8-28 14:36 编辑
! q0 a4 ]" e% C) L; ~5 W" b
- T3 S! ?( K3 \  V* f三、TASK2 PID参数的调试
6 V' z4 a' }# _# r  A% S  l8 c  E; F    任务2的代码如下:
0 H; `- P0 s& p7 g/ U
  1. //TASK2源码
    , Z+ \% V6 b  U
  2.         static int16_t Speed_Kp,Speed_Ki;
    # t- d# s' B9 w& s! r
  3.         static CPI oPItuning;
    * U: U5 [2 f0 R7 B/ V
  4.         oPItuning = MCT_GetSpeedLoopPID(oMCT[0]); // ????PID???
    6 q: t) p. k: ]8 _, B
  5.         Speed_Kp = PI_GetKP(oPItuning); // ????PID??
    9 g8 c2 V) K, h- Z- d! A
  6.         Speed_Ki = PI_GetKI(oPItuning);/ X$ c6 e# w# u; K9 Z
  7.         PI_SetKP(oPItuning,Speed_Kp); // ??PID??- \7 f* h  t8 w# l# J
  8.         PI_SetKI(oPItuning,Speed_Ki);
复制代码
这里我们首先看一下原始PID参数的速度曲线,从图中我们可以看出转速的超调比较大,已经达到4000多转
0 a( X4 C; C3 t9 |' Q/ X1 P6 y1 o 原始PID.jpg    原来的PID参数.jpg ( C! j3 H( O/ I8 m! r4 a" V  m
接着我们修改程序,将程序设成2倍的PI参数(左图)和0.5倍的PI参数(右图)$ ^" b' x" y! N( B; n0 E. r
2倍PID参数.jpg    0.5倍PID参数.jpg
# ~& v0 \( ~# E* H; J! i; A) T! R从图中可以看出,增大倍数的PID参数比减小的好,所以我们接下来将PI参数往大了调,分别作了2.2倍,2.5倍,2.9倍的速度曲线图' n& G# K! R+ y  z& e  ?
2.2倍PID参数.jpg
( T5 T( E2 ?  N- E& f' m 2.5倍PID参数.jpg
+ M) |" i6 v8 ~) B3 O1 } 2.9倍PID参数.jpg
3 ?. f4 v; V( H我们还想让超调小一点,所以我减小了一点P参数,最终得到这个速度曲线,我们通过上位机可以看到调完的参数,最后将程序中默认的PID参数改成我们自己的。
# d) b" u- ]# Q' e9 M( a1 J- g  o 最终确定的PID参数.jpg   2 ~% E8 @3 D8 j- V
程序最终PID.jpg
努力的人 回答时间:2017-8-28 13:58:15
开放性试验
反派小智 回答时间:2017-8-28 18:03:16
学习了,谢谢分享
epochal 回答时间:2017-8-29 06:51:01
学习!!!
携手未来 回答时间:2017-8-29 09:17:54
看看,学习下。
哈哈先生105 回答时间:2017-8-29 21:38:06
厉害
donatello1996 回答时间:2017-8-30 20:53:20
看了楼主的帖子学到了不少东西
努力的人 回答时间:2017-8-30 21:24:28
donatello1996 发表于 2017-8-30 20:53
8 }; k/ L, F% Q  N& k8 f看了楼主的帖子学到了不少东西

* s: P* w% E+ {这就是互相分享的意义呀
donatello1996 回答时间:2017-8-30 23:35:37
努力的人 发表于 2017-8-30 21:24- s2 i, H, l- n+ i+ n
这就是互相分享的意义呀

' l# v2 Y) D1 _, s  ?- H6 p* `对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊?
futuresir 回答时间:2017-9-4 09:12:18
学习了
futuresir 回答时间:2017-10-7 15:53:01
xiexiefxiang
1234下一页
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版