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

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

[复制链接]
努力的人 发布时间:2017-8-28 13:56
相关阅读:! M9 K4 q' |) U: V9 z3 A
电机培训 - 三个任务主函数及中断程序3 a7 h3 B  u) [9 ]0 d4 ]
电机培训 - 让你可以深入研究的PMSM/BLDC文档2 v9 e# ^7 T) @' Y' b% }) u: `

8 D8 w$ B0 @0 v7 G. L3 A: N/ l& bPS:如果大家觉得帖子还可以的话,请到社区之星评选为我投出你宝贵的一票谢谢
点击进入投票
5 z" @+ g  W: @: ]/ r- f很高兴参加了ST的电机控制培训,先上几张图,我也悄悄地在提问窗口回复了坛友的问题
1.jpg
; S3 H2 U* Q3 E, O$ V# w

/ j2 h; H" `  _8 H 2.jpg 3 {, w5 [9 j' _# f

+ n/ r  ?5 ]8 n1 h4 Z ST研讨会.jpg
$ [" S3 l. k! B8 n下面开始步入正题吧!我的主函数程序下载 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
' _; ^7 K8 R# g1 p% e对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊? ...
3 n' [& h0 ~, J) h- U, P
1.jpg $ e$ U" W$ h  {) H
母线电压是ADC采样的
+ z3 D9 S+ M; O* b. `5 ^0 l所有的函数都在这里,你自己查 STM32 FOC PMSM FW library developer Help file.chm (1.14 MB, 下载次数: 78)
努力的人 回答时间:2017-8-28 13:58:01
本帖最后由 努力的人 于 2017-8-28 15:07 编辑
( Y: _0 }" w0 i' k- `4 P# K' C1 S; v4 i
TASK35 S/ x2 H8 q* m& g  A6 Q6 ?7 M
    首先还是上传一下源码/ d1 ?" o. R, L; S* r1 O# S; P
  1. //TASK3 源码
    7 G* F4 R+ `5 d/ h' ]
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);
    $ e% L5 d- ^* _# h4 \# p& x2 N
  3.         MCI_StartMotor(oMCI[0]);
    " u' t) w* d2 K, S  T' R  l* ^3 Z7 W, L
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);3 r. {8 Z3 l" S: C
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
    4 T# x5 K2 I3 B3 U) c6 p
  6.         //STM_NextState(oSTM,STOP_IDLE);7 x! s% A3 o# h3 X% R
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );
      U# L4 i5 X2 r9 P- X. ~4 H
  8.         while(1). [& F$ ^9 l6 [
  9.           {/ Q+ U7 v- x( H9 `: `& t4 J$ ^( e3 x
  10.                
    * C- n: G% l; }4 \/ T# q- a+ S2 G
  11.                 6 Y# \% r5 ]' v* K4 Q
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);# v, {, k$ k8 K; n% ^: C: [4 j
  13.         if(Fault_Type == MC_SPEED_FDBK)9 _0 @+ A' @# w( c- o
  14.         {
    0 t+ g% ~! T) ?- L! U
  15.                 //MCI_FaultAcknowledged(oMCI[0]);
    $ Y1 V" @4 h6 }3 q5 B& s/ {- W
  16.                 //MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);
    4 @0 ^" H, @+ O/ J* Q
  17.                 //MCI_StartMotor(oMCI[0]);! b- k! m, r$ ]" F  G
  18.         }
复制代码
将程序写好后,下载到板子中,我们可以看到致故障的上位机界面
# I" _6 j& Z) Y( u; l 致故障.jpg 5 S1 T- v# B( ^8 l( d3 s( O
然后我们将下面的代码下进板子中
" n% w, x( O/ `6 C1 K8 N- I9 r1 W" J) R
  1. //TASK3 源码
    1 m6 f* Y) ~# `; F' W+ y
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);
    / K# Z9 w; o6 q) H
  3.         MCI_StartMotor(oMCI[0]);
    4 S9 b" G5 h( e* |. v
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);' f5 @0 ]! S, h5 v: R/ R  G" M1 p
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
    $ L7 u& C# s, J
  6.         //STM_NextState(oSTM,STOP_IDLE);5 c, u* Z' t5 G$ O1 w' J2 s8 R# F
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );
    ( |/ `7 V+ w( z
  8.         while(1)
    1 _% j2 Q9 x' z$ J' F* w
  9.           {/ B. R  C! C8 l5 c. B
  10.                
    7 V; {+ \: D, i3 I. ]
  11.                 , p8 M+ `. m" p" w4 U; s7 i
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);3 L% x% n: K3 c+ ]
  13.         if(Fault_Type == MC_SPEED_FDBK)! C* C0 j& h- o. c
  14.         {
    " \  N& J0 ]! _, |
  15.                 MCI_FaultAcknowledged(oMCI[0]);
    ( o9 A: }8 S5 _3 J" g
  16.                 MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);# b# V% s4 U% k7 |* m* S
  17.                 MCI_StartMotor(oMCI[0]);
    3 T- B$ Z' B) h5 j" C" x
  18.         }
