Motorcortex Core  version: 2.7.6
wd_pulsegen.h
1 //
2 // Created by alexey on 31-8-18.
3 //
4 
5 #ifndef MOTORCORTEX_CORE_WD_PULSEGEN_H
6 #define MOTORCORTEX_CORE_WD_PULSEGEN_H
7 
8 namespace mcx {
9 
10 namespace watchdog {
11 
13 public:
14 
15  PulseGenerator() = default;
16  virtual ~PulseGenerator() = default;
17 
18  bool update(bool do_no_estop, unsigned int pulse_nr_of_cycles) {
19  // invert pulse, after N cycles
20  if (pulse_counter_++ >= pulse_nr_of_cycles) {
21  pulse_counter_ = 0;
22  pulse_ = !pulse_;
23  }
24  // apply flag do no estop to the ouput pulse
25  return pulse_ & do_no_estop;
26  }
27 
28 private:
29  bool pulse_{};
30  unsigned int pulse_counter_{};
31 
32 };
33 
34 }
35 
36 }
37 
38 #endif //MOTORCORTEX_CORE_WD_PULSEGEN_H
mcx::watchdog::PulseGenerator
Definition: wd_pulsegen.h:12