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

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

[复制链接]
努力的人 发布时间:2017-8-28 13:56
相关阅读:" W& m  X6 f2 r, U2 v
电机培训 - 三个任务主函数及中断程序$ i- s% g& B% s. P$ [0 t3 O! m
电机培训 - 让你可以深入研究的PMSM/BLDC文档$ R. \4 B1 `( \# K- u7 V

% u3 r0 M& S5 q& I* Z) d5 D* fPS:如果大家觉得帖子还可以的话,请到社区之星评选为我投出你宝贵的一票谢谢
点击进入投票& U$ ?1 |0 f8 L1 v. M9 m3 m
很高兴参加了ST的电机控制培训,先上几张图,我也悄悄地在提问窗口回复了坛友的问题
1.jpg

" @6 B+ h0 ?' C+ _' w/ r( _; b. I* T4 Z
2.jpg 5 K- e5 _2 A& X/ ]$ C' Q/ h! B

! |6 x0 b2 w; w* O8 \. ~& H ST研讨会.jpg 5 T4 a4 F- p) A# J( {( W
下面开始步入正题吧!我的主函数程序下载 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% r  d* F6 ~! s% J. Q" }# d. |
对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊? ...
4 t% R% A$ m( o. O
1.jpg
7 V* y* I( j5 B& q2 [: @+ ~母线电压是ADC采样的
5 @3 r$ h8 `1 H! ]0 L4 |所有的函数都在这里,你自己查 STM32 FOC PMSM FW library developer Help file.chm (1.14 MB, 下载次数: 78)
努力的人 回答时间:2017-8-28 13:58:01
本帖最后由 努力的人 于 2017-8-28 15:07 编辑
# i8 l0 m# d: Q- q% u: M
# s! X7 l5 Y$ Y, T0 t5 v- PTASK3
) @, a& {' j) z- m  n. N. T    首先还是上传一下源码( G, [: N2 t8 L6 T
  1. //TASK3 源码
    ; _- G  `. ~7 Z; ]8 I2 w
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);  p0 E6 k& t6 d' D& `
  3.         MCI_StartMotor(oMCI[0]);
    , ?' m5 V9 u1 \4 b
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);3 V) C6 L6 y. q( \. A2 q6 h% I
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);2 }8 j" G  u2 ^" \
  6.         //STM_NextState(oSTM,STOP_IDLE);) g! t2 V2 u2 A1 o3 w6 m
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );
    5 M) C. u( Y+ w  E
  8.         while(1). X  `" U$ Q% H# ~4 Z$ j
  9.           {" P3 u( E& P" |5 X0 W
  10.                 7 x& l% H7 ?' [
  11.                 ; W* R) f4 s' F( I1 {& O' `
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);1 }1 n5 k  O" B& k/ C5 T) k( y
  13.         if(Fault_Type == MC_SPEED_FDBK)
    % b: `% c, B+ l" H6 p
  14.         {+ a: F5 M9 n. w. h- k
  15.                 //MCI_FaultAcknowledged(oMCI[0]);
    5 m$ W2 Z$ |' B* V  t' @' H
  16.                 //MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);& ^& O" H; L9 }9 K$ T  n- k
  17.                 //MCI_StartMotor(oMCI[0]);
    3 H# b$ R9 u; @+ `5 e
  18.         }
复制代码
将程序写好后,下载到板子中,我们可以看到致故障的上位机界面, y0 e6 c9 @8 I
致故障.jpg
$ E4 f3 ^3 w2 P3 P" G然后我们将下面的代码下进板子中
0 t6 ]- Q3 n7 S, _  f3 z
  1. //TASK3 源码  E3 y$ Z- c5 |
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);- E5 _: K8 O! l: I/ K" @/ o) s8 P
  3.         MCI_StartMotor(oMCI[0]);0 H5 @, k. E$ c; v+ Y
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);
    % L8 W4 S0 \2 }% L
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);% c( R$ F+ b3 F2 y) H# X7 S
  6.         //STM_NextState(oSTM,STOP_IDLE);
      I+ l8 q$ x2 ~
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );! A0 `" P+ p& i* m" m9 `
  8.         while(1)" X6 r" @( {4 e% w* N: @* j
  9.           {& E3 k6 S, Q( U' a/ B+ R4 \
  10.                 9 c4 `; G( ~4 h0 t! Z* N
  11.                 5 ~6 k* x1 z% X2 v" ?5 O$ x* h
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);
    / l; T6 x. t9 Z5 B0 L- [, H! _
  13.         if(Fault_Type == MC_SPEED_FDBK)
    / w7 h4 W' l3 _4 |& ]
  14.         {. X7 J/ Z# Y$ q1 Z- o5 B
  15.                 MCI_FaultAcknowledged(oMCI[0]);
    " l" V2 w2 J3 C- C: @# ?
  16.                 MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);8 }# F% l, y& c% O5 h( [' h& r$ o" R
  17.                 MCI_StartMotor(oMCI[0]);
    2 @- v9 U9 K- }1 A) q
  18.         }
