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

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

[复制链接]
努力的人 发布时间:2017-8-28 13:56
相关阅读:# U- a$ V5 V" q1 Z  Q5 M! c
电机培训 - 三个任务主函数及中断程序- ~, T7 A6 D6 m. B3 ~6 |
电机培训 - 让你可以深入研究的PMSM/BLDC文档* _9 m; g" ~( ^! A2 D9 S8 \. e
  W' s! h; h1 W
PS:如果大家觉得帖子还可以的话,请到社区之星评选为我投出你宝贵的一票谢谢
点击进入投票
1 F! M- I  U- i很高兴参加了ST的电机控制培训,先上几张图,我也悄悄地在提问窗口回复了坛友的问题
1.jpg
# c9 n5 v$ a$ ^. ?& X6 g

( ^! D* O6 [1 L3 M+ f. I3 b 2.jpg
1 p5 D4 a0 O/ j) P" W5 R+ I% m! N
ST研讨会.jpg
: D7 h: R2 e. l: b. L0 c% r5 C2 o/ D下面开始步入正题吧!我的主函数程序下载 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
; v  G- k! I, ?: P4 Q$ v1 _8 K对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊? ...
, ]. B3 e2 ~# @$ g
1.jpg
5 v. r' g. F6 V+ s母线电压是ADC采样的. c( ?1 N% C3 L1 Q- m. b
所有的函数都在这里,你自己查 STM32 FOC PMSM FW library developer Help file.chm (1.14 MB, 下载次数: 78)
努力的人 回答时间:2017-8-28 13:58:01
本帖最后由 努力的人 于 2017-8-28 15:07 编辑 - B1 O. _+ c! @( ^* X

( N3 R! n( \6 X, C' \1 K: D5 yTASK3
7 N  K9 m* T6 {( i8 X- L% L    首先还是上传一下源码9 l% K! K. x$ ~' L- r% }
  1. //TASK3 源码
    0 _2 F) l7 O/ ]7 h! C) m1 y- Q
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);% S3 w% J5 t) O4 {* Q7 s' s
  3.         MCI_StartMotor(oMCI[0]);
    ) B9 }* _( X  r4 {4 m
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);
    # v* g6 S) h+ x. B" U4 ]% x
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);" D2 V0 }+ K" Q- b  \9 h, [( t
  6.         //STM_NextState(oSTM,STOP_IDLE);
    : O+ `, R  w7 L! c8 H
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );
    % l9 h! }% M8 \7 w
  8.         while(1)& n& D9 w' @9 i' Q+ D/ Q
  9.           {9 i( V$ _' r2 f' |& ~7 `: y8 ?) I
  10.                 3 s5 n" O) W8 j* H: J
  11.                 - I* A8 v, i: y! A& j2 `: X
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);- V) o* j# S! g9 _( ?8 e" s
  13.         if(Fault_Type == MC_SPEED_FDBK)
    # p# B% [/ D6 K4 w4 R
  14.         {+ L2 o* F& u! V. i' B! R" s
  15.                 //MCI_FaultAcknowledged(oMCI[0]);
    0 s& E) R2 m! [: M2 i& @
  16.                 //MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);  ?7 W. ]) p% a9 p0 N+ F. q
  17.                 //MCI_StartMotor(oMCI[0]);
    1 _8 k& [9 d& q, `
  18.         }
