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.
Dependencies: mbed ros_lib_kinetic
interrupts.cpp@4:89ebfa37663b, 2018-03-05 (annotated)
- Committer:
- MikeGray92
- Date:
- Mon Mar 05 23:08:34 2018 +0000
- Revision:
- 4:89ebfa37663b
- Parent:
- 2:0537a8007a39
- Child:
- 6:2ffa254e8f6e
Added chat modes; Defined new limits for gimbal
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MikeGray92 | 2:0537a8007a39 | 1 | #include "mbed.h" |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 2 | #include <definitions.h> |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 3 | |
| MikeGray92 | 2:0537a8007a39 | 4 | //Stall Check Interrupt |
| MikeGray92 | 1:1ac7d472cfa2 | 5 | void hallInterrupt(){ |
| MikeGray92 | 1:1ac7d472cfa2 | 6 | if(prevPosition == currentPosition){ |
| MikeGray92 | 4:89ebfa37663b | 7 | stallcount++; |
| MikeGray92 | 1:1ac7d472cfa2 | 8 | } |
| MikeGray92 | 4:89ebfa37663b | 9 | else if(liftSpeed.read() > 0){ |
| MikeGray92 | 1:1ac7d472cfa2 | 10 | prevPosition = currentPosition; |
| MikeGray92 | 4:89ebfa37663b | 11 | stallcount = 0; |
| MikeGray92 | 1:1ac7d472cfa2 | 12 | } |
| MikeGray92 | 1:1ac7d472cfa2 | 13 | } |
| MikeGray92 | 2:0537a8007a39 | 14 | |
| MikeGray92 | 2:0537a8007a39 | 15 | //External Interrupt Counter |
| MikeGray92 | 2:0537a8007a39 | 16 | class Hall_Counter_1 { |
| MikeGray92 | 2:0537a8007a39 | 17 | public: |
| MikeGray92 | 2:0537a8007a39 | 18 | Hall_Counter_1(PinName pin) : _interrupt(pin) { // create the InterruptIn on the pin specified to Counter |
| MikeGray92 | 2:0537a8007a39 | 19 | _interrupt.rise(this, &Hall_Counter_1::increment); // attach increment function of this counter instance |
| MikeGray92 | 2:0537a8007a39 | 20 | } |
| MikeGray92 | 2:0537a8007a39 | 21 | void increment() { |
| MikeGray92 | 2:0537a8007a39 | 22 | if(filter_hall1.read_ms() > 5){ |
| MikeGray92 | 2:0537a8007a39 | 23 | if(liftDirection.read() == LIFTUP){ |
| MikeGray92 | 2:0537a8007a39 | 24 | currentPosition++; |
| MikeGray92 | 2:0537a8007a39 | 25 | } |
| MikeGray92 | 2:0537a8007a39 | 26 | else{ |
| MikeGray92 | 2:0537a8007a39 | 27 | currentPosition--; |
| MikeGray92 | 2:0537a8007a39 | 28 | } |
| MikeGray92 | 2:0537a8007a39 | 29 | filter_hall1.reset(); |
| MikeGray92 | 2:0537a8007a39 | 30 | } |
| MikeGray92 | 2:0537a8007a39 | 31 | } |
| MikeGray92 | 2:0537a8007a39 | 32 | |
| MikeGray92 | 2:0537a8007a39 | 33 | private: |
| MikeGray92 | 2:0537a8007a39 | 34 | InterruptIn _interrupt; |
| MikeGray92 | 2:0537a8007a39 | 35 | }; |
| MikeGray92 | 2:0537a8007a39 | 36 | |
| MikeGray92 | 2:0537a8007a39 | 37 | Hall_Counter_1 hall_Counter_1(PC_7); |