复制代码
可以发现电机正常反转。
4 E5 n8 y& u: _关于故障代码可以参考: 故障代码查询.jpg
8 Q- x1 P9 G; b关于至状态机故障和清除故障的程序,大家参考StateMachineClass.h* R: Z$ m) _* ~$ c/ H( z" m
  1. /**
    3 E. Y2 C* O1 E* V: Q! r- `
  2.   ******************************************************************************
    + m6 s9 s4 b; a& W; \* n  G. d
  3.   * @file    StateMachineClass.h; ^: Z1 L) M; V% d% Y
  4.   * @author  STMicroelectronics - System Lab - MC Team6 p0 d' M; D7 A) i* v9 f
  5.   * @version 4.3.0( a% ?( u6 |4 z, p! Q; H) s
  6.   * @date    22-Sep-2016 15:292 ~6 @; S2 i. x# G. }, @
  7.   * @brief   This file contains interface of StateMachine class      0 D- [! u, e/ k/ W8 l
  8.   ******************************************************************************
    # e8 {4 Z" A6 c/ X, V2 F) X
  9.   * @attention
    6 [. n/ n# y' N( D4 C# O
  10.   *
    # q2 O& O( ~( ^- X
  11.   * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>% N, S) C( T' ]5 P& X! m
  12.   *6 J; t: I( o1 C5 ]) K$ u/ U
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");; ]% J6 ]/ [" w# j" x9 O
  14.   * You may not use this file except in compliance with the License.+ ^# {  S, B. O! a( C: P
  15.   * You may obtain a copy of the License at:
    9 y  f! H) I! l* X
  16.   *$ w+ h6 V* C/ O6 T  b% `0 p& D
  17.   *        http://www.st.com/software_license_agreement_liberty_v2
    , ^! x' ?+ R: s9 I/ ^% q  C& Q
  18.   *
    , q4 ]3 b4 a6 ]% k
  19.   * Unless required by applicable law or agreed to in writing, software * s- n, ~7 N& X" V  b
  20.   * distributed under the License is distributed on an "AS IS" BASIS,
    % c" x0 n3 q3 [- V% ^
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    ' ?  m9 I: z" a! e& G, D
  22.   * See the License for the specific language governing permissions and; v2 f; a% B0 t- t, W* G
  23.   * limitations under the License.( a, b$ ^- v" `! F8 H. W
  24.   *- ]+ s0 d# @, |) r1 r* I: g
  25.   ******************************************************************************
    8 h+ ?( W. N2 C  `. b+ m
  26.   */% u+ y6 U( F3 w: b2 x
  27. ! x8 X! L: J- r9 u
  28. /* Define to prevent recursive inclusion -------------------------------------*/
    / L- w7 a- O& ?; _3 `
  29. #ifndef __STATEMACHINECLASS_H3 G! r& R  w* [9 E1 P/ g" c
  30. #define __STATEMACHINECLASS_H, L3 ~+ M# @. v" K# J* E

  31. + F8 c0 w' }* O2 S8 D9 f3 J5 h1 V0 H
  32. /* Includes ------------------------------------------------------------------*/$ [' F$ J/ k1 r% t8 q
  33. #include "MC_type.h"! g+ |/ c- U, o" E  j1 n
  34. - M' [( m' ]: }, l# p! K6 Z: c7 K) O1 E
  35. /** @addtogroup STM32_PMSM_MC_Library
    2 D6 B# N' {6 h% M, G8 H, ]) }# i& s
  36.   * @{
    : {9 \: M4 I, _. d' P% V/ M
  37.   */: Y1 {( }: X/ c% [- o
  38. # G  v' q3 }" j$ ?* V
  39. /** @addtogroup StateMachine# T& k8 }4 c: o9 m: z( l
  40.   * @{" I: t6 O; ]- d* w
  41.   */
    - G2 u) n5 c" V5 Z3 ~

  42. : Y& E2 S0 Z! b" J+ ^! l- p" `
  43. /** @defgroup StateMachine_class_exported_constants StateMachine class exported constants# ^% \- ~5 A1 v* W' j
  44.   * @{
    # q1 S$ ^& L5 [5 g2 e0 G
  45.   */
    ! Z* x3 [2 ^  f7 S$ r
  46. ( W% }* j5 h6 W' e; ]
  47. 1 A* `0 h( c0 q5 ?/ ~4 L) i
  48. /**
    " u. k$ D4 G$ V- S# _
  49. * @}9 T2 |7 @* f2 i0 o! o
  50. */
    7 _$ ^8 R: ~8 X1 P
  51. , ?0 O2 H, ?4 S0 Q2 N: q
  52. /** @defgroup StateMachine_class_exported_types StateMachine class exported types# m$ B* l4 ^5 H  w. D2 G# G3 J
  53. * @{
    ) d. c4 {$ n1 J- M. V* i1 r
  54. */% u2 _2 `( D1 K3 l) N
  55. : E! [9 ^) @4 i" o/ x
  56. ( k4 S+ ^/ G. w, I4 z
  57. /**
    " ]) g& z9 c9 ]% r* k' _7 _5 z6 i
  58.   * @brief  Public StateMachine class definition 1 v# {! O; v# R$ G8 F: n
  59.   */
    9 T  X/ W! P4 Y, `
  60. typedef struct CSTM_t *CSTM;% ^! E; E8 s; k2 g$ {

  61. 1 g5 a; J0 H( }0 q
  62. /**
    5 y4 L4 u& e  B( O
  63. * @}
    : m! r, N" E0 n9 |
  64. */
    1 q5 Y! W4 G# n0 T, Y7 N

  65. " v1 ^" l+ ]8 l% C/ {% R
  66. /** @defgroup StateMachine_class_exported_methods StateMachine class exported methods  R& P, @. e" {5 d
  67.   * @{. [- o8 K9 t% y8 y) g
  68.   */
    ( x6 K% o2 c4 y' M; e8 a" ?

  69. ! K2 {2 U- b. E+ o, e
  70. /**
    # b2 Z9 [2 l# R+ ]2 a3 E' L" k4 s
  71.   * @brief  Creates an object of the class StateMachine.! j$ r  ~2 G  d$ f4 O
  72.   * @param pStateMachineParams pointer to a StateMachine parameters structure.7 m1 j5 B% ]$ q3 ^* i; T
  73.   * @retval CSTM new instance of StateMachine object.
    ) a) ~: r4 j% ?: Q- S
  74.   */
    ; D! k, I4 R) B8 T2 v
  75. CSTM STM_NewObject(void);! C6 Z) K" _3 b7 d$ n) R+ `0 }0 `$ H

  76. 2 z1 L9 g( t! p- N; s
  77. /**
    # I) d8 Q  T! ?9 v* P9 K) H4 Z& V( h
  78.   * @brief  Initializes all the object variables, usually it has to be called : ?+ R8 d/ b0 E4 |5 E
  79.   *         once right after object creation.& b' N' |0 s+ L. C8 x
  80.   * @param this related object of class CSTM.  m0 t" Y, y, x- Y& {. n4 l2 n" |" L" Y
  81.   * @retval none.8 W2 G- O6 k- O
  82.   */
    0 B+ Y5 `( F  m4 ^/ `. U
  83. void STM_Init(CSTM this);
    $ j$ }7 K3 u: k0 J4 E/ k' q1 t

  84. ) U; b7 I5 }1 w2 i% L
  85. /**
    : h+ t2 Y2 o% J- d
  86.   * @brief It submits the request for moving the state machine into the state ! H+ y+ d9 L6 {8 ]+ M' N
  87.   *        specified by bState (FAULT_NOW and FAUL_OVER are not handled by this
    : ^) V4 o  @* {% @, e0 L6 P
  88.   *        method). Accordingly with the current state, the command is really
    . u7 m$ q+ \: O9 a' y
  89.   *        executed (state machine set to bState) or discarded (no
    ) |9 B$ d# G/ k! `
  90.   *        state changes)
    2 D  O) q: u8 T
  91.   * @param this related object of class CSTM.1 K: t, Q, `$ ]) c$ n
  92.   * @param bState New requested state( E8 Y7 v& S4 V# g6 f# t
  93.   * @retval bool It returns TRUE if the state has been really set equal to 5 i1 l9 {) V  z/ i
  94.   *              bState, FALSE if the request has been discarded9 x3 F1 q, @; V! \, l
  95.   */
    * t* |! u9 ~8 d/ O
  96. bool STM_NextState(CSTM this, State_t bState);
    . ~. g: |& n% T8 m7 q' \

  97.   {9 i, M" {* J  L' T) G' b
  98. /**
    3 `) l$ y. B2 \1 L2 E# w9 L
  99.   * @brief It clocks both HW and SW faults processing and update the state 6 i+ k6 K$ @/ T, u- Y6 P
  100.   *        machine accordingly with hSetErrors, hResetErrors and present state. # E6 m1 Y2 q9 j  d8 x* w1 J
  101.   *        Refer to State_t description for more information about fault states.1 G2 l8 E$ u  O# a# d( o
  102.   * @param this object of class CSTM
    1 Z. n1 p# S" T/ u, I/ [
  103.   * @param hSetErrors Bit field reporting faults currently present
    * y5 m- x' n: J5 d
  104.   * @param hResetErrors Bit field reporting faults to be cleared
    ) r; ?) f& }0 j- ]6 Z
  105.   * @retval State_t New state machine state after fault processing  ~$ e& f7 @* l5 R% b, B& E& v+ V
  106.   */
    7 n+ D: Y6 e" I9 |
  107. State_t STM_FaultProcessing(CSTM this, uint16_t hSetErrors, uint16_t 3 ]* T& {' v" E. b' F* X; h
  108.                                                                   hResetErrors);- Y; D4 p% i0 i2 L
  109. ) |- |3 X  s3 ^0 l
  110. /**" J/ T! y/ u( E7 i. f" _" Q6 x
  111.   * @brief  Returns the current state machine state9 `1 o- L* s1 ~; D, @/ j. V
  112.   * @param  this object of class CSTM
    - \7 q" r! V5 m- B, x
  113.   * @retval State_t Current state machine state
    + v2 Z7 b$ v  E% ~0 m" x4 b) o
  114.   */
    ) g) R+ l1 A5 s( Z+ n
  115. State_t STM_GetState(CSTM this);
    ; ^' {* X, I+ E

  116. / C5 D) P0 ], O  D
  117. /**: b# y2 ~* O: t9 b
  118.   * @brief It reports to the state machine that the fault state has been ) Z7 I; M3 ?$ E, |# Q/ q" j; n
  119.   *        acknowledged by the user. If the state machine is in FAULT_OVER state' \% [+ I2 l0 z/ M( R& w
  120.   *        then it is moved into STOP_IDLE and the bit field variable containing / J! r) o$ X. U2 r, ~; l
  121.   *        information about the faults historically occured is cleared. 0 ^2 v2 p4 U* [2 }
  122.   *        The method call is discarded if the state machine is not in FAULT_OVER9 g) q' M2 [; u% [
  123.   * @param this object of class CSTM
    " J" s3 L4 K! g
  124.   * @retval bool TRUE if the state machine has been moved to IDLE, FALSE if the 3 e% e6 U5 e6 s  @
  125.   *        method call had no effects   B+ \1 _( v9 O0 l
  126.   */; w5 z; X$ w, W1 p4 }+ Z
  127. bool STM_FaultAcknowledged(CSTM this);
    ' q, g, v% b1 x3 _! a, a
  128. * B6 d1 @1 b2 @3 `2 I
  129. /**
    $ ]! D' z. l4 @1 E* H  N  N2 N
  130.   * @brief It returns two 16 bit fields containing information about both faults
    6 A0 q' {! n5 t3 I& o, S
  131.   *        currently present and faults historically occurred since the state * l( O/ v9 v( h7 s$ I+ s
  132.   *        machine has been moved into state
    " G+ M9 k' Y+ j# |8 `  D" k% H
  133.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    $ J4 T5 h9 C5 C6 u8 y
  134.   * @param this object of class CSTM.
      F' X/ s( H* Q2 |5 Y% g* s
  135.   * @retval uint32_t  Two 16 bit fields: in the most significant half are stored
    2 n/ }+ U, b3 Y" I) s- V, m
  136.   *         the information about currently present faults. In the least
    - w  J  Q: f& h" H, g: j* M
  137.   *         significant half are stored the information about the faults 5 s+ _. a) t8 T
  138.   *         historically occurred since the state machine has been moved into ! w! C- r- y9 ^& N3 l2 [  {/ y
  139.   *         FAULT_NOW state
    6 }2 O* O- E" G" L& ^* n
  140.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink  V: @5 i/ ]9 D* w5 ^# N
  141.   */$ z. h6 O' O/ V% i' L8 t
  142. uint32_t STM_GetFaultState(CSTM this);# ^% ~- E: w, l* x7 W. {

  143. " s! o3 U1 z) R- b
  144. /**
    ! v; P7 C0 X. z. L
  145.   * @}
    ; }% L7 S7 R6 ~8 ?. U% b
  146.   */8 L& |2 o* K$ T, ~
  147.   
    2 {1 T- O# t( N/ G- q# L( K
  148. /**- I7 O/ ?/ R2 p# p, E$ ^" [
  149.   * @}
    7 e+ @6 z, c% Z' r$ z; ?1 i
  150.   */
    & K& p  p1 ^' I

  151. " K/ w  K; b; e- t  W" B
  152. /**
    2 Z* @) |3 ?- q
  153.   * @}
      E0 X! m* J+ M, T$ f
  154.   */; U( p3 J+ {2 u3 p

  155. ) y; M# @: {/ d% S, y8 g; {
  156. #endif /* __STATEMACHINECLASS_H */7 ~5 F# p+ j6 x! X+ p, c

  157. 8 y6 D$ F  [) K/ }) t- P
  158. /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/+ f4 B' v( U3 m2 t7 a9 M% e! L) p0 P
