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

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

[复制链接]
努力的人 发布时间:2017-8-28 13:56
相关阅读:
2 c$ X$ m0 `3 b, Z3 m) H+ D  }  e- J电机培训 - 三个任务主函数及中断程序
% S3 D8 [' |4 [/ a, J电机培训 - 让你可以深入研究的PMSM/BLDC文档
. D$ P* }' M4 N9 C) U5 X  A0 m7 l5 M) |' ]4 H" A. Q9 E" Z0 R. W  h
PS:如果大家觉得帖子还可以的话,请到社区之星评选为我投出你宝贵的一票谢谢
点击进入投票  B+ u6 X0 x3 r
很高兴参加了ST的电机控制培训,先上几张图,我也悄悄地在提问窗口回复了坛友的问题
1.jpg
5 g/ S' O! Y; @: |) \2 r) L8 X
; G$ M( X2 L$ d0 O/ {% L% g# r! s
2.jpg
! M6 P" `( F3 \3 c/ A0 R5 C9 C$ \4 f" ^7 t3 m3 X1 F7 \6 C# g
ST研讨会.jpg
1 }( c0 S; U6 y8 i# R' h下面开始步入正题吧!我的主函数程序下载 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) S9 h/ }- [. j1 l9 n
对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊? ...

. L( p8 T0 d% z* D! r  i 1.jpg
( D/ q5 g/ F1 B母线电压是ADC采样的
) k, L8 f( E7 f7 \+ I4 H7 v所有的函数都在这里,你自己查 STM32 FOC PMSM FW library developer Help file.chm (1.14 MB, 下载次数: 78)
努力的人 回答时间:2017-8-28 13:58:01
本帖最后由 努力的人 于 2017-8-28 15:07 编辑 / v$ N) z. T; p) V
3 i# z% S  w8 x9 E
TASK3
7 ~1 @. V' l& c* x: B/ c# t5 U    首先还是上传一下源码0 U# j0 E: s/ ?4 v% k
  1. //TASK3 源码
    : a% w/ T7 e6 L
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);
    # S& _7 b& o5 C5 [" V/ D6 f
  3.         MCI_StartMotor(oMCI[0]);% E3 m) U  y. d" X( N. k
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);
    . _7 Y* C5 V! D/ R( {( Z: O4 `2 e" z; n
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);8 N3 i9 n8 b4 z6 b2 E. ?# n
  6.         //STM_NextState(oSTM,STOP_IDLE);
    2 t- _- m& d0 U) P
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );( q! j" z: _6 E, i% T
  8.         while(1)
    ! `2 L2 `8 R* k
  9.           {+ [! y& r$ S+ ~( v
  10.                 1 [! v" X3 I: U  H
  11.                 9 A4 ~8 k0 d) u8 o
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);4 f! j" ?6 l6 I
  13.         if(Fault_Type == MC_SPEED_FDBK)
    + B6 y0 Q6 ~& }/ Z3 r
  14.         {7 D+ n6 |" `& f$ I6 I$ ~
  15.                 //MCI_FaultAcknowledged(oMCI[0]);4 @+ \5 D3 X% {- k5 E! d
  16.                 //MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);, i) m$ d2 u: K; B2 u
  17.                 //MCI_StartMotor(oMCI[0]);
    6 E9 ?, W: b" {% Q( i( E1 Q: ?
  18.         }
复制代码
将程序写好后,下载到板子中,我们可以看到致故障的上位机界面
. O" _. J: L4 Y) a! J2 z" E- B1 R 致故障.jpg
2 c, i' E+ B2 u0 \然后我们将下面的代码下进板子中
" D3 J* S* f$ Y8 Q# g* ?* X
  1. //TASK3 源码+ x1 a$ Z/ r& E/ p% x! s! x
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);
    / w$ O$ x* f+ _  b: b
  3.         MCI_StartMotor(oMCI[0]);0 b1 [% b: p8 k* o# O
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);9 v0 m$ s: m* }6 y5 l" i# s
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
    ) H# O, O2 o/ j/ y7 Q; w: a- h6 q8 c6 x
  6.         //STM_NextState(oSTM,STOP_IDLE);
    - m- _& w% P) J0 A6 k
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );1 m0 o' l/ M+ n' j, I2 Q4 {
  8.         while(1)7 H. M: S5 k- R" p& A5 _
  9.           {
    % [! c; x' l; Y% {+ z& q
  10.                 2 }$ F# J* h, c. y$ O% n( }, [, K% V
  11.                 ) }0 L( v/ l- R" o, p0 J
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);
    ! f, N9 f" S9 D& W) C% V
  13.         if(Fault_Type == MC_SPEED_FDBK)
    ' d( q% _* T) E7 E: T- L
  14.         {
    7 C& b8 @, I& f+ w2 L
  15.                 MCI_FaultAcknowledged(oMCI[0]);
    + \5 q( t6 s, \& a" P, S8 I& R
  16.                 MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);
    : t# A1 d# `" b: @; C
  17.                 MCI_StartMotor(oMCI[0]);3 u: V3 N9 b' s9 }7 M& e
  18.         }
