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

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

[复制链接]
努力的人 发布时间:2017-8-28 13:56
相关阅读:4 l. s9 s% }1 k* p# t$ t7 E, G
电机培训 - 三个任务主函数及中断程序
7 R$ ]4 H/ `4 }电机培训 - 让你可以深入研究的PMSM/BLDC文档8 O/ x3 K2 B8 Y' k

$ O0 O+ `# ?# IPS:如果大家觉得帖子还可以的话,请到社区之星评选为我投出你宝贵的一票谢谢
点击进入投票, o( a/ e) i3 c: [
很高兴参加了ST的电机控制培训,先上几张图,我也悄悄地在提问窗口回复了坛友的问题
1.jpg

+ x) \& z) J* F% i4 |
% y0 z( Z+ T/ K* n 2.jpg
" [, h5 d, Y2 W$ G5 o5 s
' e. z' a' u( N) p2 x8 S ST研讨会.jpg
  ?. d- _; j1 R- b( P. ^3 i下面开始步入正题吧!我的主函数程序下载 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
8 C( X* l" `6 R对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊? ...

5 m' ?; r9 Z# e' s; z! K% E 1.jpg ' m1 F1 k; S& {, h1 r
母线电压是ADC采样的
9 h1 o+ s) a% H0 V& r: y5 m所有的函数都在这里,你自己查 STM32 FOC PMSM FW library developer Help file.chm (1.14 MB, 下载次数: 78)
努力的人 回答时间:2017-8-28 13:58:01
本帖最后由 努力的人 于 2017-8-28 15:07 编辑 % T: ?! a* t' D" C6 m; T2 z6 ]

* g$ Z" l; M, [6 s+ _; fTASK3# p+ |- b) ?3 j# P
    首先还是上传一下源码1 O* S3 ?5 t' ^8 H7 g
  1. //TASK3 源码
    , }" @; q( N- t9 N$ l+ ^
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);7 I1 p4 b$ {- S
  3.         MCI_StartMotor(oMCI[0]);- |  z# P  n4 o4 C
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);# D' N; v5 i& W& I* Q# t( {
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
      h  e* m7 ^( j- d1 A
  6.         //STM_NextState(oSTM,STOP_IDLE);: M$ L( T$ Z3 _" M
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );8 q: z/ {$ e9 B( I
  8.         while(1)
    8 ]( c1 Z0 c; S0 y3 _! C* Y: P
  9.           {8 _5 k% B; ~  e  G
  10.                 ; h" a- @0 J9 V3 S
  11.                
    ! H, {: a& n# k' [, _3 D
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);6 k( k8 @' ?/ L* D8 k
  13.         if(Fault_Type == MC_SPEED_FDBK)
    0 V, H9 y+ i" y2 R4 a6 d5 g
  14.         {
    - q2 y, O3 T# I% G
  15.                 //MCI_FaultAcknowledged(oMCI[0]);* ]  \) \+ t7 k" {  `9 K  l
  16.                 //MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);- K, v. b; g; f
  17.                 //MCI_StartMotor(oMCI[0]);
    ) [, s2 L4 p6 \. u4 D7 ?
  18.         }
复制代码
将程序写好后,下载到板子中,我们可以看到致故障的上位机界面- g9 x  k" R8 ], c
致故障.jpg
0 j0 ]) q$ u- ?9 y然后我们将下面的代码下进板子中3 S1 a; I5 v* g1 F
  1. //TASK3 源码
    4 S% {8 d, g8 v* |3 r( n  u. U( {
  2.         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);$ N9 G8 d% x; {) w- [2 K
  3.         MCI_StartMotor(oMCI[0]);( _! J' w  n: f1 D  L
  4.         MCI_ExecSpeedRamp(oMCI[0],-3000/6,1000);) Z8 [. @8 V; p1 w4 J
  5.         CSTM oSTM = MCT_GetStateMachine(oMCT[0]);
    7 f/ [  V! g* q: ~. @- H- O
  6.         //STM_NextState(oSTM,STOP_IDLE);' t4 l* g- K0 L$ j  I$ Z! q; z
  7.         STM_FaultProcessing(oSTM, MC_SPEED_FDBK, STOP_IDLE );9 J2 ?  I+ i! Z% S) \# Q
  8.         while(1)
    1 Y  Q* m1 Z9 m* F9 w% f
  9.           {
    - \) ~3 T: D( Z' {0 H, ^
  10.                 # B2 I+ c8 h7 _& d
  11.                 # S- h6 N" T; l
  12.         Fault_Type = (uint16_t)STM_GetFaultState(oSTM);. m, Z; s0 Z, g' Q( e4 m' e
  13.         if(Fault_Type == MC_SPEED_FDBK)& K/ x! E6 M; k
  14.         {
    & M9 D; \6 `. L$ ~
  15.                 MCI_FaultAcknowledged(oMCI[0]);( g, N. @7 L; U  f4 Q- X
  16.                 MCI_ExecSpeedRamp(oMCI[0],MCI_GetLastRampFinalSpeed(oMCI[0]), 1000);& c$ V4 j9 q$ A
  17.                 MCI_StartMotor(oMCI[0]);
    : `# Q7 z% a- j% w0 c; P# W
  18.         }
复制代码
可以发现电机正常反转。* K6 C; z# x9 P
关于故障代码可以参考: 故障代码查询.jpg + m6 V$ M  m) l" T! D
关于至状态机故障和清除故障的程序,大家参考StateMachineClass.h
1 s. y. j; N; {
  1. /**
    2 j+ H7 e$ N# T3 ^
  2.   ******************************************************************************
    . W" m) d3 N+ c
  3.   * @file    StateMachineClass.h
    , r( ?5 @# r( D" N* R. J
  4.   * @author  STMicroelectronics - System Lab - MC Team! u4 h0 H  p" N& K0 P/ |2 t
  5.   * @version 4.3.0& K4 L5 T& v# A# U3 ~! h; V# d
  6.   * @date    22-Sep-2016 15:292 j, V# R" N) o4 C0 N3 e. X% b
  7.   * @brief   This file contains interface of StateMachine class      ( f. C( c. S( w& S1 D
  8.   ******************************************************************************
    - s* f6 d& I- P$ \- k' K0 ~) E
  9.   * @attention
    - U/ [( U6 H. V) s2 K& U, U
  10.   *
    1 s, k$ n; _7 H% ^/ ?& i, o  O
  11.   * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2>
    " M+ c+ l# t" O8 U- P
  12.   *
    & r5 N$ W# P5 p" N+ ]
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");+ r$ n/ C0 e9 }$ B- P$ y2 b) G; F  e6 `
  14.   * You may not use this file except in compliance with the License.
    3 i% V" m: @2 l  x, l  V1 G4 k
  15.   * You may obtain a copy of the License at:& b5 B. ]. l/ Y/ B( g. M2 X6 m
  16.   *
    - v1 M2 n, M% w) ^
  17.   *        http://www.st.com/software_license_agreement_liberty_v21 X8 c& V1 e7 D; P  y# \: W
  18.   *
    : p, C0 C9 b% s1 q1 d6 z
  19.   * Unless required by applicable law or agreed to in writing, software
    8 E1 w7 M" P% {9 L
  20.   * distributed under the License is distributed on an "AS IS" BASIS, * j$ k8 l, h, E4 t! |
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.0 m; n2 f& j; x! o7 @3 {" N* `( c
  22.   * See the License for the specific language governing permissions and* ]2 V( P# J1 L7 N( e
  23.   * limitations under the License.
    ( ?+ z# K; x2 t8 |/ x
  24.   *
    * n" K- w; v: R( ~2 @
  25.   ******************************************************************************
    " ~1 o6 z6 }" R  o! M
  26.   */& D" E  a' p9 B' R, z

  27. " G* X" L# B6 {7 Y# l) D
  28. /* Define to prevent recursive inclusion -------------------------------------*/9 H9 i9 d+ x  K% l5 w: U3 e
  29. #ifndef __STATEMACHINECLASS_H+ w& l- N- _( t' x! @" n  ]
  30. #define __STATEMACHINECLASS_H
    # v4 D( T; D4 W3 V$ O# ?0 k5 U6 D
  31. : H5 a! ?/ A( }, K) s4 d
  32. /* Includes ------------------------------------------------------------------*/3 I6 W8 X) Y# d2 [5 C. E, k
  33. #include "MC_type.h"
    / F( L6 v/ \9 m# P& i
  34. 1 m5 I6 D# Q( H0 }: u# e7 H
  35. /** @addtogroup STM32_PMSM_MC_Library
    4 U# f9 p3 x# Y1 w& Z1 ~
  36.   * @{8 ?/ X1 _7 t) S) t2 F& T; }
  37.   */8 {' b0 I( X0 z7 `. T
  38. / V9 |  q+ P  t/ a0 W
  39. /** @addtogroup StateMachine
    % X; V+ Y! V% c% d4 T3 z
  40.   * @{9 w4 \6 r! B) i' f  @# U" `
  41.   */9 M8 i1 x# ?1 H
  42. - S' q! M/ ~1 R9 G& K" ]( p
  43. /** @defgroup StateMachine_class_exported_constants StateMachine class exported constants
    6 s+ W& a5 U, g# a
  44.   * @{/ v" \, U. u; j% |# Z4 P! J9 Q7 K  f/ d4 D
  45.   */# X. A( b( M% ]9 Q8 M# }$ _) p

  46. 3 u3 q' n" `; J& k. Z% X! ~: B' k

  47. 3 h# Q' `. z* y8 _
  48. /**" {3 \! S. v& U# z, @4 m2 J
  49. * @}
    ! d! U' U# k$ M- D" I) H9 Q! S$ `
  50. */
    ( J( g# J; B3 O9 y
  51. 3 P: F: c. f5 k7 x* y( i/ j6 E# B
  52. /** @defgroup StateMachine_class_exported_types StateMachine class exported types! W" k6 v& {* O, ]1 e7 c
  53. * @{) r7 [4 b/ Q* ^
  54. */- ~( d$ J5 U  B) c6 R
  55. ' s% D' O" ^! }6 [5 J# z
  56. ! `+ S9 J  `1 y( [& Y8 O
  57. /**
    " O4 L; l$ q5 B, k) t9 _: _5 T8 N& G% T$ M
  58.   * @brief  Public StateMachine class definition 7 J. A8 ]- N9 N7 s) b0 ~
  59.   */
      Y3 S; F- r7 n9 ?3 S
  60. typedef struct CSTM_t *CSTM;
    % i" o- X) D  f2 j& N/ R

  61. $ @9 {, A% H6 ~& `
  62. /**; i7 O! r0 m# j1 c
  63. * @}
    * y  X% r9 s  D, G9 L2 {! y, @. ^
  64. */% G6 g' R, U* v, }; w2 e8 K
  65. , `9 O( A7 ?4 \2 X
  66. /** @defgroup StateMachine_class_exported_methods StateMachine class exported methods- @* y/ d. p: B( X. f0 `! W; K+ F
  67.   * @{
    , V/ P! H8 R( ]; B
  68.   */3 L6 [4 E# l% O2 N: B
  69. 4 S3 ]2 h3 D2 S/ C4 e
  70. /**# }! m3 k) f; ~% I% K! X5 {
  71.   * @brief  Creates an object of the class StateMachine.
    ! i3 _7 x0 |0 P& D$ Y( A
  72.   * @param pStateMachineParams pointer to a StateMachine parameters structure.; e1 U# a4 E* x6 O
  73.   * @retval CSTM new instance of StateMachine object.
    % k! n1 U# C' ?, C
  74.   */+ B* i4 r! i) D, ?. J$ b
  75. CSTM STM_NewObject(void);
    2 a% T# l& m: e+ n+ W5 h

  76. ' m6 W5 |4 ]. @! Q( T6 F
  77. /**
    7 L9 u2 [" u+ |1 ]  h# O6 m
  78.   * @brief  Initializes all the object variables, usually it has to be called
    , T3 s! c: H9 N: o% s# j; W
  79.   *         once right after object creation.: h/ L" I1 H8 _! \) O  M) _8 n3 G+ j
  80.   * @param this related object of class CSTM.
    7 E0 N8 J0 F9 K: w2 C
  81.   * @retval none.! ?3 ~9 q3 ?; v$ x$ V1 V" a2 |: `0 c
  82.   */: q6 _0 J1 A# i
  83. void STM_Init(CSTM this);& N% f: C+ N( M+ A7 @

  84. 2 y; G+ ~( B) W4 A+ ]* f, {/ ]
  85. /**
    ' _5 G* u+ G" v7 C5 y  W
  86.   * @brief It submits the request for moving the state machine into the state
    4 Z# U* N- N) N: u& f8 N3 O
  87.   *        specified by bState (FAULT_NOW and FAUL_OVER are not handled by this * b8 o! n% a' g; O1 n0 a# k
  88.   *        method). Accordingly with the current state, the command is really
    ( [0 q" B1 ]# s4 W. m- K1 B! n
  89.   *        executed (state machine set to bState) or discarded (no , D2 N/ l# Y: V1 B4 n" j2 R
  90.   *        state changes) ' d( ~4 a1 h7 s. V4 c4 g
  91.   * @param this related object of class CSTM.$ }+ E6 Q2 R) o  a( v2 r
  92.   * @param bState New requested state
      R! F8 t( `. Y
  93.   * @retval bool It returns TRUE if the state has been really set equal to
    2 n) q- l8 M& s2 v! B4 I3 p9 H8 `5 ]
  94.   *              bState, FALSE if the request has been discarded# m% \: x; X" o  D# y9 p6 e
  95.   */
    3 t+ m9 `3 ~) t" V
  96. bool STM_NextState(CSTM this, State_t bState);) R3 j- ~! k+ n4 z5 E
  97. ' g* D. R6 C8 B8 R
  98. /**( D# a' l8 Q. Z" P
  99.   * @brief It clocks both HW and SW faults processing and update the state
    ( i( e2 r; a1 ?8 o+ U; j
  100.   *        machine accordingly with hSetErrors, hResetErrors and present state.
    0 J0 a# }: a  U8 g9 u: M
  101.   *        Refer to State_t description for more information about fault states.3 [5 N: `* X' k  N6 ?3 Y6 b( G
  102.   * @param this object of class CSTM
    9 h# M  U3 o. t6 y: K
  103.   * @param hSetErrors Bit field reporting faults currently present4 `8 g" V/ J4 W, F9 V8 Y& T
  104.   * @param hResetErrors Bit field reporting faults to be cleared9 a; V0 h" Z. \/ x9 g3 H
  105.   * @retval State_t New state machine state after fault processing9 R5 d7 A! A, }* j" N7 d
  106.   */
    9 @- s; J+ S$ t$ Q
  107. State_t STM_FaultProcessing(CSTM this, uint16_t hSetErrors, uint16_t # j: b, c/ Q; q
  108.                                                                   hResetErrors);' v* M: s6 w# |, W, L- I
  109. 9 |- C2 Y6 i' T7 m, I; l
  110. /**. f7 x# b& l5 p. a
  111.   * @brief  Returns the current state machine state$ w# E- ?0 D3 C, R5 d8 W
  112.   * @param  this object of class CSTM
    / C/ \3 u  U7 z$ Q
  113.   * @retval State_t Current state machine state
    ! H" |2 E; {# U) S
  114.   */$ D8 o6 V( H7 u
  115. State_t STM_GetState(CSTM this);
    ) m: C$ R5 ]1 q; i* y6 m) k
  116. / G4 F4 `8 L& q% D# z
  117. /**
    0 J" i6 C' Y  t4 X* s
  118.   * @brief It reports to the state machine that the fault state has been ; Y& A# j  ~. R6 r3 a" ^4 z% A
  119.   *        acknowledged by the user. If the state machine is in FAULT_OVER state- n, }" \! |) U0 q: u. N
  120.   *        then it is moved into STOP_IDLE and the bit field variable containing 5 ^" L; g6 @2 a0 z" k5 Q
  121.   *        information about the faults historically occured is cleared.
    + T- T  Z: Y" Z# G: [$ u) i8 H5 C
  122.   *        The method call is discarded if the state machine is not in FAULT_OVER8 g, w; ^0 R1 I1 h1 c4 n( h" i
  123.   * @param this object of class CSTM7 c" k! E3 ~4 {4 Q! ~* X
  124.   * @retval bool TRUE if the state machine has been moved to IDLE, FALSE if the
    . l$ q5 E' }! l5 g# s" i
  125.   *        method call had no effects 3 e% B2 g( e$ t  O5 T: ~6 n
  126.   */8 j8 Q8 P  A2 @7 z2 k' _
  127. bool STM_FaultAcknowledged(CSTM this);$ L5 h# J9 _+ n' ~1 h8 ^; Q

  128. 9 t6 S" o! S# J. G+ Y4 o
  129. /**6 r4 m8 l. {) X" s& J
  130.   * @brief It returns two 16 bit fields containing information about both faults- c8 F+ m8 N) g
  131.   *        currently present and faults historically occurred since the state 0 H5 d, F+ t: A6 R4 B- n2 p
  132.   *        machine has been moved into state
    * o2 f5 R3 E* D' c6 F4 B" N
  133.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    9 X- T) I  \, P0 d7 I
  134.   * @param this object of class CSTM.$ W) ]: {& u6 V3 ?" z
  135.   * @retval uint32_t  Two 16 bit fields: in the most significant half are stored
    1 H. p* F8 `2 Q% T/ G
  136.   *         the information about currently present faults. In the least
    ) b8 j8 O3 F, F5 z; ?) D" p
  137.   *         significant half are stored the information about the faults 3 Y0 L6 X7 \0 ~' r7 M8 z  m
  138.   *         historically occurred since the state machine has been moved into
    " M2 ?! T% b1 f' C. e
  139.   *         FAULT_NOW state
    . P, K+ L5 O8 X3 p$ }6 r- X( ?3 p, B# r
  140.   * \n\link Fault_generation_error_codes Returned error codes are listed here \endlink
    5 N) h: s: B; l
  141.   */
    0 c, ?8 O# c, w1 r5 i3 e
  142. uint32_t STM_GetFaultState(CSTM this);
    7 \% C# P2 ~- n2 C( `3 v

  143. - @: b' f6 g+ q6 a1 u" I  U+ O# Y
  144. /**& G, H- d) \4 D" t. ?
  145.   * @}% J4 H/ g$ T/ u, W" G: x* F1 H
  146.   */
    # S( t" ?! v' H, @+ c7 F
  147.   
      v# `" w) W, X$ |/ w
  148. /**
    $ V- M7 k- {7 j  ^( |
  149.   * @}3 f9 w- E) K3 e2 Q; V5 l  |" X
  150.   */3 \& d( w9 w0 h/ y- _. p& I

  151. , ^, d% k* ^7 i
  152. /**1 m; ?- [0 p, w% O! y  C
  153.   * @}
    & X- X- V+ M4 H3 A& |, \; E
  154.   */4 P2 U) P# |! d

  155. . ^& j% {+ _, V! L& o- Q+ ?' o. t
  156. #endif /* __STATEMACHINECLASS_H */  k: {9 ?4 W# Q3 ~# R  p4 Y

  157. 9 ~+ ~: v# ~; \! u. D
  158. /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/9 i" @0 @' @! @" u; d0 N
复制代码

: |. g" ^) K0 Z  ]状态机看这个图: 状态机.jpg
: ^' H2 M9 q8 ^' L1 C; \. H; ?5 N6 {/ y( k4 W
5 y4 q8 y. f7 E: @; L# h9 k
. s- }# ~) ?/ Z0 b, {& u# ^
努力的人 回答时间:2017-8-28 13:57:18
本帖最后由 努力的人 于 2017-8-28 15:19 编辑 0 ]/ y% W" T( ^$ C* S

3 A4 |5 j6 P9 x0 O- P% O二、TASK1 5s转动、5s停止       
, k! _$ j& h: i' P: i1 _5 h2 o/ \

& P: T7 G& z  b' z. R    首先上传一下源代码,因为systick的500us的定时与SDK中一些任务的处理速度相关,这里我觉得还是不要修改定时时间比较好,我的代码如下:) _7 S" J6 a( f1 j; ]  e
说明:在main.c中定义uint16_t mytime; 在stm32f30x_it.c中定义extern uint16_t mytime;5S就是10000*500us,所以就可以转5S停5S了
& A- r) N) }4 q# V$ V) u% y" @
  1. //TASK1 源码' ]1 W4 K$ X' v: r$ t
  2. /////main.c//////////////: Y# v) c: W0 @& a% o3 V+ C! Z6 g; M
  3. uint16_t mytime;
    3 k: j. y1 h0 \. }+ E
  4.   while(1)5 e" X3 C; s8 O
  5.   {
    ; c: ^$ q* K5 {+ w  r
  6.                 if(mytime==0)& m1 s- N, r9 h4 B0 C, Y
  7.                 {! D6 S  L. E: x2 o! E
  8.                         MCI_ExecSpeedRamp(oMCI[0],3000/6,1000);. t7 l! }. Z! D( i# N
  9.                         MCI_StartMotor(oMCI[0]);
    $ X7 W* Q: v5 ^" ~2 e9 H6 n
  10.                 }6 u/ j" K8 T9 `2 \7 {) {
  11.                 if(mytime==10000)
    1 P1 P6 y/ e' ]$ Q0 q0 k  f5 @
  12.                 {
    % K+ C6 @, d, |
  13.                         MCI_StopMotor(oMCI[0]);6 P( e& f+ H8 E& k$ F" J
  14.                 }" I/ b) r7 j0 Q+ G% F) Q* X
  15. / z: \9 k: ~! _, D- Q  Y
  16.    
    . O# X. t$ j" n; E: e, F3 i7 n
  17.   }1 z0 \# c( u3 r2 {
  18. //stm32f30x_it.c
    4 e' f0 j: S# [
  19. extern uint16_t mytime;5 \, ^4 A+ b( E. [: x$ ]
  20. void SysTick_Handler(void); D! @2 R1 Z; v! `- q
  21. {  ?0 j. t7 Q& ?' _! l
  22.   TB_Scheduler();" P3 c7 K* h; M% P$ J( J2 A
  23.         mytime++;) R/ Q7 i, w' R  E/ t5 H
  24.         if(mytime == 20000)9 m3 Z  l, {# v9 e2 P  H
  25.         {mytime=0;}. n) Z5 i; r' b. H/ @
  26. }
复制代码

; J1 c& B  Z; h! ]6 ?视频:
3 U/ g8 [( C9 g8 z, i8 z) m/ j- V+ }& C
5 r9 }5 M9 O) d* |# d
% w# `1 R! f& X1 k- q
努力的人 回答时间:2017-8-28 13:57:36
本帖最后由 努力的人 于 2017-8-28 14:36 编辑 . N( ]5 [( `% v- A- }" F, f! J* s! \

# a7 v- }% B7 i- E8 F* _三、TASK2 PID参数的调试* H0 |2 ~( F7 t0 ~8 d9 N
    任务2的代码如下:4 ]* D5 D' }' N+ x$ N
  1. //TASK2源码
    3 }9 l! Z9 |: ~! k+ |
  2.         static int16_t Speed_Kp,Speed_Ki;7 H- K& V0 f, \! @* J7 ^
  3.         static CPI oPItuning;9 [% W! V: @' \3 B
  4.         oPItuning = MCT_GetSpeedLoopPID(oMCT[0]); // ????PID???
    ) b* E7 D- m) H8 ^4 O: m7 y
  5.         Speed_Kp = PI_GetKP(oPItuning); // ????PID??
    ) J1 K  [& O( k3 e3 v
  6.         Speed_Ki = PI_GetKI(oPItuning);
    $ V1 `7 \- a( m! w5 ?
  7.         PI_SetKP(oPItuning,Speed_Kp); // ??PID??
    - c8 s" O- b$ c) `/ G& w8 y, g
  8.         PI_SetKI(oPItuning,Speed_Ki);
复制代码
这里我们首先看一下原始PID参数的速度曲线,从图中我们可以看出转速的超调比较大,已经达到4000多转
# o8 @, N! U5 D  l' y! Y% t/ d 原始PID.jpg    原来的PID参数.jpg , \( a3 m% w% v! _( L0 \+ ~
接着我们修改程序,将程序设成2倍的PI参数(左图)和0.5倍的PI参数(右图)
2 ]. X$ T9 K9 p. d 2倍PID参数.jpg    0.5倍PID参数.jpg
, K. Y- T8 E$ T$ _: ]从图中可以看出,增大倍数的PID参数比减小的好,所以我们接下来将PI参数往大了调,分别作了2.2倍,2.5倍,2.9倍的速度曲线图
! {0 |# w; A+ I7 O6 K* `9 D 2.2倍PID参数.jpg ; D  g) \3 ]/ q# s& l9 M8 E" p
2.5倍PID参数.jpg 4 B3 B0 M2 V. C
2.9倍PID参数.jpg / K6 }, @: O9 n3 K! \
我们还想让超调小一点,所以我减小了一点P参数,最终得到这个速度曲线,我们通过上位机可以看到调完的参数,最后将程序中默认的PID参数改成我们自己的。
% d. ~, O' N" ?/ ^- W# `! s 最终确定的PID参数.jpg   
# M4 A. C6 c% a8 U7 J! f
程序最终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:531 D( \3 b& P! ^! w4 x( t4 Y: e& k0 @6 q" w
看了楼主的帖子学到了不少东西
8 Z! f; f7 a" T
这就是互相分享的意义呀
donatello1996 回答时间:2017-8-30 23:35:37
努力的人 发表于 2017-8-30 21:24& ^" d2 k0 H# L5 Q& G0 x0 m( e
这就是互相分享的意义呀
9 r2 K3 w+ u8 j+ n+ ?7 r/ Z5 U5 F
对了楼主知不知道在FOC那个例程里面监测电机转速和VBUS电压是哪个函数啊?
futuresir 回答时间:2017-9-4 09:12:18
学习了
futuresir 回答时间:2017-10-7 15:53:01
xiexiefxiang
1234下一页

所属标签

相似分享

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