Change only some output's to brushed PWM

This forum is dedicated to all issues and questions related to your individual setups and configurations
Post Reply
Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Change only some output's to brushed PWM

Post by Cereal_Killer »

Hey guys, I need help...

Since last winter, before I was using multiwii, I've been working on a micro tricopter, it's 4" wide and PCB based with all components on the single board that also serves as the frame(it's pretty much the tri version of a ProtoX) but I had a brain fart and overlooked a very important aspect and now I'm stuck.

Note 1: I'm currently testing with a bread board and arduino nano V3, the frame PCB's are VERY expensive so I dont want to order them till they're 100% finalized, because of the intricate milling needed it's nearly $150 for a panel of 10 of 4x5.25"boards)

The issue is, I wasnt thinking about how when I enable brushed motor output (controlled via PWM duty cycle) that I would loose servo control on the 4th motor output because servo's run on the same type of PPM signal as brushless ESC (pulse duration) and not PWM at all. I need a way I can make multiwii change only three of the motor output's to PWM while leaving the 4th (for the servo) as a standard PPM signal when I enable brushed motors. How can I accomplish this? The other choice is using a stand alone brushless converter to convert the PWM signal back into PPM but it seems like, since multiwii is originally a ESC controller and only recently been made capable of converting the signals to PWM on board, that there should be a way to select exactly which output's I want converted to PWM and which I want left as a standard servo / ESC output.


Other notes:
I am currently working in MW2.4 because that's what I use on my brushless models however I can switch to any older version that may be better suited to this task. I am using only an MPU6050 sensor, no MAG or other equipment and running a 328P MCU. Currently I'm using a DSMX RX (in PPM mode) into PD2 but eventually I plan to either have the CC2500 chip on board or possible switch to a NRF24L01+ module (which would also be on board) but that's later, after I've got it flying with the orangeRx Rx module.

I have the board setup to use the standard arduino pinout for a tri-
front left motor = PB3 (D11)
Front right = PB2 (D10)
Rear motor = PB1 (D9)
Servo = PD3 (D3)

I was thinking perhaps it would be best to move the three motor output's to HW PWM pins so maybe I should swap the front right motor (PB2 is not a HW PWM) and the servo (PD3, which is PWM) with each other before going further?

Any help at all would be great guys, thanks!

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Change only some output's to brushed PWM

Post by Alexinparis »

Hi,

A tricopter on an Arduino 328p proc is handle like this:
- motor pin 9: HW PWM Timer 1/ output A
- motor pin 10: HW PWM Timer 1 / output B
- motor pin 11: HW PWM Timer 2 / output A
- servo pin 3: software PWM based on Timer0

Difference between brushless of brush output for motor is only the way Timer 1 and 2 are configured + value of motor output.
There shouldn't be any impact on the servo which uses an independant Timer.
what can you observe currently on pin 3 with #define TRI ?

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Change only some output's to brushed PWM

Post by Cereal_Killer »

Hi Alex, thanks for the detailed description of how it works. That's what I was initially thinking, any why I didn't think about how I might have an issue till just the other day (once I finally got around to building the test setup on a bread board).

Unfortunately at the moment, the most detail I can give is that the servo connected to D3 simply doesn't work, I've tried several different servo's of different kinds / brands and nothing. The thing is, I'm not very well equipped and untill my salee clone & pocket USB scope gets here from China in a few more weeks (ordered by my wife as a Father's Day present) I have no way to observe in more detail what's going on, my thoughts on the issue described above are simply what I guessed was going on.

So to clarify, it should be working already, it should be only converting the actual motor output's but leaving D2 as a standard servo (pulse duration) output? That's a relief to hear the code already does what I want but a disappointment that I'm back to square one why the servo doesn't do ANYTHING.

Will keep you updated if I make progress as I wait on tools (and again once I can answer your "what's it doing" question). Thank you!

giiba
Posts: 23
Joined: Tue Apr 22, 2014 6:20 am

Re: Change only some output's to brushed PWM

Post by giiba »

This has got me worried. I'm just putting the finishing touches on a 3d printed tricopter 70mm motor to motor using brushed motors. I need a step-up for the servo, but that should happen this weekend. Then I'm onto software.

Any chance a solution was found to this? Or was something else the issue?

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Change only some output's to brushed PWM

Post by Cereal_Killer »

I meant to update this thread, guess it was just to embarrassing...

I was using a sub micro digital servo, I never got it to run at all no matter what rate I tried running it at and I wasn't able to use the scope I sometimes have access to so i could see what was up. I had to put the project on hold while I source a new analog sub-micro size servo from China (ordered about a week ago from Ali express), I plugged an analog mini-servo in and it worked but it's the size of the back arm of my frame. I'm just under 60mm front motor to motor (rear is slightly longer cause of the yaw mech, it's 2.95" motor to motor to the front two, the fronts to each other are 2".

Do you have a pic? I'd love to see, if you don't want to post maybe we can email? I'd love to see it and to hear about your yaw mech, I'm still not happy with mine... 8.5x20 motors or smaller?

giiba
Posts: 23
Joined: Tue Apr 22, 2014 6:20 am

Re: Change only some output's to brushed PWM

Post by giiba »

Hmmm, good to know. I'm using an Emax 9251 (2.5g) servo and 6mm motors; I drilled out the srcew hole to accept a 2mm carbon rod and glued it in to make the yaw mechanism.

As it sits it'll be a touch heavy (about 2:1 thrust:weight), may switch to 7mm motors if I cannot drop the weight some.

tmp_30618-IMG_20150611_225701~011004983140.jpg

giiba
Posts: 23
Joined: Tue Apr 22, 2014 6:20 am

Re: Change only some output's to brushed PWM

Post by giiba »

Well everything fired up just fine for me. Servo works fine and the first flight was poorly tuned but functional.

giiba
Posts: 23
Joined: Tue Apr 22, 2014 6:20 am

Re: Change only some output's to brushed PWM

Post by giiba »

Your problem must be something other than the code. I've got mine flying. I need to do some tuning but with only board defines changed in the code 2.4 is working as expected for me.

Micro MWC fc
3x 6mm brushed motors w/nano qx props
1x 2.5g rotary servo

If you want to see more check:
http://www.rcgroups.com/forums/showthread.php?t=2436518

Post Reply