Dual Brushless Motor ESC, 10-62V, up to 50A per motor. Motors ganged or independent, multiple control input methods, cycle-by-cycle current limit, speed mode and torque mode control. Motors tiny to kW. Speed limit and other parameters easily set in firmware. As used in 'The Brushless Brutalist' locomotive - www.jons-workshop.com. See also Model Engineer magazine June-October 2019.
Dependencies: mbed BufferedSerial Servo PCT2075 FastPWM
Update 17th August 2020 Radio control inputs completed
Radio_Control_In.h@17:cc9b854295d6, 2020-08-16 (annotated)
- Committer:
- JonFreeman
- Date:
- Sun Aug 16 14:13:19 2020 +0000
- Revision:
- 17:cc9b854295d6
- Parent:
- 16:d1e4b9ad3b8b
August 2020. Checked Radio Control input ops.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| JonFreeman | 11:bfb73f083009 | 1 | #include "mbed.h" |
| JonFreeman | 11:bfb73f083009 | 2 | #ifndef MBED_JONS_RADIO_CONTROL_IN_H |
| JonFreeman | 11:bfb73f083009 | 3 | #define MBED_JONS_RADIO_CONTROL_IN_H |
| JonFreeman | 16:d1e4b9ad3b8b | 4 | #include "brushless_motor.h" |
| JonFreeman | 16:d1e4b9ad3b8b | 5 | extern const uint32_t MOTOR_HANDBRAKE, MOTOR_FORWARD, MOTOR_REVERSE, MOTOR_REGENBRAKE; |
| JonFreeman | 11:bfb73f083009 | 6 | |
| JonFreeman | 11:bfb73f083009 | 7 | /**class RControl_In |
| JonFreeman | 11:bfb73f083009 | 8 | Jon Freeman |
| JonFreeman | 11:bfb73f083009 | 9 | Jan 2019 |
| JonFreeman | 11:bfb73f083009 | 10 | |
| JonFreeman | 11:bfb73f083009 | 11 | Checks for __-__ duration 800-2200us |
| JonFreeman | 11:bfb73f083009 | 12 | Checks repetition rate in range 5-25ms |
| JonFreeman | 11:bfb73f083009 | 13 | */ |
| JonFreeman | 11:bfb73f083009 | 14 | class RControl_In // Class to Read servo style pwm input _____-_____ |
| JonFreeman | 11:bfb73f083009 | 15 | { |
| JonFreeman | 11:bfb73f083009 | 16 | InterruptIn pulse_in; |
| JonFreeman | 11:bfb73f083009 | 17 | Timer t; |
| JonFreeman | 16:d1e4b9ad3b8b | 18 | int32_t pulse_width_us, period_us, pulse_count, tmp; |
| JonFreeman | 16:d1e4b9ad3b8b | 19 | uint32_t state, chan_mode, stick_sense; // New Dec 2019 |
| JonFreeman | 16:d1e4b9ad3b8b | 20 | double norm, V, I, stick_deviation, stick_deviation_old; // New Dec 2019 |
| JonFreeman | 16:d1e4b9ad3b8b | 21 | double lost_chan_return_value, brake_segment, effort, stick_attack; |
| JonFreeman | 16:d1e4b9ad3b8b | 22 | double range_offset; |
| JonFreeman | 11:bfb73f083009 | 23 | void RadC_rise (); |
| JonFreeman | 11:bfb73f083009 | 24 | void RadC_fall (); |
| JonFreeman | 11:bfb73f083009 | 25 | public: |
| JonFreeman | 16:d1e4b9ad3b8b | 26 | RControl_In (PinName inp) : pulse_in(inp) { // Constructor |
| JonFreeman | 11:bfb73f083009 | 27 | pulse_in.mode (PullDown); |
| JonFreeman | 11:bfb73f083009 | 28 | pulse_in.rise(callback(this, &RControl_In::RadC_rise)); // Attach handler to the rising interruptIn edge |
| JonFreeman | 11:bfb73f083009 | 29 | pulse_in.fall(callback(this, &RControl_In::RadC_fall)); // Attach handler to the falling interruptIn edge |
| JonFreeman | 16:d1e4b9ad3b8b | 30 | pulse_width_us = period_us = pulse_count = stick_sense = tmp = 0; |
| JonFreeman | 16:d1e4b9ad3b8b | 31 | state = MOTOR_REGENBRAKE; // New Dec 2019 |
| JonFreeman | 16:d1e4b9ad3b8b | 32 | norm = V = I = stick_deviation = stick_deviation_old = 0.0; // New Dec 2019 |
| JonFreeman | 11:bfb73f083009 | 33 | lost_chan_return_value = 0.0; |
| JonFreeman | 16:d1e4b9ad3b8b | 34 | range_offset = 0.0; |
| JonFreeman | 16:d1e4b9ad3b8b | 35 | stick_attack = 0.5; |
| JonFreeman | 11:bfb73f083009 | 36 | } ; |
| JonFreeman | 11:bfb73f083009 | 37 | bool validate_rx () ; // Informs whether signal being rx'd |
| JonFreeman | 11:bfb73f083009 | 38 | void set_lost_chan_return_value (double) ; // set what 'normalised' returns when no signal |
| JonFreeman | 16:d1e4b9ad3b8b | 39 | void set_offset (signed char, char, char); // signed char offs, char brake_pcent, char attack |
| JonFreeman | 16:d1e4b9ad3b8b | 40 | void set_chanmode (char, char); // 1 Disable, Uni, Bi; 2 norm/rev |
| JonFreeman | 16:d1e4b9ad3b8b | 41 | uint32_t get_chanmode () ; |
| JonFreeman | 16:d1e4b9ad3b8b | 42 | uint32_t pulsecount () ; // will count up at frame rate when radio control all working well |
| JonFreeman | 16:d1e4b9ad3b8b | 43 | uint32_t pulsewidth () ; // |
| JonFreeman | 16:d1e4b9ad3b8b | 44 | uint32_t period () ; // checked for believable repetition rate |
| JonFreeman | 16:d1e4b9ad3b8b | 45 | bool read (struct RC_stick_info &) ; |
| JonFreeman | 16:d1e4b9ad3b8b | 46 | bool energise (struct RC_stick_info &, struct brushless_motor &) ; |
| JonFreeman | 11:bfb73f083009 | 47 | } ; |
| JonFreeman | 11:bfb73f083009 | 48 | |
| JonFreeman | 11:bfb73f083009 | 49 | #endif |