{"action":"created","issue":{"url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1186","labels_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1186/labels{/name}","comments_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1186/comments","events_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1186/events","html_url":"https://github.com/cleanflight/cleanflight/pull/1186","id":99073915,"number":1186,"title":"Loop synced to Gyro","user":{"login":"borisbstyle","id":10757508,"avatar_url":"https://avatars.githubusercontent.com/u/10757508?v=3","gravatar_id":"","url":"https://api.github.com/users/borisbstyle","html_url":"https://github.com/borisbstyle","followers_url":"https://api.github.com/users/borisbstyle/followers","following_url":"https://api.github.com/users/borisbstyle/following{/other_user}","gists_url":"https://api.github.com/users/borisbstyle/gists{/gist_id}","starred_url":"https://api.github.com/users/borisbstyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borisbstyle/subscriptions","organizations_url":"https://api.github.com/users/borisbstyle/orgs","repos_url":"https://api.github.com/users/borisbstyle/repos","events_url":"https://api.github.com/users/borisbstyle/events{/privacy}","received_events_url":"https://api.github.com/users/borisbstyle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":87,"created_at":"2015-08-04T22:18:39Z","updated_at":"2015-08-11T11:26:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cleanflight/cleanflight/pulls/1186","html_url":"https://github.com/cleanflight/cleanflight/pull/1186","diff_url":"https://github.com/cleanflight/cleanflight/pull/1186.diff","patch_url":"https://github.com/cleanflight/cleanflight/pull/1186.patch"},"body":"Has been discussed many times and was on my list for a long while. I was wrapping my head over the FIFO implementation, which requires way too much rewriting. This is definately a step in the right direction.\r\n\r\nCurrent Situation:\r\nLoop and gyro are completaly out of sync.\r\n![test_old](https://cloud.githubusercontent.com/assets/10757508/9105652/e787de3e-3c19-11e5-8591-106bee0fe928.png)\r\n\r\n\r\nMy implementation:\r\nGyro update is leading the loop. The loop will start after interrupt is triggered for new gyro sample.\r\n![test](https://cloud.githubusercontent.com/assets/10757508/9105588/6714334c-3c19-11e5-922c-1f70d46d29ac.png)\r\n\r\n\r\n\r\nMy Implementation based on the most optimal performance based on my testing on F1 and F3 boards. \r\nAdded 5-8-2015:\r\nLooptime is added and is automatically adjusting the refreshrate to the configured looptime. It calculates the targetLooptime rounded up to the highest nearest.\r\n![refresh rates](https://cloud.githubusercontent.com/assets/10757508/9151932/0ee27f86-3e16-11e5-99db-83500efd3ff6.png)\r\n\r\n\r\n\r\nDOWNLOAD HEX FILES:\r\nhttps://dl.dropboxusercontent.com/u/31537757/cleanflight/betaflight/betaflight.zip"},"comment":{"url":"https://api.github.com/repos/cleanflight/cleanflight/issues/comments/129844137","html_url":"https://github.com/cleanflight/cleanflight/pull/1186#issuecomment-129844137","issue_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1186","id":129844137,"user":{"login":"Qopter","id":13316063,"avatar_url":"https://avatars.githubusercontent.com/u/13316063?v=3","gravatar_id":"","url":"https://api.github.com/users/Qopter","html_url":"https://github.com/Qopter","followers_url":"https://api.github.com/users/Qopter/followers","following_url":"https://api.github.com/users/Qopter/following{/other_user}","gists_url":"https://api.github.com/users/Qopter/gists{/gist_id}","starred_url":"https://api.github.com/users/Qopter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qopter/subscriptions","organizations_url":"https://api.github.com/users/Qopter/orgs","repos_url":"https://api.github.com/users/Qopter/repos","events_url":"https://api.github.com/users/Qopter/events{/privacy}","received_events_url":"https://api.github.com/users/Qopter/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T11:26:48Z","updated_at":"2015-08-11T11:26:48Z","body":"May I bring in my knowledge about the MPU6050. I’m sure that the MPU6050 has the same filter structure as the MPU3050. In the 3050 datasheet can be found the frequency response of the filters. From these plots we can determine what is inside the chip.\r\n\r\n![dlpf_bode](https://cloud.githubusercontent.com/assets/13316063/9196366/ef7724aa-402a-11e5-8213-d30aa50b6907.png)\r\nFilter 0: 256Hz, fs=8kHz\r\nFilter 1: 188Hz, fs=1kHz\r\nFilter 2: 98Hz, fs=1kHz\r\nFilter 3: 42Hz, fs=1kHz\r\nFilter 4: 20Hz, fs=1kHz\r\nFilter 5: 10Hz, fs=1kHz\r\nFilter 6: 5Hz, fs=1kHz\r\n\r\nThere is a 2nd order filter (256Hz) which is always in the signal path even if the other LPF (5 to 188Hz) are used. You can see it on the curves that the slope of the lower LPF have a slope of 6dB/octave at frequencies lower than 256Hz and a slope of 18dB/octave at frequencies higher than 256Hz. It means that the lower LPF (5 to 188Hz) is connected in series to the 256Hz filter which gives overall a 3rd order behaviour.\r\n\r\nI think that all filters are running at 8kHz sampling rate. Only at the end of the chain there is a decimation filter which samples down the sampling rate to 1kHz. Such a decimation filter is quite simple. It’s only adding the last 8 samples and dividing it by 8. The frequency response has a notch at 1kHz, which means no aliasing close to 1kHz.\r\n\r\nApropos aliasing! If we look at the 188Hz LPF frequency response plot (green curve with no.1), we can read out an attenuation of 60dB at 900Hz. It means aliasing products lower than 100Hz will be suppressed more than 60dB.\r\n\r\nIn my opinion the chip is well designed regarding aliasing. There should be no aliasing if the FC is synced with the MPU6050. On the other hand aliasing can occur if the FC is out of sync. \r\n"}}