Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inverting PWM Signal BlHeli_S
#1
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?
Reply
Login to remove this ad | Register Here
#2
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.
Reply
#3
What is the command for TIM_OCPolarity_High in cleanflight?

ok here is the link.
http://www.banggood.com/Eachine-32bits-F...ds=myorder
Reply
#4
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.
Reply
#5
What is a target name and how can I find what mine is?
Reply
#6
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.
Reply
#7
How do I do that?

I have just about Zero coding experience.
Reply
#8
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.
Reply
#9
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?
Reply
#10
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
Reply
#11
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?
Reply
#12
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/
Reply
#13
Will they work?
Reply
#14
That's what they are supposed to do, why wouldn't they?
Reply
#15
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?
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Convert PWM Signal to Dshot 300 celliott 5 90 27-Mar-2024, 01:00 AM
Last Post: mstc
  Help Video and Radio signal issues retrobatman 5 248 21-Nov-2023, 12:34 PM
Last Post: SnowLeopardFPV
  Help Tinyhawk 2 Indoor XM+ bind not BUT no signal for my sticks bmtbluesky 5 455 26-Sep-2021, 05:28 PM
Last Post: Rob Axel
  Antenna's signal and ground pads are shorting doronba 12 2,717 02-May-2020, 05:40 PM
Last Post: doronba


Login to remove this ad | Register Here