Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 24-Dec-2016, 02:45 PM (This post was last modified: 24-Dec-2016, 02:46 PM by JonnoSA.) I am using a brushed flight controller and I am converting it to brushless operation. The pwm motor outputs are reversed when the board is converted, so if I reverse the PWM signal on cleanflght, It will be reversed again by the board and come out the right way? Am I correct in the above? I tried the command TIM_OCPolarity_High and it was invalid. What should I do? • Posts: 236 Threads: 2 Likes Received: 66 in 45 posts Likes Given: 27 Joined: Jan 2016 Reputation: 17 24-Dec-2016, 02:57 PM (This post was last modified: 24-Dec-2016, 03:13 PM by AndreyM.) First of all, let us know what firmware target you're using for your board, and the exact board name or a link. Your idea is generally right, but i think you could undo the inversion in hardware by removing the inverters. • Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 24-Dec-2016, 03:09 PM (This post was last modified: 24-Dec-2016, 03:10 PM by JonnoSA.) What is the command for TIM_OCPolarity_High in cleanflight?
ok here is the link. http://www.banggood.com/Eachine-32bits-F...ds=myorder • Posts: 236 Threads: 2 Likes Received: 66 in 45 posts Likes Given: 27 Joined: Jan 2016 Reputation: 17 Ok, watched the video, now I understand why the signal is inverted. Tell me your target name and I'll look into CF code to determine what needs to be modified in order to get active-low PWM on motor outputs. TIM_OCPolarity_High is not a command, it's a value for initialization of PWM timer in flight controller source code, to change it you need to modify code and recompile it. • Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 What is a target name and how can I find what mine is? • Posts: 236 Threads: 2 Likes Received: 66 in 45 posts Likes Given: 27 Joined: Jan 2016 Reputation: 17 24-Dec-2016, 03:23 PM (This post was last modified: 24-Dec-2016, 03:24 PM by AndreyM.) Have you flashed your FC to the latest CleanFlight/BetaFlight? Then you should know the target name, e.g. SPRACINGF3EVO. P.S. Your's indeed is SPRACINGF3EVO. You'll have to modify CleanFlight code and flash your FC to this modified version. • Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 24-Dec-2016, 03:25 PM (This post was last modified: 24-Dec-2016, 03:26 PM by JonnoSA.) How do I do that? I have just about Zero coding experience. • Posts: 236 Threads: 2 Likes Received: 66 in 45 posts Likes Given: 27 Joined: Jan 2016 Reputation: 17 24-Dec-2016, 03:33 PM (This post was last modified: 24-Dec-2016, 03:41 PM by AndreyM.) It seems like you need to study lots of basics before moving onto this task. I could tell you what to modify in CleanFlight/BetaFlight code, but I'm afraid it won't make much sense for you. In case of latest BF, as far as I understand, it should be enough to change the following lines in the SPRACINGF3EVO/target.c file from Code: DEF_TIM(TIM2, CH1, PA0, TIM_USE_MOTOR, 1 ), // PWM1 [TIM2_CH1 (D1_CH5)] DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1 ), // PWM2 [TIM2_CH2 (D1_CH7)] [TIM15_CH1N (D1_CH5)] DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 1 ), // PWM3 [TIM2_CH3 (D1_CH1)] [TIM15_CH1 (D1_CH5)] DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1 ), // PWM4 [TIM2_CH4 (D1_CH7)]
to Code: DEF_TIM(TIM2, CH1, PA0, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM1 [TIM2_CH1 (D1_CH5)] DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM2 [TIM2_CH2 (D1_CH7)] [TIM15_CH1N (D1_CH5)] DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM3 [TIM2_CH3 (D1_CH1)] [TIM15_CH1 (D1_CH5)] DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM4 [TIM2_CH4 (D1_CH7)]
It should give you active-low PWM signal on motors 1-4. • Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 So how do I change that in the code? Do I find the hex file and then just delete the first ones and add the bottom ones? Where do I find the hex file? • Posts: 236 Threads: 2 Likes Received: 66 in 45 posts Likes Given: 27 Joined: Jan 2016 Reputation: 17 HEX is already compiled, you need to edit the C source code. This particular file is here: https://github.com/betaflight/betaflight...O/target.c • Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 So I download the file, then find the part of the code that looks like this: Code: DEF_TIM(TIM2, CH1, PA0, TIM_USE_MOTOR, 1 ), // PWM1 [TIM2_CH1 (D1_CH5)] DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1 ), // PWM2 [TIM2_CH2 (D1_CH7)] [TIM15_CH1N (D1_CH5)] DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 1 ), // PWM3 [TIM2_CH3 (D1_CH1)] [TIM15_CH1 (D1_CH5)] DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1 ), // PWM4 [TIM2_CH4 (D1_CH7)] and replace it to look like this: DEF_TIM(TIM2, CH1, PA0, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM1 [TIM2_CH1 (D1_CH5)] DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM2 [TIM2_CH2 (D1_CH7)] [TIM15_CH1N (D1_CH5)] DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM3 [TIM2_CH3 (D1_CH1)] [TIM15_CH1 (D1_CH5)] DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1 | TIMER_OUTPUT_INVERTED ), // PWM4 [TIM2_CH4 (D1_CH7)] Am I right? • Posts: 236 Threads: 2 Likes Received: 66 in 45 posts Likes Given: 27 Joined: Jan 2016 Reputation: 17 You need to download the whole BetaFlight source code, find this file, modify it, compile the whole source code for your SPRACINGF3EVO target and flash your FC with the resulting file. Just get 4 transistors and build 4 signal inverters like suggested in this article: https://quadmeup.com/simplest-hardware-i...ontroller/ • Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 • Posts: 236 Threads: 2 Likes Received: 66 in 45 posts Likes Given: 27 Joined: Jan 2016 Reputation: 17 That's what they are supposed to do, why wouldn't they? • Posts: 42 Threads: 1 Likes Received: 3 in 2 posts Likes Given: 0 Joined: Dec 2016 Reputation: 0 I know this is asking a LOT, but I was wondering, if by any chance you had the time, could do the coding for me as I have a lot to learn before I can start doing this kind of thing by myself? • |