Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
HbMotor.cpp@27:ff63c23bc689, 2018-12-14 (annotated)
- Committer:
- MasashiNomura
- Date:
- Fri Dec 14 12:32:27 2018 +0000
- Revision:
- 27:ff63c23bc689
- Parent:
- 25:f3a6e7eec9c3
- Child:
- 28:fdb3b144e342
2018/12/14 add AttCtrlDataArrayClass etc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takeru0x1103 | 18:5aa48aec9cae | 1 | #include "HbMotor.h" |
takeru0x1103 | 18:5aa48aec9cae | 2 | #include "fpga.h" |
takeru0x1103 | 18:5aa48aec9cae | 3 | |
takeru0x1103 | 18:5aa48aec9cae | 4 | //========================================= |
takeru0x1103 | 18:5aa48aec9cae | 5 | //コンストラクタ |
takeru0x1103 | 18:5aa48aec9cae | 6 | //========================================= |
takeru0x1103 | 18:5aa48aec9cae | 7 | HbMotor::HbMotor(UCHAR iID ){ |
takeru0x1103 | 18:5aa48aec9cae | 8 | id =iID; |
takeru0x1103 | 19:4b0fe9a5ec38 | 9 | ofs =0;// |
MasashiNomura | 25:f3a6e7eec9c3 | 10 | limitH =2000; |
MasashiNomura | 25:f3a6e7eec9c3 | 11 | limitL =-2000; |
MasashiNomura | 25:f3a6e7eec9c3 | 12 | curVal = 0; |
takeru0x1103 | 18:5aa48aec9cae | 13 | } |
takeru0x1103 | 18:5aa48aec9cae | 14 | |
takeru0x1103 | 18:5aa48aec9cae | 15 | //----------------------------------------- |
takeru0x1103 | 18:5aa48aec9cae | 16 | //モーター設定 |
takeru0x1103 | 18:5aa48aec9cae | 17 | //----------------------------------------- |
takeru0x1103 | 18:5aa48aec9cae | 18 | void HbMotor::setValue(INT16 iVal){ |
takeru0x1103 | 18:5aa48aec9cae | 19 | UINT16 val; |
takeru0x1103 | 18:5aa48aec9cae | 20 | |
takeru0x1103 | 18:5aa48aec9cae | 21 | //入力リミット |
takeru0x1103 | 18:5aa48aec9cae | 22 | if( iVal > limitH ){ |
takeru0x1103 | 18:5aa48aec9cae | 23 | val = limitH; |
takeru0x1103 | 18:5aa48aec9cae | 24 | }else if( iVal < limitL ){ |
takeru0x1103 | 18:5aa48aec9cae | 25 | val = limitL; |
takeru0x1103 | 18:5aa48aec9cae | 26 | }else{ |
takeru0x1103 | 18:5aa48aec9cae | 27 | val = iVal; |
takeru0x1103 | 18:5aa48aec9cae | 28 | } |
takeru0x1103 | 18:5aa48aec9cae | 29 | |
takeru0x1103 | 18:5aa48aec9cae | 30 | //オフセット重畳 |
MasashiNomura | 25:f3a6e7eec9c3 | 31 | curVal = val = val + ofs; |
MasashiNomura | 25:f3a6e7eec9c3 | 32 | //sp.printf("MOT [%d]",curVal);//Test Code |
takeru0x1103 | 19:4b0fe9a5ec38 | 33 | //PWM幅設定 |
takeru0x1103 | 18:5aa48aec9cae | 34 | fpgaSubProp(id,val); |
takeru0x1103 | 18:5aa48aec9cae | 35 | } |
MasashiNomura | 25:f3a6e7eec9c3 | 36 | |
MasashiNomura | 25:f3a6e7eec9c3 | 37 | void HbMotor::setOfs(INT16 iVal){ |
MasashiNomura | 24:c5945aaae777 | 38 | ofs = iVal; |
MasashiNomura | 24:c5945aaae777 | 39 | } |
MasashiNomura | 24:c5945aaae777 | 40 | |
MasashiNomura | 25:f3a6e7eec9c3 | 41 | INT16 HbMotor::getOfs(){ |
MasashiNomura | 25:f3a6e7eec9c3 | 42 | return ofs; |
MasashiNomura | 25:f3a6e7eec9c3 | 43 | } |
MasashiNomura | 25:f3a6e7eec9c3 | 44 | |
MasashiNomura | 24:c5945aaae777 | 45 | void HbMotor::setLimit(INT16 low, INT16 hi){ |
MasashiNomura | 24:c5945aaae777 | 46 | limitL = low; |
MasashiNomura | 24:c5945aaae777 | 47 | limitH = hi; |
MasashiNomura | 25:f3a6e7eec9c3 | 48 | } |
MasashiNomura | 25:f3a6e7eec9c3 | 49 | |
MasashiNomura | 25:f3a6e7eec9c3 | 50 | INT16 HbMotor::getCurrentValue(){ |
MasashiNomura | 25:f3a6e7eec9c3 | 51 | return curVal; |
MasashiNomura | 25:f3a6e7eec9c3 | 52 | } |
MasashiNomura | 25:f3a6e7eec9c3 | 53 | |
MasashiNomura | 25:f3a6e7eec9c3 | 54 | void HbMotor::setValueDirect(INT16 iVal){ |
MasashiNomura | 25:f3a6e7eec9c3 | 55 | //PWM幅設定 |
MasashiNomura | 25:f3a6e7eec9c3 | 56 | //sp.printf("MOT [%d]",iVal);//Test Code |
MasashiNomura | 25:f3a6e7eec9c3 | 57 | fpgaSubProp(id,iVal); |
MasashiNomura | 25:f3a6e7eec9c3 | 58 | } |
MasashiNomura | 27:ff63c23bc689 | 59 | |
MasashiNomura | 27:ff63c23bc689 | 60 | void HbMotor::setValueFPGA(UCHAR iID, INT16 iVal){ |
MasashiNomura | 27:ff63c23bc689 | 61 | UCHAR tmp = id * 2 + iID; |
MasashiNomura | 27:ff63c23bc689 | 62 | fpgaMotor(tmp,iVal); |
MasashiNomura | 27:ff63c23bc689 | 63 | } |