复制代码
4 ]! c2 H! V9 V4 M
状态机看这个图: 状态机.jpg 5 V1 l: f0 ~) l; s6 A& B6 B3 e
. m2 v) f3 g% J* V8 ?, B$ J( ^

1 Z1 x# X, D2 h( L* u
& r( s! B  R/ r  A$ ^' f
努力的人 回答时间:2017-8-28 13:57:18
本帖最后由 努力的人 于 2017-8-28 15:19 编辑
  o8 S8 \2 ^8 \; g% Q
1 n+ Y3 H8 L6 |; S! j0 B: ]' i2 Z8 i二、TASK1 5s转动、5s停止       
/ K; n7 T; v/ }$ D) J  b
$ R+ \: m# P3 J9 @5 E* t
    首先上传一下源代码,因为systick的500us的定时与SDK中一些任务的处理速度相关,这里我觉得还是不要修改定时时间比较好,我的代码如下:
1 ]" C' n& q3 x( H: U* X# j  I4 U说明:在main.c中定义uint16_t mytime; 在stm32f30x_it.c中定义extern uint16_t mytime;5S就是10000*500us,所以就可以转5S停5S了1 K# @) E8 g$ |' E
  1. //TASK1 源码; u# c1 ^; U  F7 P# S. \
  2. /////main.c/////////////// C5 b. q& l; K! F. V5 P
  3. uint16_t mytime;$ Y8 f+ Z# ?! p5 j" h, y( c6 Z
  4.   while(1)* S1 B) E% i4 Q! S
  5.   {
    6 J% }/ k8 @! h' U: m. M" A
  6.                 if(mytime==0)2 M6 u/ P8 D- r1 ?0 T8 f" y$ O
  7.                 {$ l, `) y7 K* V0 f3 x0 {
  8.                         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);
    - }2 u0 A6 k# N
  9.                         MCI_StartMotor(oMCI[0]);
    / c' S6 {0 D. B6 t
  10.                 }
    $ Y3 j  Z+ ~" G1 w9 Z
  11.                 if(mytime==10000)
    % T2 K; C9 o* |5 k$ I+ h
  12.                 {
    " x' Y( u# J. G  F# a
  13.                         MCI_StopMotor(oMCI[0]);; w* g: v" w( @' H7 q( P: t
  14.                 }4 _5 W6 w) f3 y9 F  S, W

  15. . k+ O5 a* ]! M1 t  M7 X
  16.    ' w5 |4 {; s' R& `. {4 s% _
  17.   }
    / v' {* v2 J7 H+ `/ X' S
  18. //stm32f30x_it.c
    6 C1 h% n, W/ z
  19. extern uint16_t mytime;" z! R; F6 M- C: f# l  a1 @2 b
  20. void SysTick_Handler(void)$ B! a; M- ]. C# R
  21. {* L! P& u( F/ _  [) y3 |
  22.   TB_Scheduler();
    7 r7 F$ Z+ s* f8 ]' K
  23.         mytime++;2 C( Q$ e; ~% X+ s6 `
  24.         if(mytime == 20000)1 i, F- L8 M% s; l/ U4 h0 u% p- J
  25.         {mytime=0;}
    7 ~7 F! h3 ~3 t1 u/ A! H
  26. }
复制代码

7 h# ]' ?0 ?' r视频:
$ }; T- }# m4 H2 \6 I
* \  |- Y9 `. s
+ C( U/ K) i5 k+ P& m4 \% q& X8 J! ?7 j4 z
努力的人 回答时间:2017-8-28 13:57:36
本帖最后由 努力的人 于 2017-8-28 14:36 编辑
: U1 x# n+ p! J2 W( G! A$ f
( G0 U- v5 P1 g0 V- `+ Y三、TASK2 PID参数的调试
6 R3 `3 R6 D7 u0 R- h" T* S6 S    任务2的代码如下:& I3 [8 a' p9 R5 `% h8 L' h, r& b
  1. //TASK2源码3 S2 t, N, [6 _
  2.         static int16_t Speed_Kp,Speed_Ki;
    8 B- i( w# w7 e; @" C0 P  S6 d
  3.         static CPI oPItuning;
    " i+ g& @% g' M' W3 M
  4.         oPItuning = MCT_GetSpeedLoopPID(oMCT[0]); // ????PID???
    1 {$ x0 T5 O! \$ a: L
  5.         Speed_Kp = PI_GetKP(oPItuning); // ????PID??
    ! c( J0 o: H; i# p
  6.         Speed_Ki = PI_GetKI(oPItuning);
    ! G1 y) s* z8 O2 p" A$ |2 y7 Y$ T
  7.         PI_SetKP(oPItuning,Speed_Kp); // ??PID??
    ' L1 e6 Y( ~& }% `; N
  8.         PI_SetKI(oPItuning,Speed_Ki);
复制代码
这里我们首先看一下原始PID参数的速度曲线,从图中我们可以看出转速的超调比较大,已经达到4000多转- R4 I% M: Y- d! i  H& o
原始PID.jpg    原来的PID参数.jpg $ p# ]! T* y/ C, g. d; l. E/ Z
接着我们修改程序,将程序设成2倍的PI参数(左图)和0.5倍的PI参数(右图)
+ v& k* T8 s8 h4 a& R# ~ 2倍PID参数.jpg    0.5倍PID参数.jpg : y; ~  J. T6 G% t5 f" Q: G
从图中可以看出,增大倍数的PID参数比减小的好,所以我们接下来将PI参数往大了调,分别作了2.2倍,2.5倍,2.9倍的速度曲线图- M3 U' j, ?8 i1 y2 |0 j
2.2倍PID参数.jpg & G# z2 E7 M, I/ Q! b
2.5倍PID参数.jpg
" Z. M$ G) @/ q' O) m% w/ S 2.9倍PID参数.jpg 5 [- C- ]  Q1 }" t( \7 ~( M" L, Q7 G
我们还想让超调小一点,所以我减小了一点P参数,最终得到这个速度曲线,我们通过上位机可以看到调完的参数,最后将程序中默认的PID参数改成我们自己的。
* V# v( B6 D4 T# a+ ?/ w& v 最终确定的PID参数.jpg   ( R- d" a& G6 z
程序最终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& j8 b6 H$ b* D' _! _% J4 N* ?6 X
看了楼主的帖子学到了不少东西
  s. J6 G9 m8 P, T
这就是互相分享的意义呀
donatello1996 回答时间:2017-8-30 23:35:37
努力的人 发表于 2017-8-30 21:24( @, t  g' `- b- j, F& c! w  X2 I
这就是互相分享的意义呀

8 ?4 p6 {. Y. H: m3 z1 Q6 `; V" U对了楼主知不知道在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 手机版