复制代码
可以发现电机正常反转。
, I5 e3 \# Y& H6 J关于故障代码可以参考: 故障代码查询.jpg
, [3 s* u; p+ d* E. D7 K关于至状态机故障和清除故障的程序,大家参考StateMachineClass.h
+ F/ z+ v' w. H: C% y
  1. /**" _, D' y5 m: |2 u! g0 L0 m/ W$ M
  2.   ******************************************************************************
    0 ]+ @6 A0 C% j9 X5 ~, B
  3.   * @file    StateMachineClass.h
      W% e. a0 H) Z
  4.   * @author  STMicroelectronics - System Lab - MC Team
    ) n3 P3 ~: N/ g$ a
  5.   * @version 4.3.0
    ; n# H9 J: Z8 |  _0 q
  6.   * @date    22-Sep-2016 15:29
    5 m3 k" [/ {) A0 F% w* ^
  7.   * @brief   This file contains interface of StateMachine class      7 k+ ^& X, D& C' \& ~
  8.   ******************************************************************************
      E" q$ r' J" x; l# H2 t+ O6 `
  9.   * @attention3 K/ F; _: n2 [8 F' G8 y6 f
  10.   ** C5 T/ Y" ]" }1 U8 U
  11.   * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>2 ]  l' j3 S5 |
  12.   *# l0 S4 g# b. P8 i# u" j& G" a0 e
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");8 Y" {2 R4 T7 }+ C7 g
  14.   * You may not use this file except in compliance with the License.
    - V. F$ l9 z! Y- ^1 r8 O
  15.   * You may obtain a copy of the License at:: r9 a+ ]1 ^4 b1 F% y; w
  16.   *
    - Z' Q( v& W' K: z% n
  17.   *        http://www.st.com/software_license_agreement_liberty_v22 U3 O0 Q9 s0 E
  18.   *
    % C6 t& |; k. c( c7 k
  19.   * Unless required by applicable law or agreed to in writing, software 4 `2 r! X1 N* x/ F
  20.   * distributed under the License is distributed on an "AS IS" BASIS,
    * U) l$ M) \" R( L
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.& c  J3 h2 x7 q4 ^6 a7 ?* g
  22.   * See the License for the specific language governing permissions and5 i/ {& n- f9 I  O8 T0 Q" Q& T
  23.   * limitations under the License.: D* c4 L* J  `9 O  a2 e
  24.   *' d; K! c) p- t
  25.   ******************************************************************************
    & c  T6 M  x) O$ R/ Y
  26.   */  t* U6 ~9 o7 G9 t8 P) t4 Z& L/ [; T

  27. 8 y: |  w. l. W7 s0 w! u4 q! {
  28. /* Define to prevent recursive inclusion -------------------------------------*/
    , d! C) a- j! c* ^6 A  \- I" \
  29. #ifndef __STATEMACHINECLASS_H: H* h2 [# n4 k1 K
  30. #define __STATEMACHINECLASS_H9 C& [" ~* [  v3 J1 M% x
  31. & ]3 a. n+ r: m/ |! e
  32. /* Includes ------------------------------------------------------------------*/0 E% j0 p' d* F9 H3 w$ A
  33. #include "MC_type.h"
    " M+ P7 l# n# i* \4 z

  34. 3 ~) T! a" S9 j8 r9 c! U- x! ?+ e
  35. /** @addtogroup STM32_PMSM_MC_Library
    + p1 k! n3 C6 Y( _- ^& |
  36.   * @{
    / o+ N6 d6 ~- N- m+ v
  37.   */
    # @% ~  V! `, r) D  e9 {4 E! p
  38. 4 j8 G9 J! o  b+ N
  39. /** @addtogroup StateMachine! f  M! U8 N- \  @( d
  40.   * @{. U! l8 y1 b* e. a: t$ J0 l, J
  41.   */
    . C1 k6 M0 R! I" ?3 y8 `
  42. % N/ P# D# e, F* f7 Q
  43. /** @defgroup StateMachine_class_exported_constants StateMachine class exported constants
    ) \5 j% }- i# t7 m2 _+ m! n
  44.   * @{
    ' R/ N2 }5 b2 b8 X
  45.   */' m1 V3 _, z# K$ ?1 U4 J+ p

  46. ; \. i( f' Y% r3 O: m+ m

  47. - L% C9 O  [/ R
  48. /**
    4 B: U5 V- u+ g5 @) J, L1 t
  49. * @}& h" p5 d  [2 _! q1 T) S
  50. */
    $ Q- t' }, d7 p, w, c

  51. : s) b. S" }  P; q
  52. /** @defgroup StateMachine_class_exported_types StateMachine class exported types
    ' Y) _; Z* V1 g( {- C( Q
  53. * @{3 i/ L  l1 e- u* ?2 H
  54. */
    : p. ~( e0 c& {
  55. 1 e0 J4 i( u( a3 y) q3 R
  56. 7 R+ T' a6 N/ O1 O" q3 V
  57. /**
    6 z; f* ^5 ]1 r6 }- j5 A
  58.   * @brief  Public StateMachine class definition
    5 Y6 ]6 N7 ]" l" y
  59.   */- P! |; Y( p% b9 J6 M' ~
  60. typedef struct CSTM_t *CSTM;4 X1 Y. ?' _& `

  61. # N# J4 y3 f# k8 E
  62. /**
    . ~$ A8 l' V" |- E2 w0 v# J
  63. * @}
    5 B3 Q3 j: ?9 J# N& n
  64. */
    & ?- e  g( ?* f3 i2 w/ R
  65. + Z4 f5 ], Q( |, n( {9 x9 P
  66. /** @defgroup StateMachine_class_exported_methods StateMachine class exported methods
    * W" u8 C/ n& S$ L+ P
  67.   * @{
    6 W, Z% G) z- b' i
  68.   */  ~! A  q( S9 ]6 p

  69. + t$ D: e1 e- K6 ]4 d$ J; R
  70. /**1 Y, z; J) t' ]+ G$ `  G: u8 z0 q; d2 {
  71.   * @brief  Creates an object of the class StateMachine.
    6 d, v- g. i5 ^
  72.   * @param pStateMachineParams pointer to a StateMachine parameters structure.
    9 r! [4 |# [6 v  n
  73.   * @retval CSTM new instance of StateMachine object.
    # P5 P9 e# H% P) _( S, W9 Q; g+ q
  74.   */, w  U( U& U) ~& `  f: \
  75. CSTM STM_NewObject(void);
    % l, z! S1 ^" |3 _6 J" _" i

  76. * D" l0 u% U' t- [8 M2 W$ c# {/ r1 r
  77. /**
    * A$ L( @. @0 n
  78.   * @brief  Initializes all the object variables, usually it has to be called # F8 w8 M6 u) r, f% @
  79.   *         once right after object creation.
    ! G- u; z- n( N! w* w
  80.   * @param this related object of class CSTM.
    & X3 ?! o7 u) q; X% \1 x! x& L
  81.   * @retval none.4 \- G$ e+ t- e: `& e
  82.   */
    - v6 E/ d& k& Z+ H# m
  83. void STM_Init(CSTM this);& [" ?# `% @) E# Y* ~! }
  84. 1 Z; b) h! W4 I3 X) }
  85. /**
    - y8 ^- ?) u/ |& O
  86.   * @brief It submits the request for moving the state machine into the state
    7 k* T- ]4 K$ L  M/ M+ \0 h
  87.   *        specified by bState (FAULT_NOW and FAUL_OVER are not handled by this
    1 y" _3 `2 D( I7 l; h  t. M
  88.   *        method). Accordingly with the current state, the command is really
    . ~0 u  n0 A/ q; a0 t
  89.   *        executed (state machine set to bState) or discarded (no
    5 Z3 m4 C% T3 M$ m, |, A
  90.   *        state changes)
    1 _+ x" \, {0 j3 K
  91.   * @param this related object of class CSTM.
    8 j& O' x5 a* I7 R: O3 L& T4 N
  92.   * @param bState New requested state( ~$ U$ t3 f" N' m! ?4 V% K
  93.   * @retval bool It returns TRUE if the state has been really set equal to
    8 f# h) L5 T& l
  94.   *              bState, FALSE if the request has been discarded
    2 l" {. X, i/ }* J7 A/ ^2 |
  95.   */
    3 U1 d, V; _# F- a! T1 g
  96. bool STM_NextState(CSTM this, State_t bState);
    9 ~- [/ k& }2 l" F3 M0 m+ P8 \
  97. # A# |! [# Q9 B# u+ Q2 y
  98. /**( P9 y2 q  w2 A: d
  99.   * @brief It clocks both HW and SW faults processing and update the state
    0 L/ k# p6 c; q; W. [
  100.   *        machine accordingly with hSetErrors, hResetErrors and present state.
    ; C/ o2 u1 \& u; r2 m& g9 Y
  101.   *        Refer to State_t description for more information about fault states.5 A0 b8 }, L; i* p3 G
  102.   * @param this object of class CSTM+ Y+ D! a7 U( [6 J4 X& b3 u
  103.   * @param hSetErrors Bit field reporting faults currently present
    , e& m& p3 ^( s& K& d
  104.   * @param hResetErrors Bit field reporting faults to be cleared
    4 V' S) v! a: l( F% l, ^
  105.   * @retval State_t New state machine state after fault processing
    ' }+ V, q0 t/ v% u- V
  106.   */
    0 y0 a+ k$ u* Q& }
  107. State_t STM_FaultProcessing(CSTM this, uint16_t hSetErrors, uint16_t 1 W0 H$ Z' `* {4 c' w& E/ j( ^
  108.                                                                   hResetErrors);
    3 @+ i: f4 P5 _9 A) t7 _8 q
  109. 7 h5 ^: x  {0 w# }5 G
  110. /**
    * W5 B) d* o9 y5 v6 X
  111.   * @brief  Returns the current state machine state
    0 e: A* d9 u; P" w$ d
  112.   * @param  this object of class CSTM* b5 N0 W' L4 o. D# z
  113.   * @retval State_t Current state machine state- |& Q: r( `5 D4 ]+ O2 {
  114.   */+ {" j4 J3 q/ U
  115. State_t STM_GetState(CSTM this);
    ' P0 _" t0 T- ~' U6 B  |
  116. 3 ?. v2 S( c, y. V6 }6 b2 j- Q# ^
  117. /**
    * n* C% j, d0 W1 D7 k  @: U+ n7 d
  118.   * @brief It reports to the state machine that the fault state has been / V! i, M( m2 _, N7 ]( O2 F* L
  119.   *        acknowledged by the user. If the state machine is in FAULT_OVER state0 H. e4 Q! e* K* ~" K' d$ B. ~8 j
  120.   *        then it is moved into STOP_IDLE and the bit field variable containing
    2 r* V+ o! X( }, i- T
  121.   *        information about the faults historically occured is cleared.
    0 b/ v( O8 o6 s5 z$ h# M1 ?5 X
  122.   *        The method call is discarded if the state machine is not in FAULT_OVER  \+ c/ p$ g& x% O! x
  123.   * @param this object of class CSTM# m2 {! `1 p7 U8 h! Q
  124.   * @retval bool TRUE if the state machine has been moved to IDLE, FALSE if the
    3 |! o) Y6 D7 Z" M8 `
  125.   *        method call had no effects
    ) l5 b4 U0 E6 B1 m& n4 m+ R
  126.   */
    / G- r* @. R) C- C
  127. bool STM_FaultAcknowledged(CSTM this);
    & N. @+ |2 g5 P# B( C3 m( [2 U
  128. / S' A3 ]1 R' M0 L' D9 c
  129. /**
    $ E* f: W2 K4 A$ h. h* B2 W
  130.   * @brief It returns two 16 bit fields containing information about both faults
    / P( r1 q, m4 X
  131.   *        currently present and faults historically occurred since the state
    $ h. O" y- m9 j# w) S$ f' V; l( j9 s
  132.   *        machine has been moved into state* F4 C! l# V" G  q: W; O
  133.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    ) i4 w& J6 J6 E( @
  134.   * @param this object of class CSTM.
    : {$ h- v. z9 T$ S$ o8 ~
  135.   * @retval uint32_t  Two 16 bit fields: in the most significant half are stored
    : h' F  P9 w- w% V; X+ f- M$ [
  136.   *         the information about currently present faults. In the least
    6 ~" s. j. |. ^! Z2 |) Z+ e/ A
  137.   *         significant half are stored the information about the faults
    $ G, @) T/ g- h5 Q  N/ S
  138.   *         historically occurred since the state machine has been moved into
    7 P9 a0 D/ z' Q- V
  139.   *         FAULT_NOW state4 w5 o+ [4 v+ t& W
  140.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    5 S$ P5 G* d' I/ v. y  v0 }+ k
  141.   */: g) I4 W% t0 w( Q+ e" a! k
  142. uint32_t STM_GetFaultState(CSTM this);
    , j+ f3 g7 v; {* Q2 m) e

  143. & b: r" J5 e1 F8 J  ^
  144. /**
    ) Y: Z+ C( n4 K
  145.   * @}
    2 Q/ `, a, c6 R9 J. H
  146.   */* N' m! V2 z- P" H$ s, r& Y. b
  147.   5 P4 _+ Z; p! q% Z7 z
  148. /**
    : `7 N0 C# r/ I3 c5 B
  149.   * @}
    1 D: \8 ?0 c4 r
  150.   */
    8 H) b) M/ r) A; |, u% G

  151. + }/ r, q( P* R# H6 t' E) H
  152. /**' h. l( Q1 N# B' x* I
  153.   * @}
    / T9 q# m; E' G+ I4 t1 M: V; p
  154.   */
    - O9 \) A7 Q6 P0 U5 I6 H
  155. 7 P+ p$ |1 T" }+ k
  156. #endif /* __STATEMACHINECLASS_H */- a$ O4 a, V/ G+ T$ {1 b

  157. " d$ d# Q: S9 ^/ v# v" e
  158. /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/( x  D: p( K9 F/ A
复制代码

: j1 y$ }7 [! n/ u状态机看这个图: 状态机.jpg 5 z! e$ Y# V; ]4 h
* A5 G; B+ B  x& Y  ]( g

( r. |2 _- O) Y0 Y4 z. G0 v7 ~) z+ n7 |/ m0 a& z& V# Y+ m
努力的人 回答时间:2017-8-28 13:57:18
本帖最后由 努力的人 于 2017-8-28 15:19 编辑
0 H! E' o# N9 t& F, s1 B, I8 L$ L" ^0 m) W
二、TASK1 5s转动、5s停止        - ]1 k0 u+ N% z" G; }! C

# v( @, S1 T/ a( {    首先上传一下源代码,因为systick的500us的定时与SDK中一些任务的处理速度相关,这里我觉得还是不要修改定时时间比较好,我的代码如下:
& o8 w7 Q; q- M' a说明:在main.c中定义uint16_t mytime; 在stm32f30x_it.c中定义extern uint16_t mytime;5S就是10000*500us,所以就可以转5S停5S了
0 p$ |  e; \5 G, {
  1. //TASK1 源码# V# k* p- ~$ e  J, T/ i+ g1 ?
  2. /////main.c//////////////
    ; x. {+ k' t" Q; a8 k. V
  3. uint16_t mytime;
    " @* T# F+ c. m
  4.   while(1), d7 w6 x/ g# t0 q5 x1 ^
  5.   {
    . a- T' r8 P+ |0 S
  6.                 if(mytime==0)( H9 ]- r2 ]% E( @' ^
  7.                 {* P" u/ u. \! G$ _
  8.                         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);" U9 c8 O. I& K3 u9 z  j
  9.                         MCI_StartMotor(oMCI[0]);
    $ a7 ]2 t5 S: U0 I7 o! b& v- B# ^
  10.                 }
    1 w, h; ~8 x: k
  11.                 if(mytime==10000)) z  @- w, x) u+ r* F
  12.                 {" q' w$ x6 [* ?: h7 Q! R
  13.                         MCI_StopMotor(oMCI[0]);
    / O% ^9 b; w8 p, E0 i$ Z& \- g& T
  14.                 }" f# ?7 f6 D! o! q/ T

  15. 7 E, x2 X. A8 `. d! X
  16.    * F6 l8 x0 N/ X) C% h. s. c0 C4 R
  17.   }
      x7 U9 N$ p" U  }6 x  E7 f
  18. //stm32f30x_it.c
    % ]# r/ j+ q- Y
  19. extern uint16_t mytime;! d8 w. e+ ~" o0 l# I
  20. void SysTick_Handler(void)) ?( G) ^# e. n4 }8 n
  21. {
    " @9 s8 g- ]5 B9 ]" V
  22.   TB_Scheduler();* i. I/ s5 }' r% s  ~6 c% Q
  23.         mytime++;
    4 l$ e6 _1 e7 p8 F5 g0 C7 m& B
  24.         if(mytime == 20000), g. |  }8 Y0 ^1 x) f: p* w% R7 `
  25.         {mytime=0;}
    9 G4 A7 j0 s" N. ]2 j2 ^8 G% p
  26. }
