HontaiTec Quadcopters (HT F801, HT F803,...)

More
18 Jun 2015 21:46 #34327 by hexfet

Durete wrote: Just tested the emulator (very interesting thing :pinch: )
I can't see any strange behaviour. According the emulator is sending the right packet always, but in real world is not right ;)

Only way to know for sure is to look at the received data ;)

Why is the quad behavior different when the trims are fixed at 0 compared to when they are calculated to be 0? Packet timing? Some kind of packet corruption before it leaves the radio? I can't think of anything that seems very likely (which sometimes means missing something obvious).

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 02:40 #34336 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)

hexfet wrote: Thanks for testing :) We could stop here if we fix the trims to zero. If y'all are up for more investigation here's what I'm thinking. I'm fine with either choice.

Summarizing:
1) Setting channel and trim data in packet to fixed values sends "20 20 20 00 00 00" to receiver and results in no drift.
2) Setting channel data based on centered sticks and fixing trim values to zero sends "20 20 20 00 00 00" to receiver and results in no drift.
3) Setting channel and trim data based on centered sticks to "20 20 20 00 00 00" results in yaw drift.

If there's a problem it seems likely to be in the trim values being sent. Not sure what I'm missing because the trims look correct, at least with my emulator build. Durete, can you build the emulator (with the driven trims) and verify that #3 is true for your build? Greenfly you might want to try the same and make sure the result is the same. The emulator will print the packet data.
Next step would be back to a receiver capture to verify the correct data at the receiver.


I'm happy with the latest builds. What are the drawbacks with going with what we've got?

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 03:53 #34337 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)

greenfly wrote: What are the drawbacks with going with what we've got?


I guess I just don't understand the implications of the data-driven trims. That's ok... I'll get it in time. Anyway, I am ready to do receiver-side captures. I left the wires sticking out of the quad so I could fly it and/or analyze it.

Can you provide a description of what you would like me to capture?

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 05:10 #34342 by Durete
Hi guys.
@greenfly, since you have the receiver cables attached yet to your module, will be great if you can provide a receiver capture, I should fully disassembly mine to take this captures ;)
-You need to install my previous build with driven trims (RC With Trims build)
-Try to fly your F803 and confirm you have yaw drift (I have on mine, but very minor)
-Remove props, and take some SPI captures with only throttle applied (don't touch rudder stick).

Decoding this captures we will see what's the data packet received causing the very minor yaw drift.

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 05:33 #34343 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)
OK, I loaded the RC with Trims build... but I can barely tell if there is a drift. Anyway, here are three captures.
Attachments:

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 05:36 #34344 by Durete
Thanks Greenfly :)
I can't take a look now, because I'm at job.
Probably Hexfet will take a look before me.

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 05:40 #34345 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)
Is this what we are looking for?
4.895263   > RX_PAYLOAD          61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 => 40 0b 00 00 4a 20 20 20 00 ff 00 0b c5 00 0a c5 91 2b 80

Because it does not look like 20 20 20 0 0 0....

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 05:50 #34346 by Durete

greenfly wrote: Is this what we are looking for?

4.895263   > RX_PAYLOAD          61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 => 40 0b 00 00 4a 20 20 20 00 ff 00 0b c5 00 0a c5 91 2b 80

Because it does not look like 20 20 20 0 0 0....


Right!
This is the faulty packet causing yaw drift

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 12:32 #34356 by hexfet
The rounding logic is still not correct. I'll take a little time to get it right. It's working as intended for the channels, which is why they're all at 20, but in the trims if the mixer output is just barely less than zero it gets rounded the wrong way. Missed something obvious.

Need to fix the tx power adjustment too. Probably not doing it correctly considering the xn297 emulation.

Almost there :)

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 12:37 #34357 by goebish
Replied by goebish on topic HontaiTec Quadcopters (HT F801, HT F803,...)
For power, just call NRF24L01_SetPower() after NRF24L01_WriteReg(NRF24L01_06_RF_SETUP, 0x07); in init ;)

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 12:38 #34358 by Durete
Yeaahhhh, we are almost there .
Now we know where is the problem and we are not walking with blind eyes :)
Thank you'all guys for your work, I have learn a lot at this thread B)

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 16:43 - 19 Jun 2015 16:48 #34370 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)

