'm having some trouble adapting the new IMU v3 to Jean-Louis' code written for tricopters. His code used the APM_Compass library and for some reason, it wont compile with any reference to that library. The new IMU doesnt use that library, so I havent let that stop me from trying. It compiles and gives me output, but something is still wrong. The debug wont print GPS and the attitude values although stable seem way off. I'm hoping some experts can look at my code and tell me what's wrong or even what is right.
I've included the code I have now. Please help if you can.ardimupter-120708b.zip
I figured out why channel_filter was not considered declared and that was because the function wasnt anywhere to be found. I added it and at least it now will understand when throttle comes in on channel 1.
I still havent figured out how to get it to recognize Heading instead of the APM_Compass baloney. If I can do that, then the only hurdle left is getting serial PPM into the board.
The only thing that doesnt work right now is Magnetometer Based Heading Lock, but there is still inertial heading lock. This is the best I can do at the moment.
OK, figured it out. Heading is defined as float Heading, but it wasnt defined until after this line tried to use it.
if (hmc5843ok==1) err_yaw = TargetHeading - ToDeg(Heading);
Compiler cant compile something it doesnt know about, so I told it what it wanted to know where it wanted to know it.
I wont be able to test this for awhile, have to wait for a PPM out Rx.
I've got a PPM encoder on the way. This is the one:
I didnt choose the DIYDrones PPMencoder because the instructions are geared toward Paparatsy and I found the Quadro for a bargain. I still need some pin headers so in the end the cost is equal.
Here's a shot of the ardimupter outputting Rx debug. There is no Rx hooked up of course.
I had to start over. I kinda have it working, but it only starts one ESC. The good news is that if I move the IMU, that one motor responds. I tried Jose Julio's MiniQuad program just to see if it would start the motors and it does. I really dont know why this tricopter version doesnt send low throttle to all the ESC's.
Hello Harry, you look all alone here :-) Care for an audience?
I am very interested in your project as I would like to do the same thing more or less in parallel, with the exception being that I would like to use the ArduIMU+ V3 as a standalone stabilization and servo mixer (CCMP) for my Align 250 helicopter. I'm just tired of crashing it LOL. I have both flybarred and flybarless 250's, but the 3GX does not autolevel as it only has gyro's and no accelerometers...
I have no coding experience other than reading about half way through "Learning the C programming language" so I am not sure I can be of significant benefit to your tri-copter project, however I am a quick learner and it is the reason why I chose to pursue the Arduino UAV projects in general, I just went the traditional heli route because I've always loved them.
Jeff, I dont know that much either and some have even been so kind as to tell me that even when they were wrong about something. So nice and helpful.
The problem I'm having is the thing only arms one motor, really frustrating. If I could get the other motors to start, I'm almost 100% it would stabilize since it shows good attitude data and the one motor responds to attitude changes.
As for what youre trying to do, I might be able to help some. How many servos are involved? The trick would be picking good PID numbers and the stabilization part would probably need rewriting. That's not that big a change to someone who understands control for helicopters. I'd have to see lots of examples, maybe the Arducopter code has clues.
I think taking examples of code from any of the Ardupilot platforms should show the mixing algorithm for a 120 degree swash plate, I wouldn't expect it to be cut and paste but not too far from it. I would have to find them in the code first and wrap my head around how they are used in the APM 2.0, not a small task for a newb but I need to get my feet wet somewhere :-). The heli uses 4 servo's, three for swash plate control and the forth for the tail rotor. I can get a 6 channel PPM signal from an HK receiver that will bind to my TH9X though I am working out how to get the full 9 channels of PPM from the tiny 3ch HK receiver that will also bind to the TH9X, but that is not of consequence to this project :-)
PID's I could copy from a functioning APM 2.0 mounted and wired to the heli assuming the PID algorithms are a copy anyway. The IMU6000 should act the same on both boards.
On your arming issues I have come across a thread or two about the min/max values not being set correctly for all output channels. I can go looking for them again if that would help but I suspect you may already know where to find them in the tri-copter code?
I haven't ordered my ArduIMU yet as I was holding off on a purchase until the APM 2.5 is available (later this week rumor has it) and I need to get an assortment of USB programmers too. I suppose I could order some stuff from spark fun now and just get the APM 2.5 from DIYdrones when it shows up...
If I got the ArduIMU now I could at least scope the output channels using your code to see what the ranges are for the three ESC outputs on startup.
Yeah, cut and paste is good to a point. I just did a test using the AutoStab, which is for a bicopter. Jean-Louis took his tricopter code and changed it to run 2 ESC's and 2 Servos. I loaded it up and it armed each ESC even though one is in the servo spot. I looked for what is different and there is 4 lines that constrain the output, min/max. The minimum seems to be why it's not working on the tricopter. I'm going to see if I can constrain it like it is in the bicopter.
Well you should be playing with the PID's in fairly short order then :-)
I went over and got sucked into spark fun for a bit, seems I'm going to need to take the wife out and buy her something if I want to get away with spending like I want to. I was good and kept everything in the "wish list" and not the "cart" for now.
I think I will take some time tomorrow and look through the tri-copter code you posted up and compare it to the APM 2.0 code to see where the similarities lie, it occurred to me that the three motors separated by 120 degrees and the three servo's working the swash plate have very similar functions as far as controlling the craft. I think the major difference is in how the yaw terms are handled as in a tri-copter they are applied to the three motors respectively and in a traditional heli the yaw terms are isolated from the swash plate.
I know they just updated the traditional heli yaw algorithms in the 2.7 code so I should be able to spot the changes versus 2.6.
P.s. what Tx/Rx are you using for your tri-copter and how many PPM channels are you putting into the IMU?
I was looking at your PPM adapter and thought you might get a kick out of my HDMI cable to APM 2.0 so I could put it wherever I needed to on my 600efl. I managed to get 7 inputs and 7 outputs plus the power all individually shielded and in a single cable. I was a little cross eyed by the time I was done, but it all works flawlessly :-)