复制代码
可以发现电机正常反转。- W  j% e. T! D$ t) R+ J$ |
关于故障代码可以参考: 故障代码查询.jpg ; ?+ b5 m* d# A: c3 k, \% G, Z
关于至状态机故障和清除故障的程序,大家参考StateMachineClass.h
  G  B* U9 U3 p/ Z; v5 m; H/ a: ^
  1. /**
    0 H+ P' ^3 z6 C% ]$ y( a4 o: J5 ]2 t
  2.   ******************************************************************************
    ; \  \) _: q4 q5 ~0 E9 E  ?
  3.   * @file    StateMachineClass.h7 V) L( X$ h- `0 d: V
  4.   * @author  STMicroelectronics - System Lab - MC Team! h& |; {$ ^0 L) I9 n
  5.   * @version 4.3.0+ B8 T' L8 X5 @; r: y1 D
  6.   * @date    22-Sep-2016 15:29
    & o4 J" V  s+ h
  7.   * @brief   This file contains interface of StateMachine class      
    % o+ P3 L9 M, T4 y2 s/ M. K
  8.   ******************************************************************************" ?0 I/ v7 N' I/ ~+ {4 a
  9.   * @attention5 j+ E7 }- x1 K2 y) `$ i2 ~5 _( l, E
  10.   *4 c$ w3 M* R7 T. J( h6 \1 z! h. o' H
  11.   * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>/ O- Q$ ?" [# u6 o2 ?9 k1 v4 j7 g
  12.   *
    # G6 F7 G5 M4 e; ^' t, f' u! W
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
    6 C. P3 Z( K" ]
  14.   * You may not use this file except in compliance with the License.
    ( R1 a$ O! e3 Q1 i3 _% b0 O- A* D
  15.   * You may obtain a copy of the License at:
    5 C1 z6 H, {2 V5 O0 Z4 o* [! c% K
  16.   *
    4 {) U2 ]. L1 Y
  17.   *        http://www.st.com/software_license_agreement_liberty_v22 ^" J$ J& L% [
  18.   *( s1 e1 t: g) a4 p. r. M
  19.   * Unless required by applicable law or agreed to in writing, software 9 L9 X( }2 L. Q# I3 p0 J* v
  20.   * distributed under the License is distributed on an "AS IS" BASIS, 4 z' ?; h5 Q  [) o
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    : ]8 |: @7 G, q0 q& E! Q' V: \
  22.   * See the License for the specific language governing permissions and2 X$ P, @; V" ^( `# K: J+ }
  23.   * limitations under the License.2 b  }9 Q: r: [% r. o8 H
  24.   *
    % `, I; P- [. r5 c6 G
  25.   ******************************************************************************
    7 {$ q5 @4 ~3 y
  26.   */
    * J- `! B$ G# v# Z* b
  27. " ^- [0 a; x* F0 o
  28. /* Define to prevent recursive inclusion -------------------------------------*// k1 G  k& V/ N2 o; Y
  29. #ifndef __STATEMACHINECLASS_H8 Q$ o/ O  u9 |; I( e4 |
  30. #define __STATEMACHINECLASS_H+ \. n4 n! y( C/ b. U& h- V

  31. ! O$ W  ?+ P+ {- \  o9 ]3 S$ ]
  32. /* Includes ------------------------------------------------------------------*/
    " M7 ]$ v" K. L6 j  R
  33. #include "MC_type.h"
      R3 n- d7 _# C

  34. 9 F* H) {0 W2 \
  35. /** @addtogroup STM32_PMSM_MC_Library7 o! I/ o- o( ?
  36.   * @{3 r/ u& H& B; t9 T, [7 X
  37.   */2 N7 S6 K9 ~7 Q2 e; }
  38. 0 b: R6 _- x% x7 }2 I; z5 [
  39. /** @addtogroup StateMachine6 }, K$ _- N5 t% [( B, I0 |9 a7 \
  40.   * @{
    ' a1 K5 o& ^# t! r: }
  41.   */
    5 |) r. d5 r- b. N9 M

  42. 9 q4 }' \( A& W' z, i2 O
  43. /** @defgroup StateMachine_class_exported_constants StateMachine class exported constants+ e/ ~+ f, V% g: d  f9 j+ j
  44.   * @{# s$ X  t4 P1 w
  45.   */& Y4 i- _, a2 D' V2 ^2 U
  46. % a+ Y* _# u& ~6 G
  47. - n* m/ {; \- w% g- @/ y
  48. /**8 s, e( ?3 u# X
  49. * @}
    ; M4 [+ `# I% E2 _4 g6 v& y
  50. */
    ) c; D; n* |$ w) [( y% T: H' l

  51. & O% F& L6 `" t( K- S5 R) k( Z+ M+ [  r
  52. /** @defgroup StateMachine_class_exported_types StateMachine class exported types- h. E4 ?" P) }  Z$ T5 \, ~! b
  53. * @{) ?1 q  a' j- e8 U
  54. */
    $ G% C$ h8 t  r$ E3 N7 g
  55. 3 ]- F- J* W' h, c; d

  56. - f& `" ]6 `+ P- M: J  f7 l. }6 M1 G
  57. /** / v6 R# ~  r7 o. z, K; w* A
  58.   * @brief  Public StateMachine class definition : x- Z5 D6 c# q
  59.   */
    ! q3 v! Q; [7 M" W
  60. typedef struct CSTM_t *CSTM;3 q2 a: J6 s' r1 v: h. R5 W

  61. 7 Z0 x) Q# v/ w" L4 n4 E
  62. /**
    5 Q$ N0 l6 g+ |4 V2 D3 E( g+ W
  63. * @}, V. J: L+ p! R3 |
  64. */8 N. ~4 h( Q. E" t# x( [
  65. 2 K: J. I# t* R- j
  66. /** @defgroup StateMachine_class_exported_methods StateMachine class exported methods
    , k) C; R0 c' I" x
  67.   * @{, k! E" X2 g" q1 q
  68.   */
    $ ~8 c! O7 d2 H8 m- v
  69. : J% O8 Z, L* M& C5 j& d# H! c
  70. /**7 X  F. T" C! d: V, D  {! j
  71.   * @brief  Creates an object of the class StateMachine.( G* Z$ T/ h1 L
  72.   * @param pStateMachineParams pointer to a StateMachine parameters structure.5 n" s. I4 l! r1 L
  73.   * @retval CSTM new instance of StateMachine object.2 O3 c2 A& e( L5 z, N; Z- Z/ }! s- m4 K
  74.   */
    , f5 Z! l/ R) |2 ]7 K! _
  75. CSTM STM_NewObject(void);
    : v3 L" I2 {" n  T, j1 C
  76. . P1 B. q: a" h  Z! v) {& q4 U
  77. /**
    % p" ^/ }; m, ?6 L
  78.   * @brief  Initializes all the object variables, usually it has to be called
    , ^* {6 j. n7 \7 B& G0 o
  79.   *         once right after object creation.! t& G7 I2 c! r+ e
  80.   * @param this related object of class CSTM./ X. ?; l. a" Z  ?' z, i( f
  81.   * @retval none.+ k0 ^- q4 L  z
  82.   */
    9 ?( j9 j3 r# J5 v& g
  83. void STM_Init(CSTM this);0 _% U4 |$ W) o1 j5 P

  84. : @$ M: _4 K3 n8 q0 p
  85. /**
    - ?7 t* x* ^. f5 J5 L0 N& c4 Y$ t
  86.   * @brief It submits the request for moving the state machine into the state 6 ~9 R7 K7 ?$ K7 ?
  87.   *        specified by bState (FAULT_NOW and FAUL_OVER are not handled by this
    ; Z: v0 E9 M3 F6 Q" ]- V( r
  88.   *        method). Accordingly with the current state, the command is really
    / ?7 A2 C( t: j; ?/ _
  89.   *        executed (state machine set to bState) or discarded (no 5 u, N, k1 S( ^! ]1 O
  90.   *        state changes)
    9 ?. q5 Q2 G1 c
  91.   * @param this related object of class CSTM.$ |# {0 o( K) Y. y
  92.   * @param bState New requested state# {7 Y8 K3 o. M) }' h9 T
  93.   * @retval bool It returns TRUE if the state has been really set equal to 7 E3 q* Q% E7 i6 p7 @; f- K
  94.   *              bState, FALSE if the request has been discarded& |/ U0 s; C/ t2 ?
  95.   */
    & f; f5 [; b3 L% `( O
  96. bool STM_NextState(CSTM this, State_t bState);1 _! |5 I, a3 W) V
  97. $ ^4 J, _% ~! M5 E
  98. /**- N/ j! |9 r, H; o# n* }! R
  99.   * @brief It clocks both HW and SW faults processing and update the state 6 L5 f* b# C1 q; N$ Z: w, G, D
  100.   *        machine accordingly with hSetErrors, hResetErrors and present state. / O/ h1 b- {  V4 ~7 F7 d" O
  101.   *        Refer to State_t description for more information about fault states.8 R7 w. V1 u( y
  102.   * @param this object of class CSTM9 P* W9 j$ C5 t2 p; w
  103.   * @param hSetErrors Bit field reporting faults currently present
    8 z1 B$ x: M- J6 g, _& O4 t
  104.   * @param hResetErrors Bit field reporting faults to be cleared
    1 P9 J( N: m- r) T' g
  105.   * @retval State_t New state machine state after fault processing
    / P) F" I& c" s* [: z4 m
  106.   *// w. K3 k9 T1 S4 R; H7 r
  107. State_t STM_FaultProcessing(CSTM this, uint16_t hSetErrors, uint16_t
    ' |! T* y) F# m
  108.                                                                   hResetErrors);; A" @9 n/ n  p3 M' o" M8 k

  109. + O( i' J7 `' ?' {
  110. /**7 Q1 {+ s9 l4 N8 y' m1 K
  111.   * @brief  Returns the current state machine state+ M) ^) H4 D3 \$ T& r) E& c
  112.   * @param  this object of class CSTM
      x+ H. w& j; @2 K) E
  113.   * @retval State_t Current state machine state
    : {2 D" Y# w6 ^+ o; |* Y$ ~
  114.   *// p5 w$ E$ a7 M
  115. State_t STM_GetState(CSTM this);
    ' _% N, r. |8 H* w* s% H

  116. 4 b0 I6 V- Z  u; y) w, T# N
  117. /**
    4 \% I7 v3 V4 f: v( i% ~
  118.   * @brief It reports to the state machine that the fault state has been
    & q1 p3 R+ r) M- h
  119.   *        acknowledged by the user. If the state machine is in FAULT_OVER state: t* @! P1 z; k- F, ?3 Y
  120.   *        then it is moved into STOP_IDLE and the bit field variable containing ) G- ]- O3 O" ]% E* i" V7 m4 r
  121.   *        information about the faults historically occured is cleared.
    3 \/ Y' O! q7 `" [$ u5 n; e
  122.   *        The method call is discarded if the state machine is not in FAULT_OVER, t. `4 p4 m% R5 B! J8 p
  123.   * @param this object of class CSTM; y9 x5 q; E3 B# B
  124.   * @retval bool TRUE if the state machine has been moved to IDLE, FALSE if the
    & `; o9 j$ D, g) J# }, r
  125.   *        method call had no effects 9 N6 |/ b* G: A% B
  126.   */( ]4 c3 N. V+ H/ u3 S
  127. bool STM_FaultAcknowledged(CSTM this);
    3 X5 ~7 [6 f4 N5 w1 B  @
  128. - a$ {( ?* a4 T% V  ]% J" ^2 y
  129. /**% Z( g' t$ @+ o3 ~
  130.   * @brief It returns two 16 bit fields containing information about both faults
    * D6 |$ n. ]8 ^) E+ J5 b1 c9 I* \3 C
  131.   *        currently present and faults historically occurred since the state . u4 ^* N, H; _) c9 q7 a5 Q' L, h
  132.   *        machine has been moved into state* N/ z* S% v% J
  133.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink8 l  U0 ^3 j/ n7 O% w
  134.   * @param this object of class CSTM.* r  m0 n! ~" q: y7 A  c( x+ @! n
  135.   * @retval uint32_t  Two 16 bit fields: in the most significant half are stored
    ' f' G2 r# X' S! x5 h$ l/ H( k
  136.   *         the information about currently present faults. In the least 7 ?# J' T7 Y9 H, W5 S- g8 E
  137.   *         significant half are stored the information about the faults
    6 `! N5 C& j  k) Q2 X/ h
  138.   *         historically occurred since the state machine has been moved into
    + u( @2 j5 p  b. r. O+ z
  139.   *         FAULT_NOW state  p+ s! k6 F* w
  140.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink( u4 U% m$ l6 R- O' q
  141.   */5 ]; l3 ]" P- o  S5 G2 E- N
  142. uint32_t STM_GetFaultState(CSTM this);
    / k, i( Q! ~' m
  143. 1 F" [& Q- p+ r2 \4 d& r
  144. /**& Y  N! ~0 U) ^' {* ^+ e+ D
  145.   * @}
    9 x5 w2 c% P3 i7 f" }  p  x! F
  146.   */
      m4 h) G7 z9 H* E
  147.   
    0 j- l& E* y) j7 P1 N6 U
  148. /**# I; S  G) s6 C4 e& Z0 }$ ]
  149.   * @}
    9 [5 I4 o1 {' b
  150.   */6 `3 y. n' @4 [
  151. / V5 X0 P. F1 c! W! f
  152. /**
    & b/ Z- R' W  ~3 o% _# k8 w
  153.   * @}
    5 [6 B/ u, H; s3 ]( c
  154.   */' E1 `$ P0 ]- a  u8 b
  155. . G' H, P" j* i1 C% Q
  156. #endif /* __STATEMACHINECLASS_H */+ b" Y3 a& o& C9 ]& @

  157. . Q8 x$ v7 }" l
  158. /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
    - B2 q, L& V# y  m/ a  u