hexfet wrote: The rounding logic is still not correct. I'll take a little time to get it right. It's working as intended for the channels, which is why they're all at 20, but in the trims if the mixer output is just barely less than zero it gets rounded the wrong way. Missed something obvious.


I was wondering if the integer math is throwing it off. Is FLOAT available? I can write a function that will work if I can store a float value.
        s32 scale_channel(u8 value, s8 rangeA, s8 rangeB)
        {
            s32 result = 0;

            float offset = (float)(value - CHAN_MIN_VALUE) / (float)CHAN_RANGE;
            if (rangeA > rangeB)                
                result = (s32)(rangeA - (offset * (rangeA - rangeB)));
            else
                result = (s32)((offset * (rangeB - rangeA)) + rangeA);

            return result;
        }

I'm not sure how to do the calculation with just integer math.

(p.s) Sorry if I'm off by a long shot... it's been a while since I did any C... I'm a C# developer these days.
Last edit: 19 Jun 2015 16:48 by greenfly.

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 18:15 #34371 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)
How about...
static s8 scale_channel(u8 ch, s8 rangeA, s8 rangeB)
{
    if (rangeA > rangeB)                
	return rangeA - ((Channels[ch] - CHAN_MIN_VALUE) * (rangeA - rangeB) / CHAN_RANGE);
    else
        return ((Channels[ch] - CHAN_MIN_VALUE) * (rangeB - rangeA) / CHAN_RANGE) + rangeA;	
}

I can build, but not test until I get home from work.

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 20:26 #34374 by hexfet
That code will give the correct result when A>B, but is off by one in the other direction. Not technically off, but not what the receiver is expecting. It wants the center value to be 0x20 whether counting up or down. This code also has the issue of rounding down just below zero, which is what's causing the final yaw drift. Not sure how expensive floats are but it might be worth looking at.

I've pushed code that has a scaling function that produces the desired results. I couldn't get to working code completely by working out the math so it's a little hacky. The pushed code has the driven trims, but it's really up to y'all with the quads to say whether it's worth leaving in. Does it make the quad "better"?

The tx power issue should be fixed. I was using NRF24L01_SetPower to change the power but not initialize it so the internal variable used by that function and SetBitrate was not being initialized. I changed the init code to use both these functions.

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 20:52 #34375 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)
Thanks Hexfet. I did not realize the issue with the center value. I'm beginning to catch on to the problems you were explaining earlier.

Do any other modules that you know utilize floats? I could not find any.

Anyway, I will build the latest code from your repo and begin testing again. Did you want me to capture the data packets again with the new build?

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 21:08 #34377 by Durete
Just tested latest code. The yaw drift has gone :)
Now is perfect, and rates seems to be a little bit improved with driven trims.
I can't test properly the power output setting, since here is night and now I'm at home, but at least when you change the power output the quadcopter doesn't loose bind, so probably is right now.
Tomorrow morning maiden flight outside with my Devo!
Hats off to you sir! :)

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 21:12 #34378 by Durete
Latest code version in case anyone wants to test:
www.dropbox.com/s/caejml2p1vwio7f/deviation-devo7e-RC2.zip?dl=0

Please Log in or Create an account to join the conversation.

More
19 Jun 2015 21:18 #34379 by hexfet
I did see some floats in the cflie protocol but didn't investigate. I may give another go at the algorithm. Probably better to pass in a rounding parameter, as the trims need to round towards zero and the channels round up.

Won't need any captures unless the drift is still there :)

Please Log in or Create an account to join the conversation.

More
20 Jun 2015 01:23 #34387 by greenfly
Replied by greenfly on topic HontaiTec Quadcopters (HT F801, HT F803,...)
The latest build looks good. No drift. Smooth flying. I think we have got it.

Great job Hexfet... thanks for all of your time and help!

Please Log in or Create an account to join the conversation.

More
20 Jun 2015 01:28 #34388 by Durete

greenfly wrote: The latest build looks good. No drift. Smooth flying. I think we have got it.

Great job Hexfet... thanks for all of your time and help!


Did you noticed any improvement on rates over stock TX? I think they are a little bit improved, so driven trims is working in this model :)
I finally tested the power output setting using my own home range test (Quadcopter inside Microwave oven :P ) and I think is working now.

Please Log in or Create an account to join the conversation.

Time to create page: 0.081 seconds
Powered by Kunena Forum