dlktdr / HeadTracker

This project is built to record the orientation a FPV headset to allow the camera on your RC to follow your head movements.
GNU General Public License v3.0
368 stars 83 forks source link

(Un)plugging the USB plug on DTQSYS board affects the channel output range. #159

Open cmanley opened 10 months ago

cmanley commented 10 months ago

First of all thanks for creating this awesome firmware! I stumbled upon this bug today when checking that the pan channel of my head tracker was working in the channel outputs page of my TX16S: I noticed that the min/max range was 988 - 1976 μs (with center 1482μs) instead of the the 1000 - 2000 μs (with center 1500μs) I had set it to before in the v2.2 software. So I connected the head tracker via USB to the v2.2 application and saw that it was calibrated to a range of 1000 - 2000 μs, and then I noticed that my TX16S was also displaying that range too all of a sudden. So then I pressed the Disconnect button in the v2.2 application, and the range shown on the TX16S was still 1000 - 2000 μs. So far so good, but then.... as soon as I unplugged the USB cable from the head tracker, the channel output being displayed on my TX16S dropped back to the 988 - 1976 μs range. When I plug the USB cable back in (without even connecting with the v2.2 software), the range displayed in the TX16S goes back to 1000 - 2000 μs. Really weird. I'm not sure if this is a firmware or hardware issue.

dlktdr commented 7 months ago

I had a slightly different but maybe related issue with the Nano33BLE. When the chip has power from the USB it uses the High accuracy clock. As soon as you remove that voltage it goes to low power mode and uses the low accuracy one. Added some extra code to force the high accuracy clock at all times.

Maybe this is what is happening here too. I'll have to do some reading, the clock source used on the DTQ's nrf52850 board is different maybe that code isn't working as expected. https://github.com/dlktdr/HeadTracker/blob/7794f9cb05f8baa6c8d712f8eb96e9910c0159cd/firmware/src/zephyr/boards/arm/dtqsys_ht/src/init.c#L27-L33