{"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":57,"created_at":"2015-08-04T22:18:39Z","updated_at":"2015-08-07T21:31:34Z","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/9122961/b91db17c-3c8c-11e5-9b68-ae8bcea87b59.png)\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/128838008","html_url":"https://github.com/cleanflight/cleanflight/pull/1186#issuecomment-128838008","issue_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1186","id":128838008,"user":{"login":"tracernz","id":9995998,"avatar_url":"https://avatars.githubusercontent.com/u/9995998?v=3","gravatar_id":"","url":"https://api.github.com/users/tracernz","html_url":"https://github.com/tracernz","followers_url":"https://api.github.com/users/tracernz/followers","following_url":"https://api.github.com/users/tracernz/following{/other_user}","gists_url":"https://api.github.com/users/tracernz/gists{/gist_id}","starred_url":"https://api.github.com/users/tracernz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tracernz/subscriptions","organizations_url":"https://api.github.com/users/tracernz/orgs","repos_url":"https://api.github.com/users/tracernz/repos","events_url":"https://api.github.com/users/tracernz/events{/privacy}","received_events_url":"https://api.github.com/users/tracernz/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T21:31:34Z","updated_at":"2015-08-07T21:31:34Z","body":"Undoubtedly SPI is faster, you can read the accel/gyro data registers at up to 20 MHz (vs. 400 kHz for I2C, which also has more protocol overhead). Trex4git already has some working code reading the gyro synchronously at 8 kHz and downsampling."}}