We all want an excelent sonar ALT-hold so we do everything to get the most acurate reading from our sonar. Move it away from the ESC's and shield your sonar cable. But how to shield?
First of all: find a 3 core shielded cable ( i sacrificed a mobile (gsm) handsfree set.
On one end make your oilpan connection, be sure you connect the shielding in the cable to 0v (the black)
I have an jst male on the oilpan side, but you can see the connection between the black and the shielding.
Next, connect your sonar the right way, and do not connect the shielding at this end, do not connect, do not connect ( did i say do not connect )
Connecting the shielding at the sonar end would cause unwanted problems and the signal quality could even be worse. Why not connect the shielding at both ends? We want to shield, and not conduct. If we had te 0v conected at both sides it is possible the shielding would act like an antenna for spikes and show-up in your signal. So if using shielded cables only connect the shielding at the end closest to te main 0v and never at the far end.
2cents from Pieter
Have you tested how much it improves the signal??
This afternoon i will fly my hex and try it. In CLI > TEST> ADC it looks better allready,
Seems a little better, but is still not rock-steady. Will setup a testrig like in this video so i can tune the PID's
I was flying above grass so there could be some interference.
Just had a second flight with the 38. Sonar seems a bit better but have to tweak the PID a little more. Over a grass surface the AH on sonar is a little to sensitive. Today in dead calm wheater loiter P and I halved to get rid of oscillation and bang on the spot. I detected some motor differences wich leads to jumpy correction. (one motor is turning heavy! but new ones have just arrived)
An other item is the following. For sonar AH the PID shold be not to fast to prevent jumping single grass leaves. But imagine the following: in AH fly forward as fast as you can (dare) and level out. The copter will rise because the props act as an airfoil.!but now the AH needs to be fast or it will decend to 0cm and make a hop to the AH level. Ever seen?
Jason, looks verry good after a motor change. Stille needs a tiny bit tuning on AH, but i now let some club members who are real quad/hexa noobs fly it in AH without any experience :)
I will likely get some flack for this one but since it is working very well for me, I thought I would post and perhaps I will get some new ideas out of it that may make everything work even better.
First things first, I'm working with a DJI F550 with a shiny new Spektrum DX8 with AR8000 receiver and TM1000 telemetry module (this was included since the whole reason I bought this radio was my old DX7 browned out and with the floating inputs the mode got switched out of loiter...translation - motors shut off at 150ft+ and couldn't break the freefall) which currently feeds my flight pack voltage, receiver voltage, and control link quality to my transmitters display.I also have the 3dr telemetry radios for monitoring and mavlink, as well as the uBlox gps(recently flashed with the GLONASS capable firmware and prepped for a test flight now)
In mounting my gps I didn't want to ziptie it to an ESC, and had some aluminum laying around so I cut off two pieces of L the same length, put them together to make a T, drilled a hole and rivetted them together, little bit of trimming to the downward side to make it flat rather than a T, and it got bolted on between the top right arm(first one during the motor test command) and the second arm.I then put the gps up on about 4cm brass standoffs so it is even above the props. Then once my sonar arrived and I did a lot of reading, I ended up with the sonar mounted to the bottom of that T using a couple of 3cm brass standoffs to stradle the T, I found that the sensor fits perfectly like this, and has about 4mm of clearance from the ground without modifying the legs.
For my cable I dug around for several hours before I found one I liked, ended up being an old school USB cable from when USB2 was brand now...so the cable is about 5mm across, and shielded. I then soldered pins to the sonar, and the smallest 10v 100uf cap directly to the back of the pins(ie put the right angle pins in, solder them in place and before you do anything else, add the cap to the + and -) I then crimped the proper pins to the + and - wires, then combined the remaining two wires in one pin, did the same on the other side leaving the cable a little(ok WAYYYYY too) long so that if I had any issues, I could easily relocate things without ruining the cable, and I can obviously always cut it to length and re-crimp...This is the first thing that could have made it end badly, my cable measures 3ft long...
Second possible mistake that I see now is what I did with the extra cable...around around it goes along the outside hex pathway 1.5 revolutions.
For this end I crimped the two data lines together, put in the - and crimped a pin directly to a rresistor then soldered the + wire to that, added a little heatshrink then crimped the shielding to it's own pin and plugged it in to a spare server outputs ground connector.
The result is working quite nicely dispite the two snafu's mentioned. At some point here I will remove the extra cable, but I definately think shielding is needed. I am very seriuosly considetring putting in your library and moving the sonar to pwm, I tried to program that myself but couldn't manage to find the right code so I abandoned trying to do that part myself. Thanks for posting your code and all the testing.