NHK2021_ikarashiSolenoidValve
Dependents: NHK2021_ikarashiSV_code NHK2021_ikarashiSV_code_withservo 2021NHK_B_syudo
ikarashiSV.h@8:f276fe03c43d, 2021-10-23 (annotated)
- Committer:
- ikarashikota
- Date:
- Sat Oct 23 03:38:23 2021 +0000
- Revision:
- 8:f276fe03c43d
- Parent:
- 7:58da8ee2b38d
- Child:
- 9:252dd0bc8f93
add solenoid class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ikarashikota | 0:2b253298d427 | 1 | /** @ikarashiSV.h |
ikarashikota | 0:2b253298d427 | 2 | * |
ikarashikota | 0:2b253298d427 | 3 | * NHK2021Bチーム 電磁弁のライブラリです |
ikarashikota | 0:2b253298d427 | 4 | * @attention 回路が悪いのか電磁弁が悪いのかわかりませんが、訳あってpin_c,pin_dの代入値を本来とは逆にしています。 |
ikarashikota | 1:696f7c0ab1bd | 5 | * 追記 なんか治りました |
ikarashikota | 0:2b253298d427 | 6 | */ |
ikarashikota | 0:2b253298d427 | 7 | #ifndef ikarashi_SOLENOID |
ikarashikota | 0:2b253298d427 | 8 | #define ikarashi_SOLENOID |
ikarashikota | 0:2b253298d427 | 9 | |
ikarashikota | 0:2b253298d427 | 10 | #include "mbed.h" |
ikarashikota | 0:2b253298d427 | 11 | |
ikarashikota | 0:2b253298d427 | 12 | /** ikrashiSV |
ikarashikota | 0:2b253298d427 | 13 | * |
ikarashikota | 0:2b253298d427 | 14 | * 電磁弁が動かせます |
ikarashikota | 0:2b253298d427 | 15 | */ |
ikarashikota | 0:2b253298d427 | 16 | class ikarashiSV |
ikarashikota | 0:2b253298d427 | 17 | { |
ikarashikota | 0:2b253298d427 | 18 | public: |
ikarashikota | 0:2b253298d427 | 19 | |
ikarashikota | 0:2b253298d427 | 20 | /** コンストラクタ |
ikarashikota | 0:2b253298d427 | 21 | * |
ikarashikota | 0:2b253298d427 | 22 | * @param pin_a 下の電磁弁 |
ikarashikota | 0:2b253298d427 | 23 | * @param pin_b ↑同じ |
ikarashikota | 0:2b253298d427 | 24 | * |
ikarashikota | 0:2b253298d427 | 25 | * @param pin_c 上の電磁弁 |
ikarashikota | 0:2b253298d427 | 26 | * @param pin_d ↑同じ |
ikarashikota | 0:2b253298d427 | 27 | */ |
ikarashikota | 0:2b253298d427 | 28 | ikarashiSV(PinName pin_a,PinName pin_b,PinName pin_c,PinName pin_d); |
ikarashikota | 0:2b253298d427 | 29 | |
ikarashikota | 0:2b253298d427 | 30 | /** 使っても使わなくてもいいやつ |
ikarashikota | 0:2b253298d427 | 31 | * |
ikarashikota | 0:2b253298d427 | 32 | * state って言いう変数に+1します(state初期値0) |
ikarashikota | 0:2b253298d427 | 33 | */ |
ikarashikota | 0:2b253298d427 | 34 | void add_state(); |
ikarashikota | 0:2b253298d427 | 35 | |
ikarashikota | 0:2b253298d427 | 36 | /** 大本命関数 |
ikarashikota | 0:2b253298d427 | 37 | * |
ikarashikota | 5:1ef248a66820 | 38 | * _state = 1 ・・・ 投げる |
ikarashikota | 5:1ef248a66820 | 39 | * _state = 2 ・・・ 戻る |
ikarashikota | 5:1ef248a66820 | 40 | * _state = 0 ・・・ 開放 |
ikarashikota | 0:2b253298d427 | 41 | * @param _state 条件分岐用変数 |
ikarashikota | 0:2b253298d427 | 42 | */ |
ikarashikota | 0:2b253298d427 | 43 | void solenoid(int _state); |
ikarashikota | 0:2b253298d427 | 44 | |
ikarashikota | 0:2b253298d427 | 45 | /** 電磁弁の状態を確認する関数 |
ikarashikota | 0:2b253298d427 | 46 | * 押していたらpushで、引いていたらpullです |
ikarashikota | 0:2b253298d427 | 47 | */ |
ikarashikota | 0:2b253298d427 | 48 | void solenoid_show(); |
ikarashikota | 0:2b253298d427 | 49 | |
ikarashikota | 0:2b253298d427 | 50 | /** 使わなくてもいい(n回目) |
ikarashikota | 0:2b253298d427 | 51 | * |
ikarashikota | 0:2b253298d427 | 52 | * @return state を返します |
ikarashikota | 0:2b253298d427 | 53 | */ |
ikarashikota | 0:2b253298d427 | 54 | int state_show(); |
ikarashikota | 0:2b253298d427 | 55 | private: |
ikarashikota | 0:2b253298d427 | 56 | int state; |
ikarashikota | 0:2b253298d427 | 57 | int _state; |
ikarashikota | 0:2b253298d427 | 58 | int solenoid_status; |
ikarashikota | 0:2b253298d427 | 59 | DigitalOut port_a;//1 下の電磁弁 |
ikarashikota | 0:2b253298d427 | 60 | DigitalOut port_b;// |
ikarashikota | 0:2b253298d427 | 61 | |
ikarashikota | 0:2b253298d427 | 62 | DigitalOut port_c;//2 上の電磁弁 |
ikarashikota | 0:2b253298d427 | 63 | DigitalOut port_d;// |
ikarashikota | 0:2b253298d427 | 64 | }; |
ikarashikota | 0:2b253298d427 | 65 | |
ikarashikota | 8:f276fe03c43d | 66 | /** ikarashiSV2 |
ikarashikota | 8:f276fe03c43d | 67 | * 下のエアシリンダー用のクラスです。 |
ikarashikota | 8:f276fe03c43d | 68 | * 1個目のクラスとほとんど同じです |
ikarashikota | 8:f276fe03c43d | 69 | */ |
ikarashikota | 7:58da8ee2b38d | 70 | class ikarashiSV2{ |
ikarashikota | 8:f276fe03c43d | 71 | public: |
ikarashikota | 7:58da8ee2b38d | 72 | ikarashiSV2(PinName pin_e, PinName pin_f); |
ikarashikota | 7:58da8ee2b38d | 73 | void solenoid(int _state2); |
ikarashikota | 7:58da8ee2b38d | 74 | void solenoid_show(); |
ikarashikota | 7:58da8ee2b38d | 75 | private: |
ikarashikota | 7:58da8ee2b38d | 76 | int solenoid_status2; |
ikarashikota | 7:58da8ee2b38d | 77 | DigitalOut port_e; |
ikarashikota | 7:58da8ee2b38d | 78 | DigitalOut port_f; |
ikarashikota | 7:58da8ee2b38d | 79 | }; |
ikarashikota | 7:58da8ee2b38d | 80 | |
ikarashikota | 0:2b253298d427 | 81 | #endif |