![](/media/cache/profiles/ibmfp2.jpg.50x50_q85.jpg)
Used to tune ESC controllers using BLHeli firmware
See https://os.mbed.com/users/4180_1/notebook/using-a-dc-brushless-motor-with-an-rc-esc/ fpr details.
main.cpp@0:58c5e839229e, 2017-05-20 (annotated)
- Committer:
- 4180_1
- Date:
- Sat May 20 01:04:12 2017 +0000
- Revision:
- 0:58c5e839229e
ver 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:58c5e839229e | 1 | #include "mbed.h" |
4180_1 | 0:58c5e839229e | 2 | //BlHeli Cable (mbed FTDI) see manual for 1-pin hookup - needs resistor? and diode! |
4180_1 | 0:58c5e839229e | 3 | //worked without resistor on my setup |
4180_1 | 0:58c5e839229e | 4 | //See https://developer.mbed.org/users/4180_1/notebook/using-a-dc-brushless-motor-with-an-rc-esc/ |
4180_1 | 0:58c5e839229e | 5 | RawSerial pc(USBTX, USBRX); |
4180_1 | 0:58c5e839229e | 6 | RawSerial dev(p9, p10); |
4180_1 | 0:58c5e839229e | 7 | DigitalOut led1(LED1); |
4180_1 | 0:58c5e839229e | 8 | DigitalOut led4(LED4); |
4180_1 | 0:58c5e839229e | 9 | |
4180_1 | 0:58c5e839229e | 10 | void dev_recv() |
4180_1 | 0:58c5e839229e | 11 | { |
4180_1 | 0:58c5e839229e | 12 | led1 = !led1; |
4180_1 | 0:58c5e839229e | 13 | while(dev.readable()) { |
4180_1 | 0:58c5e839229e | 14 | pc.putc(dev.getc()); |
4180_1 | 0:58c5e839229e | 15 | } |
4180_1 | 0:58c5e839229e | 16 | } |
4180_1 | 0:58c5e839229e | 17 | |
4180_1 | 0:58c5e839229e | 18 | void pc_recv() |
4180_1 | 0:58c5e839229e | 19 | { |
4180_1 | 0:58c5e839229e | 20 | led4 = !led4; |
4180_1 | 0:58c5e839229e | 21 | while(pc.readable()) { |
4180_1 | 0:58c5e839229e | 22 | dev.putc(pc.getc()); |
4180_1 | 0:58c5e839229e | 23 | } |
4180_1 | 0:58c5e839229e | 24 | } |
4180_1 | 0:58c5e839229e | 25 | |
4180_1 | 0:58c5e839229e | 26 | int main() |
4180_1 | 0:58c5e839229e | 27 | { |
4180_1 | 0:58c5e839229e | 28 | pc.baud(19200); |
4180_1 | 0:58c5e839229e | 29 | dev.baud(19200); |
4180_1 | 0:58c5e839229e | 30 | |
4180_1 | 0:58c5e839229e | 31 | pc.attach(&pc_recv, Serial::RxIrq); |
4180_1 | 0:58c5e839229e | 32 | dev.attach(&dev_recv, Serial::RxIrq); |
4180_1 | 0:58c5e839229e | 33 | |
4180_1 | 0:58c5e839229e | 34 | while(1) { |
4180_1 | 0:58c5e839229e | 35 | sleep(); |
4180_1 | 0:58c5e839229e | 36 | } |
4180_1 | 0:58c5e839229e | 37 | } |