├── THUMBNAIL_YOUTUBE.png ├── README.md └── ArduinoCode /THUMBNAIL_YOUTUBE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonAeronautics/Part-VIII-MotorControlTeensy/HEAD/THUMBNAIL_YOUTUBE.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Part VIII: Use your Teensy to control a brushless motor 2 | 3 | This project explains how you can program your Teensy 4.0 microcontroller to control a brushless motor. The FS-IA6B receiver is used to give instructions to the Teensy, which will be in turn transformed to a PWM signal that is fed to the Electronic Speed Controller (ESC). The Youtube video below explains the electronic circuit and the necessary code. 4 | 5 | [![alt text](https://github.com/CarbonAeronautics/MotorControlTeensy/blob/bd3441c69a83f6a3bbfc8ce9fbcf490ff1b32a6e/THUMBNAIL_YOUTUBE.png?raw=true)](https://www.youtube.com/watch?v=3op6erX3gIk&t) 6 | -------------------------------------------------------------------------------- /ArduinoCode: -------------------------------------------------------------------------------- 1 | /* 2 | The contents of this code and instructions are the intellectual property of Carbon Aeronautics. 3 | The text and figures in this code and instructions are licensed under a Creative Commons Attribution - Noncommercial - ShareAlike 4.0 International Public Licence. 4 | This license lets you remix, adapt, and build upon your work non-commercially, as long as you credit Carbon Aeronautics 5 | (but not in any way that suggests that we endorse you or your use of the work) and license your new creations under the identical terms. 6 | This code and instruction is provided "As Is” without any further warranty. Neither Carbon Aeronautics or the author has any liability to any person or entity 7 | with respect to any loss or damage caused or declared to be caused directly or indirectly by the instructions contained in this code or by 8 | the software and hardware described in it. As Carbon Aeronautics has no control over the use, setup, assembly, modification or misuse of the hardware, 9 | software and information described in this manual, no liability shall be assumed nor accepted for any resulting damage or injury. 10 | By the act of copying, use, setup or assembly, the user accepts all resulting liability. 11 | 12 | 1.0 5 October 2022 - initial release 13 | */ 14 | 15 | #include 16 | PulsePositionInput ReceiverInput(RISING); 17 | float ReceiverValue[]={0, 0, 0, 0, 0, 0, 0, 0}; 18 | int ChannelNumber=0; 19 | float InputThrottle; 20 | void read_receiver(void){ 21 | ChannelNumber = ReceiverInput.available(); 22 | if (ChannelNumber > 0) { 23 | for (int i=1; i<=ChannelNumber;i++){ 24 | ReceiverValue[i-1]=ReceiverInput.read(i); 25 | } 26 | } 27 | } 28 | void setup() { 29 | Serial.begin(57600); 30 | pinMode(13, OUTPUT); 31 | digitalWrite(13, HIGH); 32 | ReceiverInput.begin(14); 33 | analogWriteFrequency(1, 250); 34 | analogWriteResolution(12); 35 | delay(250); 36 | while (ReceiverValue[2] < 1020 || 37 | ReceiverValue[2] > 1050) { 38 | read_receiver(); 39 | delay(4); 40 | } 41 | } 42 | void loop() { 43 | read_receiver(); 44 | InputThrottle=ReceiverValue[2]; 45 | analogWrite(1,1.024*InputThrottle); 46 | } 47 | --------------------------------------------------------------------------------