复制代码
将程序写好后,下载到板子中,我们可以看到致故障的上位机界面
8 h' @' A! f! i  F+ C3 z& { 致故障.jpg
* M  Q# @5 ^$ F6 s然后我们将下面的代码下进板子中
7 K0 L; ]# q6 f
  1. //TASK3 源码
    . r/ \% F2 ^: [
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);9 \, C9 x8 X; h' g
  3.         MCI_StartMotor(oMCI[0]);
    / h. M, F9 P6 I. N
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);
    # {8 A/ ]9 n. M. Y6 ^  B% w! R
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);, G) _4 J1 v- j" i9 b6 q
  6.         //STM_NextState(oSTM,STOP_IDLE);
    " R% B5 H$ H$ H8 p
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );
    5 j  K7 Y$ ^% |  E9 Z
  8.         while(1)
      Q. J, Z% d' _  b
  9.           {* N& E" j* [0 W* q, Q& z
  10.                 0 S4 z% k+ B: F0 [# m  N' u
  11.                
    * [, }/ K% h* P' P- B- E
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);
    9 o# U1 j, Q' z( e$ _' x
  13.         if(Fault_Type == MC_SPEED_FDBK)# }9 Z5 i: _0 B% l# Y+ P
  14.         {/ R  l# ]8 P# j7 _9 ]5 E5 J& u
  15.                 MCI_FaultAcknowledged(oMCI[0]);" U) `' g; ^* a1 ?  A& u- W
  16.                 MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);
    / C  l* n& b( s8 ~$ y3 C" a
  17.                 MCI_StartMotor(oMCI[0]);
    ! G1 n% V8 ?8 d0 j3 t$ ^
  18.         }
复制代码
可以发现电机正常反转。
) a9 i3 D% V* B( @关于故障代码可以参考: 故障代码查询.jpg
- ?+ q7 n1 X# E) z关于至状态机故障和清除故障的程序,大家参考StateMachineClass.h9 s/ m- a$ q, p4 ]7 e
  1. /**; F: S8 W: ~8 L2 Y
  2.   ******************************************************************************. R9 T) C3 j& o
  3.   * @file    StateMachineClass.h
    . y# F' x' g6 N' e9 `9 A
  4.   * @author  STMicroelectronics - System Lab - MC Team; x8 ?, `$ ~6 M: }/ V; a
  5.   * @version 4.3.0
    + e5 `! @5 }" E: P) `+ A9 U9 W
  6.   * @date    22-Sep-2016 15:290 V9 Y& Z6 n0 O/ Z! M
  7.   * @brief   This file contains interface of StateMachine class      
    8 \% j) x6 M& V) B( B: I
  8.   ******************************************************************************0 E. r4 a7 C9 t" A1 I
  9.   * @attention/ a2 }# _, y( K; x5 m
  10.   *
      |! V" O: r( h, h% r2 l) @
  11.   * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>
    1 I- K5 |1 `: W- `: e4 v
  12.   *
    5 t8 n% z+ _- V& Q2 L
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");2 ~" X0 R: m* O& `! N
  14.   * You may not use this file except in compliance with the License.
    " f8 M& R/ D- N7 q
  15.   * You may obtain a copy of the License at:% t: e" }+ @6 |. E
  16.   *
    ) Q& B  g6 b+ L5 O# z/ C
  17.   *        http://www.st.com/software_license_agreement_liberty_v25 u( n& n# ?4 g
  18.   *9 L/ {5 I7 R' p
  19.   * Unless required by applicable law or agreed to in writing, software
    5 n1 @# c% Y5 M& D0 M+ w8 _
  20.   * distributed under the License is distributed on an "AS IS" BASIS,
    7 |2 f! e/ o! f+ S1 i
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied./ R- K3 d( c# K0 N. }* K+ ^
  22.   * See the License for the specific language governing permissions and
    4 V5 ]# @8 w2 e3 j
  23.   * limitations under the License.6 s# `9 u) I3 B8 {2 `# r1 \
  24.   *
    ' ?) d9 c! t& d! ~) I
  25.   ******************************************************************************
    # Z  H+ q9 g5 i: J
  26.   */1 o$ |, x( |1 A

  27. ! J; p1 N3 W; T" k
  28. /* Define to prevent recursive inclusion -------------------------------------*/. ^5 I$ Y' F9 e
  29. #ifndef __STATEMACHINECLASS_H0 Y8 u! K  w/ f) ~2 x3 e
  30. #define __STATEMACHINECLASS_H
    + [0 e. z0 ~7 D6 b. s3 R# n" l

  31. & u4 K$ S% p' j- |
  32. /* Includes ------------------------------------------------------------------*/
    ; ^! x: a" V* ?1 m/ t- h
  33. #include "MC_type.h"
    ' T+ y; ], n0 j9 j) r

  34. 6 Z+ D' C, m* Q# t# ^& y
  35. /** @addtogroup STM32_PMSM_MC_Library
    # \7 d9 P4 p) w, j1 `' H" ]3 @2 w
  36.   * @{
    ; I$ K1 j, n5 {! A8 `1 p
  37.   */6 D5 n! f1 k, u+ A
  38. 0 b/ N9 x, k. e* l" k
  39. /** @addtogroup StateMachine: W  T+ T* Z1 q3 P- N
  40.   * @{
    5 x! ]. h: T4 ^9 r1 {0 ~6 j' _* p9 l
  41.   */
    7 d5 M3 h+ T( Z$ f% o+ q
  42. 4 P5 x- W, h0 B; d
  43. /** @defgroup StateMachine_class_exported_constants StateMachine class exported constants
    # o# Q0 a# [% u( f
  44.   * @{
    3 Q5 o2 l9 L1 X% h) [$ T. A- L
  45.   */
    ) f3 a9 e8 b, s4 k5 L  P$ o
  46. ) o, ^+ L# s1 v
  47. & P; {, c# J1 L% x7 `( t
  48. /**. r% \* d* B- A4 m2 H: I; R5 L
  49. * @}
    $ a8 d- M2 b6 N: ?1 s& s
  50. */; x! Q# k0 a, }4 E

  51. ; N& l+ |1 X, g) P5 Y
  52. /** @defgroup StateMachine_class_exported_types StateMachine class exported types
    9 ?: f& n4 J, k' H+ F  i/ ~
  53. * @{
    + e4 [1 I2 F7 s3 y% ^
  54. */
    % M8 j* @. m1 S' v2 Q- n  w
  55. 7 k# e$ k3 a* d( a9 c( R
  56. # `4 Y1 ~, @" A9 S6 ~- L6 F
  57. /** % }* Y6 ~0 ]& F9 p0 h( T; @  p, k
  58.   * @brief  Public StateMachine class definition
    ' g! S7 M  y0 D9 e# M  P" {" N' ]
  59.   */- s* q8 m. ]6 {" @- m
  60. typedef struct CSTM_t *CSTM;
    7 k7 c! K0 Z  u4 c' C" E1 b) E

  61. + w. T+ b4 e' n! t7 L
  62. /**
    ; {2 A' V$ N. |
  63. * @}
    : u! [/ H) H6 O$ \
  64. */
    + P$ V8 U' q+ O; Q9 `+ t
  65. 7 A4 ^" H: N4 Y$ R: k; m5 d
  66. /** @defgroup StateMachine_class_exported_methods StateMachine class exported methods6 s) [* R$ D8 d. z6 k
  67.   * @{1 I  [. k. q8 n$ R
  68.   */
    : |1 P' c: a) z3 x0 \' Y
  69. 7 u  J- q8 {# H1 m3 L8 G
  70. /**# u/ _* Q7 F5 c& b" q# ^
  71.   * @brief  Creates an object of the class StateMachine.; [( H! \* \  J5 z+ e3 t
  72.   * @param pStateMachineParams pointer to a StateMachine parameters structure.
    2 z7 h; K' p/ \
  73.   * @retval CSTM new instance of StateMachine object.
    4 U; `7 r4 w  m# R- r) Z/ d
  74.   */8 A6 k# h4 z" Q6 Y% r3 p( C
  75. CSTM STM_NewObject(void);& C2 ~; `9 O/ B0 d7 c+ L, |8 }

  76. 1 B9 O0 p( \. h* o" R4 {- ^
  77. /**
    : K, R& o) r6 x* r! K7 G
  78.   * @brief  Initializes all the object variables, usually it has to be called
    . q0 z3 P% t7 a) a4 m
  79.   *         once right after object creation.2 Y* u% G% L' d% t
  80.   * @param this related object of class CSTM.
    7 x' [- ~6 [8 R
  81.   * @retval none.
    " [( z5 _5 o/ J9 [  B% D8 W
  82.   */  ?9 p# c! T% M3 _
  83. void STM_Init(CSTM this);
    * _5 x1 ]% I5 k% ^2 c

  84. ' Z* e6 a6 M3 _& B# I
  85. /**. F5 n' @0 O& |- C
  86.   * @brief It submits the request for moving the state machine into the state
    # d$ y% C3 _6 Z4 F* E0 l* }
  87.   *        specified by bState (FAULT_NOW and FAUL_OVER are not handled by this 0 k* T" P) W0 T' j4 o
  88.   *        method). Accordingly with the current state, the command is really
    3 B$ ^, F8 j/ v2 z
  89.   *        executed (state machine set to bState) or discarded (no
    + \0 u' Q9 @% p
  90.   *        state changes)
    - n; C, O$ W' Y3 I. e9 y, ?5 ?" a
  91.   * @param this related object of class CSTM.3 |" B, f9 F0 b) G/ I6 i4 O! [7 Y
  92.   * @param bState New requested state
    - t5 g6 u: s, j4 m3 R9 Y
  93.   * @retval bool It returns TRUE if the state has been really set equal to . V. v% Y- R6 X1 P% C
  94.   *              bState, FALSE if the request has been discarded$ d/ j( g" Q9 U/ Q0 ?4 f
  95.   */
    ! c( n5 N7 H8 o. S# j
  96. bool STM_NextState(CSTM this, State_t bState);
    : M+ f, X' R4 C9 ?7 F* V

  97. & t8 j6 g, N* e/ `
  98. /**3 [& z7 ^! T# X( y  w. W
  99.   * @brief It clocks both HW and SW faults processing and update the state ; b$ a; L9 S5 h! c' `
  100.   *        machine accordingly with hSetErrors, hResetErrors and present state. / Q  E2 v$ V% q' R5 t3 N
  101.   *        Refer to State_t description for more information about fault states.
    ; g3 K& I& z7 \9 T
  102.   * @param this object of class CSTM! g7 q9 \+ K; R  {* d' m4 C6 Z: ]
  103.   * @param hSetErrors Bit field reporting faults currently present
    ) V8 |- X# D/ k/ i
  104.   * @param hResetErrors Bit field reporting faults to be cleared. Q9 `8 N$ H' T
  105.   * @retval State_t New state machine state after fault processing
      X: c' ]; N6 z  t9 o* J
  106.   */
    0 j* k7 O# |2 C! b9 R( T) ^
  107. State_t STM_FaultProcessing(CSTM this, uint16_t hSetErrors, uint16_t
      C& Z/ `: b/ K8 V; H) Q
  108.                                                                   hResetErrors);
    " Y% p. {  K& L: h
  109. % G/ F( Y" \8 e
  110. /**) }! |( p3 S) ^1 I. T8 }
  111.   * @brief  Returns the current state machine state
    0 Q& b2 C) x: F1 y2 s4 F$ P( |
  112.   * @param  this object of class CSTM4 l# [) j7 B2 X! u5 P+ y! ?, u
  113.   * @retval State_t Current state machine state% c+ Y; a/ g# @
  114.   */
    " W, \9 r% k, I, N6 t5 `
  115. State_t STM_GetState(CSTM this);9 Z; i3 e* M* f2 S
  116. 0 O  x& j- ^4 A
  117. /**
    # [/ P: p& c/ p" N! E, [' N
  118.   * @brief It reports to the state machine that the fault state has been 1 A; R9 y3 q# _  n, g9 \
  119.   *        acknowledged by the user. If the state machine is in FAULT_OVER state
    * J) P6 X) h$ d: e% y9 p
  120.   *        then it is moved into STOP_IDLE and the bit field variable containing ; m2 m3 c2 {; D9 V/ M. k3 d
  121.   *        information about the faults historically occured is cleared. ; K: n. |: q0 N. [
  122.   *        The method call is discarded if the state machine is not in FAULT_OVER
    * x* c' T# B( f1 _7 {
  123.   * @param this object of class CSTM9 V! Y9 [  [( W' A
  124.   * @retval bool TRUE if the state machine has been moved to IDLE, FALSE if the
    $ Y+ l' N1 L3 M4 V' ?/ {
  125.   *        method call had no effects # s# O2 a5 N& e% d# r
  126.   */
    2 r. C* U$ o, Z4 d
  127. bool STM_FaultAcknowledged(CSTM this);) R; N' T5 c( E+ \8 ]' L# h" C
  128. 4 \8 f. ~+ K, E% C% w( Z: Y+ E! U6 G
  129. /**1 \; |. B2 D& Z! j; K) t! [
  130.   * @brief It returns two 16 bit fields containing information about both faults5 e' v; i$ f( U* h' Z: j
  131.   *        currently present and faults historically occurred since the state ; f1 g0 C- y7 M9 s1 o
  132.   *        machine has been moved into state( b) F: [& J% Z/ ~# e
  133.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    ; x! O8 v# S- A* J. z
  134.   * @param this object of class CSTM.9 v6 ], D* d' @  n
  135.   * @retval uint32_t  Two 16 bit fields: in the most significant half are stored6 A7 b6 n# Z# _. q8 v/ x
  136.   *         the information about currently present faults. In the least 5 }5 C  u: |( o  K% \' F
  137.   *         significant half are stored the information about the faults
    8 c- j. ?" r& i( v8 v
  138.   *         historically occurred since the state machine has been moved into 8 j1 `1 ~- Z* v* a" h
  139.   *         FAULT_NOW state7 g2 M) X( _; y" D6 W
  140.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink$ _& G, q7 j8 s5 ?' F
  141.   */
    ! g& [! `1 I  R7 L, l
  142. uint32_t STM_GetFaultState(CSTM this);
    4 H) a/ y* }& x# |5 i, I" g
  143. " c: e4 A5 W* q6 _) _1 \9 Q( H1 P
  144. /**3 e5 f- K- h4 y; J6 i9 X
  145.   * @}! o* N) r0 M  j- }4 ~
  146.   */4 U, a. j2 s( G8 O$ x
  147.   0 ?( q+ P" {, N
  148. /**
    # c- f& K0 `/ E+ X$ G" ?0 R
  149.   * @}$ o" g2 i1 Q- _% N, x0 P( Z" U
  150.   */+ c6 {- W6 a2 ~5 K3 Q

  151. / p" n" t+ M3 |7 \0 O1 X* T- I
  152. /**
    0 D5 O; D  [/ k. G" V. F; q& B
  153.   * @}% S5 K" F7 c9 D( m- v
  154.   */+ V. Z) U: [9 r' j: z

  155. " p  ]7 |0 d+ [' Q0 Q
  156. #endif /* __STATEMACHINECLASS_H */
    ; u: f, B+ r: n3 e: T- `

  157. 5 m8 L  h  h% T, a7 {
  158. /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/, e) \- w% O3 ^1 \) g% d: \
复制代码
* ?) f/ B- o& N3 N! `- @- t
状态机看这个图: 状态机.jpg
7 ^9 {+ X/ r6 j: u4 {! Y" Y: b
; c% W9 m2 J9 ~& F, G7 ~
( }0 c/ Q/ }. f! u, K# F- G
1 [" k3 s; h# L; Z" ~8 P! [
努力的人 回答时间:2017-8-28 13:57:18
本帖最后由 努力的人 于 2017-8-28 15:19 编辑
- J5 ?% j/ q" u& |- O4 h2 V' Z2 f# q) x$ l2 R8 h! u
二、TASK1 5s转动、5s停止       
8 N( I0 _. u: x" {

, B) l. h/ `! i% f" |    首先上传一下源代码,因为systick的500us的定时与SDK中一些任务的处理速度相关,这里我觉得还是不要修改定时时间比较好,我的代码如下:& J3 o/ t5 n4 c
说明:在main.c中定义uint16_t mytime; 在stm32f30x_it.c中定义extern uint16_t mytime;5S就是10000*500us,所以就可以转5S停5S了* P" Z1 K1 S6 s' k0 s
  1. //TASK1 源码
    * C# O. s# }' s4 L
  2. /////main.c//////////////6 {6 s1 N; [/ ?# C0 E- y) m
  3. uint16_t mytime;. w9 o5 q# P* |6 Y; h+ N
  4.   while(1)
    " G# ]+ `/ \1 \# ?( ]. v
  5.   {
    , ?' [+ h4 L  P1 F
  6.                 if(mytime==0); e" V( [1 U1 p$ x+ D
  7.                 {
    ' a* F9 x1 L$ I3 a* A2 o5 I
  8.                         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);  V/ J& C5 A2 O$ L; H
  9.                         MCI_StartMotor(oMCI[0]);
    7 C' G# G- K, {% D" ?' p+ A
  10.                 }
    0 ]0 s. O4 m, G, y
  11.                 if(mytime==10000)4 B1 r& n: z! T, r
  12.                 {
    / ~% \3 e0 `' Y7 d5 F# ^- e
  13.                         MCI_StopMotor(oMCI[0]);
    6 m8 K: _( P, M2 e- k
  14.                 }9 p# D) y. K8 e

  15. / P, S' v% ^- }5 `5 _( j. {$ Q; u
  16.    
    7 D# ]& ]$ F/ x: Z- t. B2 f1 w
  17.   }
    ) _: _. |3 p6 B1 h
  18. //stm32f30x_it.c
      h/ U9 X) d5 {: P% m
  19. extern uint16_t mytime;7 `+ D, p" B% b# c, p1 \& ]
  20. void SysTick_Handler(void)
    , r+ v6 D7 z$ [, A
  21. {
    / q7 U3 q) Y% u% v' t& L, ?) b* a
  22.   TB_Scheduler();
    ' h7 w& l# F9 q+ a5 ~. B
  23.         mytime++;- R+ Z& F$ y& |: C" K4 e
  24.         if(mytime == 20000)9 ]+ V2 @) O8 u- b9 ~- `; |
  25.         {mytime=0;}, M7 v* h1 k9 t# s# b' M
  26. }
复制代码

6 H! w" ^; l8 R$ l, E! [7 r视频:9 a" U/ C6 |" Z5 t, v( p
. B; ?: U; b/ ~- u. S" F  Y1 q

  y5 `* E. s! t1 o: Y9 Q5 B; L) v$ z* A  k5 S0 H2 e5 g
努力的人 回答时间:2017-8-28 13:57:36
本帖最后由 努力的人 于 2017-8-28 14:36 编辑 2 c2 {" N  [$ u$ W  z! f5 T

8 P: h5 o- l9 X) R' f三、TASK2 PID参数的调试  L' p7 e* Z) I5 t% p, G
    任务2的代码如下:
) |3 r8 U& B% K  v8 H2 D
  1. //TASK2源码' o3 y) |( i0 P# W* |" [
  2.         static int16_t Speed_Kp,Speed_Ki;
    0 ?9 R4 J( m6 x) Q
  3.         static CPI oPItuning;  m$ ]: r+ @- x, m; U- j
  4.         oPItuning = MCT_GetSpeedLoopPID(oMCT[0]); // ????PID???
    6 U' l; T) w7 b
  5.         Speed_Kp = PI_GetKP(oPItuning); // ????PID??% M& q3 k) k9 [# `* V' ]
  6.         Speed_Ki = PI_GetKI(oPItuning);
    & d! E' o7 A* S
  7.         PI_SetKP(oPItuning,Speed_Kp); // ??PID??
    $ w- J* P6 v* H2 }: R3 K2 t- i
  8.         PI_SetKI(oPItuning,Speed_Ki);
复制代码
这里我们首先看一下原始PID参数的速度曲线,从图中我们可以看出转速的超调比较大,已经达到4000多转( U" F; t. \/ p9 V, M
原始PID.jpg    原来的PID参数.jpg 0 B7 h6 r' y8 _/ J/ L
接着我们修改程序,将程序设成2倍的PI参数(左图)和0.5倍的PI参数(右图)* ]+ Z6 A  @! }! y* z  }4 j
2倍PID参数.jpg    0.5倍PID参数.jpg ) ?% G7 \5 {) k1 e/ t
从图中可以看出,增大倍数的PID参数比减小的好,所以我们接下来将PI参数往大了调,分别作了2.2倍,2.5倍,2.9倍的速度曲线图
* r' ]+ @( `0 l% b8 v; W 2.2倍PID参数.jpg
! u! i! j0 p  R4 d4 W) j$ S$ f$ ^ 2.5倍PID参数.jpg # o* }, w) f' m3 J# ^  c
2.9倍PID参数.jpg
0 J9 t% f! J3 d0 y- ?我们还想让超调小一点,所以我减小了一点P参数,最终得到这个速度曲线,我们通过上位机可以看到调完的参数,最后将程序中默认的PID参数改成我们自己的。
5 [3 a" {8 J8 A+ z9 q# O& c" d 最终确定的PID参数.jpg   " \% f; T* r7 T& a; h
程序最终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. r  @% l, T8 F" E1 [
看了楼主的帖子学到了不少东西
+ l5 B) |1 s( Y
这就是互相分享的意义呀
donatello1996 回答时间:2017-8-30 23:35:37
努力的人 发表于 2017-8-30 21:24
: j* ]4 k  u  d5 o  S4 K5 u这就是互相分享的意义呀
8 {( U8 F6 J3 o# q  K6 Y
对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊?
futuresir 回答时间:2017-9-4 09:12:18
学习了
futuresir 回答时间:2017-10-7 15:53:01
xiexiefxiang
1234下一页

所属标签

相似分享

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版