复制代码

  c8 G) N# D& T; h状态机看这个图: 状态机.jpg - Z' a) r5 c' q2 ~2 w6 g' }
+ [1 \2 D# _; @/ y

0 [9 b% e7 }; j) _& Z5 c% A( o! W& X1 Q1 R0 y# w
努力的人 回答时间:2017-8-28 13:57:18
本帖最后由 努力的人 于 2017-8-28 15:19 编辑
. N& g1 j2 k, u7 ]+ y4 X
. q" L/ h) W- ]: A1 k# z/ @二、TASK1 5s转动、5s停止        ; r8 s7 ^7 Z7 i, ~

# X8 @8 K+ s: u) P+ d8 u  C' {/ U    首先上传一下源代码,因为systick的500us的定时与SDK中一些任务的处理速度相关,这里我觉得还是不要修改定时时间比较好,我的代码如下:
) H2 z1 w2 H; ?/ |8 W$ e说明:在main.c中定义uint16_t mytime; 在stm32f30x_it.c中定义extern uint16_t mytime;5S就是10000*500us,所以就可以转5S停5S了
, K( l# s2 H  i& d6 `, \5 g
  1. //TASK1 源码; P6 t- }9 Y3 Z# U5 {5 |1 L7 W
  2. /////main.c//////////////9 N+ h) {- s4 x- q
  3. uint16_t mytime;5 T" j' e4 Y8 |
  4.   while(1)
    0 j9 A) c; P* l
  5.   { . t& Z) u) \1 k6 r4 ?
  6.                 if(mytime==0)
    3 K! f) ?0 N# r9 A$ S; n5 F0 U$ ^
  7.                 {* o0 H! l7 `3 o$ t. D
  8.                         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);  k" w' N5 q0 x' z  Q# ^! h
  9.                         MCI_StartMotor(oMCI[0]);( Y  ^; Q! O! T  I, C3 e. f; D
  10.                 }
    3 O$ j4 H6 ]" R( I* u4 C
  11.                 if(mytime==10000), R0 e2 l- M/ q# p4 t$ ~
  12.                 {
    2 l" t! K" m8 e0 K) t. f
  13.                         MCI_StopMotor(oMCI[0]);) \1 p- @# J+ c( A* I0 C
  14.                 }5 ?% t, N8 y+ q6 s
  15. 1 |. Y/ F6 ^1 C5 T4 t' y" |
  16.    
    & F1 `6 g- ]& ~
  17.   }+ X# w$ G, ^& p5 Y
  18. //stm32f30x_it.c
    * w/ T& G* R. X' Z% U2 j4 K! Q. q
  19. extern uint16_t mytime;! u% w- \* I# S- I2 j# k2 F; ~
  20. void SysTick_Handler(void)
    / M: O8 T- r: S3 n
  21. {
    3 P  e; t! w& {+ q; ]8 m3 I
  22.   TB_Scheduler();2 m% K' B* q/ U
  23.         mytime++;
    - L& d4 Z; Y& Z3 ]; Z
  24.         if(mytime == 20000)
    1 B8 X9 o& L6 A4 f- Q5 ?3 B8 A
  25.         {mytime=0;}. J% Y. v/ |0 V' ~* V
  26. }