复制代码
* y* j+ _' U. F! o4 h8 l. o! Q& k1 {
视频:
# v- z' a0 F4 I8 ?- h3 u) ^, h
+ {+ B- D5 Z/ Z5 a. f0 G' m9 [/ }9 _- A* j, T, @
, J) q  q5 r6 a' _
努力的人 回答时间:2017-8-28 13:57:36
本帖最后由 努力的人 于 2017-8-28 14:36 编辑
* L4 x* v! B. i& g' h4 |/ \! T
6 Z4 T' O6 ?3 c$ }  I9 W2 L; G& v三、TASK2 PID参数的调试% O" V4 a* M3 F0 B0 M4 J& u
    任务2的代码如下:
0 j. Q$ S& l- Q9 G. p
  1. //TASK2源码
    $ R$ l) p- H0 [
  2.         static int16_t Speed_Kp,Speed_Ki;8 Q  q1 Q" |4 _
  3.         static CPI oPItuning;% h. D" q, E* u$ B3 b
  4.         oPItuning = MCT_GetSpeedLoopPID(oMCT[0]); // ????PID???
    # h" t( s, C- E
  5.         Speed_Kp = PI_GetKP(oPItuning); // ????PID??5 m* W% L' Q3 c/ F$ L$ S9 Q; q9 y9 n2 ?$ \
  6.         Speed_Ki = PI_GetKI(oPItuning);
    4 y8 D( u: L1 r7 o, l* n
  7.         PI_SetKP(oPItuning,Speed_Kp); // ??PID??
    8 k( ?  X6 u9 O1 Y; J, M
  8.         PI_SetKI(oPItuning,Speed_Ki);
复制代码
这里我们首先看一下原始PID参数的速度曲线,从图中我们可以看出转速的超调比较大,已经达到4000多转
$ @* c# |$ ^. b( ? 原始PID.jpg    原来的PID参数.jpg
) Q) h8 ^) @% }% F- \, T接着我们修改程序,将程序设成2倍的PI参数(左图)和0.5倍的PI参数(右图)
1 [7 [$ F+ J6 z! N 2倍PID参数.jpg    0.5倍PID参数.jpg ) e- Q& C9 b- E& w% [
从图中可以看出,增大倍数的PID参数比减小的好,所以我们接下来将PI参数往大了调,分别作了2.2倍,2.5倍,2.9倍的速度曲线图7 j5 @: H  o! g- H7 \3 k
2.2倍PID参数.jpg * f& u  k4 t% G. @5 H' a$ ]
2.5倍PID参数.jpg ( c, D. |9 s2 S0 k
2.9倍PID参数.jpg - C! H3 V! b5 V3 a" x' @1 C
我们还想让超调小一点,所以我减小了一点P参数,最终得到这个速度曲线,我们通过上位机可以看到调完的参数,最后将程序中默认的PID参数改成我们自己的。1 B2 t+ V8 Y+ @$ M4 l& ?+ O$ F( _
最终确定的PID参数.jpg   , l* O8 u4 O" B, K
程序最终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
! e( L6 x$ c1 Q看了楼主的帖子学到了不少东西
& K# N$ A- m$ `. ~) m9 F- \* ]6 F
这就是互相分享的意义呀
donatello1996 回答时间:2017-8-30 23:35:37
努力的人 发表于 2017-8-30 21:24
, P6 D8 V8 r% k& w/ l这就是互相分享的意义呀

9 }& m4 n5 U; {6 v8 V: b9 r, c对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊?
futuresir 回答时间:2017-9-4 09:12:18
学习了
futuresir 回答时间:2017-10-7 15:53:01
xiexiefxiang
1234下一页

所属标签

相似分享

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