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

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

[复制链接]
努力的人 发布时间:2017-8-28 13:56
相关阅读:
7 _% n3 d5 |! @& y* R( @电机培训 - 三个任务主函数及中断程序
* s! j7 e( J" h1 i3 @% k" B# }6 e电机培训 - 让你可以深入研究的PMSM/BLDC文档8 p% K' j" L( g' U
) O, f' x9 F' b& e, |, a% M
PS:如果大家觉得帖子还可以的话,请到社区之星评选为我投出你宝贵的一票谢谢
点击进入投票
+ S9 c; _4 O! [4 ]8 P1 J2 D很高兴参加了ST的电机控制培训,先上几张图,我也悄悄地在提问窗口回复了坛友的问题
1.jpg
% ?4 y/ X* ~8 {+ N4 D

0 A! a( [$ B8 F: s' s; X7 w2 m 2.jpg
$ p+ g! o  T* X5 ~, p
9 Q, T1 s5 g: D: ^ ST研讨会.jpg
0 v8 q' D+ R/ M下面开始步入正题吧!我的主函数程序下载 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:354 i1 G4 N1 i& ?% K6 Q) @7 e
对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊? ...
' ^  [2 D0 O' a. F! T. e  T; V  E
1.jpg : ?$ G/ u5 x/ o" B
母线电压是ADC采样的
1 S6 M( H3 i! u. a/ Q* c所有的函数都在这里,你自己查 STM32 FOC PMSM FW library developer Help file.chm (1.14 MB, 下载次数: 78)
努力的人 回答时间:2017-8-28 13:58:01
本帖最后由 努力的人 于 2017-8-28 15:07 编辑 % |) D' [" e; h5 c; {8 h% P

0 B; g# ~- J7 N& {TASK31 `; F' b0 H6 {7 u
    首先还是上传一下源码- X- o6 O9 O' g9 |, g) L+ _
  1. //TASK3 源码1 d5 S9 y- D" k4 y; ^
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);' T6 B) R/ l: z; T
  3.         MCI_StartMotor(oMCI[0]);
    ) {, U  t! U2 |. }: r: m3 _
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);0 c; q- [8 l% z8 p9 M: G
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
    - h/ @- p4 x  H5 E  M$ F! k6 @. k
  6.         //STM_NextState(oSTM,STOP_IDLE);, o! _# A+ B" ~( V
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );" |$ }! F' |- B' r
  8.         while(1)' K& d' r$ k/ V& Q" K. H
  9.           {
    3 t; Y" |$ ?! [+ V% g5 v
  10.                
    3 r! V* _; j; L! U) l. d2 L7 X& v
  11.                
    / \- h2 \! M/ Q$ l  [$ a
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);
    6 B1 o& t" g1 q" |: V& R6 F
  13.         if(Fault_Type == MC_SPEED_FDBK)
    ) i6 U# r. m- r! j+ v! }
  14.         {
    ' e# P4 Y3 b, R; Y3 I
  15.                 //MCI_FaultAcknowledged(oMCI[0]);2 T# s8 o: i; `& d% Q' e7 Q
  16.                 //MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);
    ( I& [* r4 z3 E: J$ h6 h/ A
  17.                 //MCI_StartMotor(oMCI[0]);
    , a: ]. C' z) M( J& d
  18.         }
复制代码
将程序写好后,下载到板子中,我们可以看到致故障的上位机界面
) X) h. i% S' k: M0 O 致故障.jpg   p' L! r" ?8 x) D; {
然后我们将下面的代码下进板子中
4 V6 X, {- |& q3 s0 F) p0 o. l
  1. //TASK3 源码
    0 n( Q( [5 a0 N: g7 T
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);
    ) Q9 l! J6 H! V/ r
  3.         MCI_StartMotor(oMCI[0]);1 [0 }* M: l- A- j
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);* M& H$ Y4 S+ q- O8 B
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
    7 F' E8 Y  f5 S9 Q6 ]9 q0 h
  6.         //STM_NextState(oSTM,STOP_IDLE);
      K7 J8 p; F% g% B, ?
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );5 ^1 e; |  E' N. k& M
  8.         while(1)  ?9 p# P( G% Y; p' d) c
  9.           {9 v7 i/ O; N, l/ K
  10.                
    - T7 V9 w( q  \, |
  11.                 ! h, f7 M- P1 [" j1 C9 u0 t
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);
    2 H8 X; a6 }" I  D5 S, s7 c% @; j8 D1 v
  13.         if(Fault_Type == MC_SPEED_FDBK)/ b6 l. m+ l0 Z! J5 G
  14.         {
    3 x* Y$ A' R* z+ [2 t+ U/ J
  15.                 MCI_FaultAcknowledged(oMCI[0]);+ h, n6 O/ t1 r" N! Y0 I' `9 q1 I  o
  16.                 MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);4 L' \1 I; I# F1 h
  17.                 MCI_StartMotor(oMCI[0]);
    1 K" g6 ^: D6 @
  18.         }