复制代码
$ r$ f1 L( a0 d2 N$ W
视频:# N1 ^) c4 N5 a, n
+ C0 P" ^( ^5 }0 q' f
! y0 s) Y2 b# E( I4 e/ D  T
! v) W6 [" n4 w5 f5 q4 _
努力的人 回答时间:2017-8-28 13:57:36
本帖最后由 努力的人 于 2017-8-28 14:36 编辑
: d) L( _. `6 V( B+ E) w( V7 c: o# P* K5 h! b; X
三、TASK2 PID参数的调试
( C8 y, C$ f6 i! Z0 z5 m+ X6 o5 U    任务2的代码如下:
0 O9 @' ^* t; |
  1. //TASK2源码1 J5 ?: X; c4 m, A$ A9 P+ @5 T
  2.         static int16_t Speed_Kp,Speed_Ki;
    " n0 c) [7 T/ x, |  W8 a! u
  3.         static CPI oPItuning;
    . [0 w3 w, C) `: u7 y
  4.         oPItuning = MCT_GetSpeedLoopPID(oMCT[0]); // ????PID???
    . s' V' u: I" a; @& L
  5.         Speed_Kp = PI_GetKP(oPItuning); // ????PID??
    6 m9 g/ h3 h9 U  _
  6.         Speed_Ki = PI_GetKI(oPItuning);6 r4 \; O# W+ d- w, O3 @! g6 }
  7.         PI_SetKP(oPItuning,Speed_Kp); // ??PID??
    5 A8 D7 d0 l9 i* I: _0 l7 i/ J" s
  8.         PI_SetKI(oPItuning,Speed_Ki);
复制代码
这里我们首先看一下原始PID参数的速度曲线,从图中我们可以看出转速的超调比较大,已经达到4000多转2 x+ r' p# w- Q6 G4 @9 `
原始PID.jpg    原来的PID参数.jpg   g3 t) ?$ F, m5 [* r0 y- _
接着我们修改程序,将程序设成2倍的PI参数(左图)和0.5倍的PI参数(右图)
, K; D' ]5 Z% [9 D& N$ v) e 2倍PID参数.jpg    0.5倍PID参数.jpg
; C% Z# C. j; j" V1 g5 {从图中可以看出,增大倍数的PID参数比减小的好,所以我们接下来将PI参数往大了调,分别作了2.2倍,2.5倍,2.9倍的速度曲线图
( s7 n7 ^% H( s, b 2.2倍PID参数.jpg
: k: R# x, B8 `1 z! _7 i 2.5倍PID参数.jpg
! @6 c0 e0 [+ }9 A& Q( B  z, u 2.9倍PID参数.jpg 6 F( N3 Y' f9 [
我们还想让超调小一点,所以我减小了一点P参数,最终得到这个速度曲线,我们通过上位机可以看到调完的参数,最后将程序中默认的PID参数改成我们自己的。5 d9 M+ R! l# Y& X4 K( Y
最终确定的PID参数.jpg   
, A! ^  |. G* V9 D7 A! ^1 z  E; L: 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:53
9 n* a" W- n6 g9 c6 ^% R" H& X看了楼主的帖子学到了不少东西

/ W* N8 G* J! X6 v2 W$ F( U& J) S) C这就是互相分享的意义呀
donatello1996 回答时间:2017-8-30 23:35:37
努力的人 发表于 2017-8-30 21:24+ J5 j6 n1 _% t5 p# L
这就是互相分享的意义呀
2 k3 j6 P! J' {" r/ T
对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊?
futuresir 回答时间:2017-9-4 09:12:18
学习了
futuresir 回答时间:2017-10-7 15:53:01
xiexiefxiang
1234下一页

所属标签

相似分享

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