复制代码
可以发现电机正常反转。
7 n' u) m4 f8 W4 Y, |! l- o+ k% @8 |& k关于故障代码可以参考: 故障代码查询.jpg
2 U5 i8 K' Z; L& _* H关于至状态机故障和清除故障的程序,大家参考StateMachineClass.h, A% Z: a" U+ B/ R/ ]/ r
  1. /**2 e+ A& m0 k. i$ y( o5 v
  2.   ******************************************************************************+ D" p  |% T/ d# w0 Q7 p6 J
  3.   * @file    StateMachineClass.h, A2 J# U. L0 j
  4.   * @author  STMicroelectronics - System Lab - MC Team
    6 q( U$ N5 A: f
  5.   * @version 4.3.0, Z% X$ s6 F% U. @; I
  6.   * @date    22-Sep-2016 15:29  t  T2 a3 \5 ~
  7.   * @brief   This file contains interface of StateMachine class      
    . A0 q0 O* n( D( M0 p0 ~1 H: J
  8.   ******************************************************************************  B! l3 R8 F5 I! Q( B' E
  9.   * @attention
    $ O" n6 E! T5 q0 y! [
  10.   *
    6 M7 P7 F- ~: s' z9 y9 K+ v1 N. x
  11.   * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>9 d- X! `- v$ u  o2 K' C) ^
  12.   *3 |- s- z: o4 Z
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");2 {# G( O. }4 a- L3 k
  14.   * You may not use this file except in compliance with the License., C2 s: ?3 W, w  O6 x% I
  15.   * You may obtain a copy of the License at:
    1 t: Q( z5 K. J6 K8 ^
  16.   *
    3 e: }& o3 Z" H
  17.   *        http://www.st.com/software_license_agreement_liberty_v2
    % y+ ^; h1 M" x  P) P5 l
  18.   *0 _1 O$ p/ A& I  K. B# H
  19.   * Unless required by applicable law or agreed to in writing, software
    & z2 c6 h9 R/ e1 L
  20.   * distributed under the License is distributed on an "AS IS" BASIS, ' ~9 f1 p6 `) K" M
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.6 Q/ E& i# t, h4 b9 q
  22.   * See the License for the specific language governing permissions and" a  H1 J% t& O8 D9 z' F) ]
  23.   * limitations under the License.
    2 I) Y) `* c5 J5 }
  24.   *7 Q! y- P1 ], p" ~( T' U
  25.   ******************************************************************************$ N* T' Y. j6 u! S5 C! S; s/ @7 T! P+ p
  26.   */3 U& d$ K" T9 F# O+ E7 r  z
  27. ' i( p' {: B. e$ P
  28. /* Define to prevent recursive inclusion -------------------------------------*/
      R  p9 `& T: e' p2 |$ U1 d( G0 g
  29. #ifndef __STATEMACHINECLASS_H+ N* X0 W, W5 ?/ Z1 ^4 `" J5 [
  30. #define __STATEMACHINECLASS_H
    0 `3 ~( v' m" l, `6 s1 l
  31. 9 g. Q/ [, y* B1 O' y) j; d
  32. /* Includes ------------------------------------------------------------------*/; e1 m. F* e. U, P
  33. #include "MC_type.h"+ D0 M2 m; X/ }; b- G# y! G
  34. $ d# P$ E- i" `) j& r2 e9 k$ j& G0 s
  35. /** @addtogroup STM32_PMSM_MC_Library
    , i) E2 e! D# C+ f
  36.   * @{
    4 M8 M6 f) f, C% A( @
  37.   */
    . W* a# d$ u" [) y: z
  38. 9 |/ D( `# p+ ^" x0 v3 i
  39. /** @addtogroup StateMachine" ^+ i% {. o9 l8 S$ m7 o" h3 R
  40.   * @{
    ! v& C* O/ \. L3 W6 v1 \
  41.   */
    , H+ y: ]7 Q' Y0 O. I0 X: `

  42. 9 T; ?7 Q: o3 R' v" q: \: D& W
  43. /** @defgroup StateMachine_class_exported_constants StateMachine class exported constants
    - p3 B# R. i4 _# {; ^) z  G
  44.   * @{
    7 V; D  y6 ~0 T9 v# b2 ]
  45.   */
    ) p5 N  @, Q/ M
  46. ( C) l8 g4 {3 }0 l

  47. 3 t& Z% [& G# ~
  48. /**5 o: q  f& A* m8 W8 h4 `. Y
  49. * @}( f) @; u; S3 R/ D! b* n% {+ [
  50. */
    * v* A( j- d& }

  51. ( B' c5 m1 q+ s5 Y
  52. /** @defgroup StateMachine_class_exported_types StateMachine class exported types
    % i5 L' a- _" L. Y
  53. * @{; j5 b7 ^( g+ a# q
  54. */
    9 x. s; T7 c  s  S  ~
  55. ' v4 ]$ E6 K  M% R. _4 c
  56. , \' D/ b9 J' V( c2 c" b1 J$ W9 i
  57. /** 7 E' Z3 f* S, h
  58.   * @brief  Public StateMachine class definition
    6 Q& b/ a! g0 e5 W
  59.   */
    " Y$ a! z0 h' N8 I7 @
  60. typedef struct CSTM_t *CSTM;  w2 B1 y2 \+ h5 E/ v0 o- D7 X* S
  61. - K6 U: o+ ~  m- V( R
  62. /**9 E1 `1 p: T; g- R0 K! G5 j7 S# a
  63. * @}2 w/ {2 C6 d3 l4 C! a4 H
  64. */$ s( J. y( Q7 O! _

  65. # K: j4 S6 m1 i( {
  66. /** @defgroup StateMachine_class_exported_methods StateMachine class exported methods
    % Q' z# c+ e2 `' J6 ]
  67.   * @{7 b8 I9 a- t, b7 [) V4 a7 m
  68.   */- g7 y7 C; y' Y' L5 m. ~
  69. . E; x, t0 K0 s# g: h
  70. /**
    . I; H  G# ?: _
  71.   * @brief  Creates an object of the class StateMachine.
    2 A  Q- b" q7 [- L( |0 p
  72.   * @param pStateMachineParams pointer to a StateMachine parameters structure.
    # a( i7 K- S# ?; B- X' g0 m
  73.   * @retval CSTM new instance of StateMachine object.
    : H1 h& H1 ?: v1 R# m
  74.   */6 @1 D4 ^8 ~1 T+ Y' g* b
  75. CSTM STM_NewObject(void);
    3 i8 |# d* m8 L* a1 x

  76. 5 P: G5 b" w: r- x% W
  77. /**5 t+ A" g' e9 q) v$ k
  78.   * @brief  Initializes all the object variables, usually it has to be called
    / ^: D0 s8 I3 o: e- t6 Q! r
  79.   *         once right after object creation.0 {2 ?; Q3 j1 X
  80.   * @param this related object of class CSTM.
    2 i4 A1 V- ^6 f  u
  81.   * @retval none.
    ' ^9 j) D) q$ }* L2 u& Y/ w' X1 Y
  82.   */
    * e2 U! Y& j2 O
  83. void STM_Init(CSTM this);
    . k; D8 e0 h" H2 G

  84. ! e& {  d- L! X; e. q
  85. /**
    # X4 F1 A% w8 s1 K; M; f
  86.   * @brief It submits the request for moving the state machine into the state
    % P2 r' p6 K  U% T( ^
  87.   *        specified by bState (FAULT_NOW and FAUL_OVER are not handled by this 3 f8 h# X5 j( F. q6 ?
  88.   *        method). Accordingly with the current state, the command is really) [8 C) a4 o  C; g
  89.   *        executed (state machine set to bState) or discarded (no
    0 U+ q3 T. T' A1 H- Y
  90.   *        state changes) * c, j" w2 o4 z! \/ L8 ^: x
  91.   * @param this related object of class CSTM.
    & E+ n6 l3 l/ @. {8 O# \
  92.   * @param bState New requested state7 J! ]4 l- ~# S' `; h
  93.   * @retval bool It returns TRUE if the state has been really set equal to   D7 H) Q2 O0 f* K
  94.   *              bState, FALSE if the request has been discarded
    5 M% n7 v: X! E
  95.   */
    % A& R) ~! ~% _7 e/ ^
  96. bool STM_NextState(CSTM this, State_t bState);
    3 ~7 V* o" y* m: l3 c5 O/ t
  97. - T' u# O! |. c
  98. /**
    ) y& k! H* _( W* l& u. n- W: A
  99.   * @brief It clocks both HW and SW faults processing and update the state
    2 m1 g: t4 b9 h0 r
  100.   *        machine accordingly with hSetErrors, hResetErrors and present state.
    % }2 \" t/ H9 A9 e% O
  101.   *        Refer to State_t description for more information about fault states.9 I" f# S* @) M
  102.   * @param this object of class CSTM
    8 r( [5 \2 i! D6 g
  103.   * @param hSetErrors Bit field reporting faults currently present
    , a" ^2 Z- k, l# i6 B
  104.   * @param hResetErrors Bit field reporting faults to be cleared# H! Q( d6 V+ D
  105.   * @retval State_t New state machine state after fault processing
    6 l/ H- c% J* {3 \; q4 a% r% K
  106.   */* q, a# E) W$ a( B& ?5 Z
  107. State_t STM_FaultProcessing(CSTM this, uint16_t hSetErrors, uint16_t
    & Y0 J% j1 o! V! g" O
  108.                                                                   hResetErrors);0 H2 L. ~; s! V! b0 |
  109. 7 C; w) R2 b* z
  110. /**
    ! A- i) a3 k2 L  ~- S, h
  111.   * @brief  Returns the current state machine state
    6 A( a/ l* h! c; ~  O5 c
  112.   * @param  this object of class CSTM' Q# X7 ]' G: U. \2 A
  113.   * @retval State_t Current state machine state
    3 e( P7 i2 r, |" `" x& G0 C. ^
  114.   */) n7 A7 s, v; O& j. |4 c( j+ L
  115. State_t STM_GetState(CSTM this);
    3 w4 Z& W: a$ G

  116. ) q) l- ]- F3 n( q* {5 `/ o7 W
  117. /**$ S  u# c  i# u3 e' C6 ~( M8 a  m: c
  118.   * @brief It reports to the state machine that the fault state has been
    ; S$ E6 H: W1 T, c* d
  119.   *        acknowledged by the user. If the state machine is in FAULT_OVER state0 t0 |! W7 h: l! m
  120.   *        then it is moved into STOP_IDLE and the bit field variable containing
    / K# v6 E: h- z4 c1 {6 d' a
  121.   *        information about the faults historically occured is cleared. * q" Q; ]% D3 m) W) f/ x
  122.   *        The method call is discarded if the state machine is not in FAULT_OVER2 b. y$ P' ~6 y* I6 q3 z
  123.   * @param this object of class CSTM) M) U% v4 K7 E9 b( R3 K6 g
  124.   * @retval bool TRUE if the state machine has been moved to IDLE, FALSE if the
    ' ^& j9 Q: o: R2 w
  125.   *        method call had no effects - W3 ?9 C7 Q8 {" n3 f; m, z$ \
  126.   */
    0 _# N, B& f" }* z4 Q, L& M+ `# _) E
  127. bool STM_FaultAcknowledged(CSTM this);
    ; o. |0 D1 c; e/ k. {

  128. $ c- o3 \. f6 s5 ~; z9 `* b
  129. /**! \+ y# O/ O/ f: ?% V% d* V+ z3 [" \; t
  130.   * @brief It returns two 16 bit fields containing information about both faults
    3 k' M) S4 ~+ H! Z
  131.   *        currently present and faults historically occurred since the state
    ! k4 Q) [  S. h* p8 ^& T
  132.   *        machine has been moved into state& z7 T+ R* H9 P$ M% q" h9 ~
  133.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink8 \2 M! V: p3 N$ ?
  134.   * @param this object of class CSTM.. }) d' ]5 W# N. V0 S
  135.   * @retval uint32_t  Two 16 bit fields: in the most significant half are stored
    7 V' S$ q# m; {* F& ^4 ~
  136.   *         the information about currently present faults. In the least 2 A# s& E; S. T+ l+ N; \( B2 ~
  137.   *         significant half are stored the information about the faults
    2 z4 A& P4 f$ n) w
  138.   *         historically occurred since the state machine has been moved into
    7 @8 ?1 o0 f2 g) K5 ~/ k! t
  139.   *         FAULT_NOW state
    ! A$ w6 X8 c8 C) E
  140.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    , Y+ y  m2 y2 s
  141.   */
    : |" W! O/ Z, E
  142. uint32_t STM_GetFaultState(CSTM this);
    * F; ]. f' P; i  @6 j# c* Z! r0 E

  143. ' s3 l& N$ d; w( c8 [- W+ `
  144. /**8 ~* M; d* G/ C0 a
  145.   * @}. I5 H: z3 d) c4 h$ z+ c! m
  146.   */7 J3 u6 x7 L, i1 j/ K. t
  147.   
    9 Z, S% u! f0 p% U
  148. /**" l5 a7 {5 ]. k5 O+ p) u
  149.   * @}
    6 M; U! f& r( j
  150.   */5 Q/ v, `4 M3 T8 ~3 c

  151. ; ?) g0 a% B; a7 {# B) {# v
  152. /**
    ' k& X* I) Y1 @6 u$ ?; @2 h1 X( B
  153.   * @}
    0 v* `7 P3 s2 r3 _! w' m4 T# u
  154.   */
    " `- `5 @# u# C0 t
  155. + Q' \2 K* W- t7 |
  156. #endif /* __STATEMACHINECLASS_H */
    ' \$ p7 u: g$ h7 b  u2 z- W
  157. : a2 P- g* ^! }6 P! T; G
  158. /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
    * U3 o+ T/ K! s  X5 z" x& T
复制代码

8 N9 J' R* V2 P; h% R( F状态机看这个图: 状态机.jpg
8 ~9 B4 B( I  n0 m5 \& G8 R! F! A6 s3 k, ^/ C( a9 p  @- H
5 j' ?, _. E: x$ F7 v' Z  J
! ?: j& H: \% U$ a9 g. z
努力的人 回答时间:2017-8-28 13:57:18
本帖最后由 努力的人 于 2017-8-28 15:19 编辑 , U0 [/ D* C6 D+ C
5 W4 x0 `: o+ D: l6 M7 {+ s- K! c
二、TASK1 5s转动、5s停止       
1 ~4 t) ]9 y" P3 H( U* ~/ A$ y& ~& D8 Y
; c+ Q3 T/ z, y( [, m0 H
    首先上传一下源代码,因为systick的500us的定时与SDK中一些任务的处理速度相关,这里我觉得还是不要修改定时时间比较好,我的代码如下:, ^( R5 ~- T3 E
说明:在main.c中定义uint16_t mytime; 在stm32f30x_it.c中定义extern uint16_t mytime;5S就是10000*500us,所以就可以转5S停5S了
6 @9 f1 @0 ~* \$ f4 K& b+ d
  1. //TASK1 源码
    8 ~+ d  n! C1 n) K' v4 I) Q
  2. /////main.c//////////////! B% }' _5 r9 F: m+ k( Y& C, M
  3. uint16_t mytime;& c  z1 P4 B) D, z6 O& ?3 j0 W
  4.   while(1)  I& K8 z# q# V7 l
  5.   {
    " {; W' a* U- H  e% ]3 T2 f
  6.                 if(mytime==0)
    , O" a7 T7 ~! i8 ~4 m) t
  7.                 {
    + ?" y6 U9 j% u: z0 d2 b
  8.                         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);' M1 |# S, ?( ]* L* N; ?/ ^/ w
  9.                         MCI_StartMotor(oMCI[0]);# n6 Z& Z; N) ?. J7 v
  10.                 }
    % g6 I0 F) B0 D5 J; O1 N! f
  11.                 if(mytime==10000)
    , z/ E. {6 V4 `5 m" ]: Q
  12.                 {
    6 a8 W9 {1 e! c  X5 j( a; B: i9 T
  13.                         MCI_StopMotor(oMCI[0]);
    1 F& _# d/ [4 N
  14.                 }
    * b% b8 B6 M0 Q7 O) ~4 P, U8 Q$ `

  15. - \# \9 L2 `$ D8 _& R
  16.    . l+ X& s& G, N! n) d7 l3 l
  17.   }8 q$ c+ Y0 v: z) e7 W( }7 W8 `. [
  18. //stm32f30x_it.c
    & L% d/ q" a, z  i, a
  19. extern uint16_t mytime;. }8 `, R  n5 C3 |4 g  `4 R1 f
  20. void SysTick_Handler(void)( p5 N; U  F& q% v
  21. {
    / h. T. \7 r  J9 n
  22.   TB_Scheduler();* i: P2 n& Y$ W2 Y( q8 {4 {
  23.         mytime++;
    9 h$ Y" |7 v) L" t& b
  24.         if(mytime == 20000). f7 A) b& V5 \% E
  25.         {mytime=0;}
    % q, M9 Q+ V& n0 w9 x; A
  26. }
复制代码
# |0 _, U2 a" C  {3 t* e+ ]
视频:
$ n& x0 u% ~! {8 P6 g8 }
5 `% s& J& f/ c7 q* \; h
7 I! `" P* V5 T+ i7 E* N
- Z$ b0 M" V$ V5 z* t
努力的人 回答时间:2017-8-28 13:57:36
本帖最后由 努力的人 于 2017-8-28 14:36 编辑
  S6 V+ e/ n5 E) H4 F" u+ N# _0 R
3 n: q6 E  v5 s+ h三、TASK2 PID参数的调试
  N( t- c) n, o2 c7 N% J    任务2的代码如下:* l% G) R: Q: ]4 c, h3 Q. f5 ?
  1. //TASK2源码
    $ y+ d# @, M9 J! O) L8 K$ U0 j4 x' T% V3 T
  2.         static int16_t Speed_Kp,Speed_Ki;
    ! g( l$ `/ t3 g
  3.         static CPI oPItuning;, A4 H) V( e  I# P% T! G+ W: c% t
  4.         oPItuning = MCT_GetSpeedLoopPID(oMCT[0]); // ????PID???
    : D( c7 r: ^2 q, s6 B! M
  5.         Speed_Kp = PI_GetKP(oPItuning); // ????PID??: R9 i5 t& D1 u$ i, w# v9 D( t! t
  6.         Speed_Ki = PI_GetKI(oPItuning);
    7 K/ K9 c# F9 c+ ~7 f. l, {! h
  7.         PI_SetKP(oPItuning,Speed_Kp); // ??PID??. V' o0 M. V' B
  8.         PI_SetKI(oPItuning,Speed_Ki);
复制代码
这里我们首先看一下原始PID参数的速度曲线,从图中我们可以看出转速的超调比较大,已经达到4000多转
! M' w) W' y) F2 x, B5 \% S4 N$ o6 d 原始PID.jpg    原来的PID参数.jpg / [# v0 K3 ?7 x6 c
接着我们修改程序,将程序设成2倍的PI参数(左图)和0.5倍的PI参数(右图)
$ ]' m5 a2 c$ A: _( w% v: H! O- b9 ] 2倍PID参数.jpg    0.5倍PID参数.jpg 2 x" L) A" I1 w# Y% c& O
从图中可以看出,增大倍数的PID参数比减小的好,所以我们接下来将PI参数往大了调,分别作了2.2倍,2.5倍,2.9倍的速度曲线图
: f! _3 I2 C: ~8 R0 Q 2.2倍PID参数.jpg
- l* q4 h/ F- M( e 2.5倍PID参数.jpg
- c0 M* G6 E8 _" b8 W+ @ 2.9倍PID参数.jpg 9 e! j9 A8 Q' k# g
我们还想让超调小一点,所以我减小了一点P参数,最终得到这个速度曲线,我们通过上位机可以看到调完的参数,最后将程序中默认的PID参数改成我们自己的。( E6 {$ O4 B0 Y: Y! z9 ^
最终确定的PID参数.jpg   
* i3 b  }# r0 A# C- u
程序最终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:539 n  i% y7 Q# J2 w- F* J- r
看了楼主的帖子学到了不少东西
! s/ M- O! B! [  L* |
这就是互相分享的意义呀
donatello1996 回答时间:2017-8-30 23:35:37
努力的人 发表于 2017-8-30 21:24( W: V8 q% b/ O' P' r
这就是互相分享的意义呀
( m6 D/ D. p- I8 R4 A4 b
对了楼主知不知道在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 手机版