{"action":"created","comment":{"url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments/103119883","pull_request_review_id":23896305,"id":103119883,"diff_hunk":"@@ -0,0 +1,154 @@\n+/*\n+ * Copyright (C) 2017 The Paparazzi team\n+ *\n+ * This file is part of paparazzi.\n+ *\n+ * paparazzi is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2, or (at your option)\n+ * any later version.\n+ *\n+ * paparazzi is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with paparazzi; see the file COPYING.  If not, write to\n+ * the Free Software Foundation, 59 Temple Place - Suite 330,\n+ * Boston, MA 02111-1307, USA.\n+ */\n+\n+/**\n+ * @file modules/ins/ins_temp_ctrl.c\n+ *\n+ * Bebop2 INS temperature control on pwm 6 for Bebop2, pwm 10 for DISCO\n+ *\n+ * Controls the heating resistors in the Bebop2 to keep the MPU6050\n+ * gyro/accel INS sensors at a constant temperature\n+ *\n+ */\n+\n+#include <stdio.h>\n+#include <unistd.h>\n+#include <fcntl.h>\n+\n+#include \"std.h\"\n+#include \"mcu_periph/uart.h\"\n+#include \"pprzlink/messages.h\"\n+#include \"subsystems/datalink/downlink.h\"\n+#include \"ins_temp_ctrl.h\"\n+\n+uint8_t ins_temp_ctrl_ok = 0;\n+int pwm_heat_duty_fd = 0;\n+\n+#ifndef INS_TEMP_TARGET\n+#define INS_TEMP_TARGET 50\n+#endif\n+\n+#ifdef BEBOP_VERSION2\n+#define PWM_HEAT_CHAN PWM_HEAT_CHAN_BEBOP2\n+#elif BOARD==disco\n+#define PWM_HEAT_CHAN PWM_HEAT_CHAN_DISCO\n+#else\n+#error temp control only implemented in Parrot Bebop2 and Disco\n+#endif\n+\n+void ins_temp_ctrl_periodic(void)\n+{\n+  float temp_current, error;\n+  static float sum_error = 0;\n+  uint32_t output = 0;\n+\n+  temp_current = imu_bebop.mpu.temp;\n+\n+  if (ins_temp_ctrl_ok == 1) {\n+    /* minimal PI algo without dt from Ardupilot */\n+    error = (float) ((INS_TEMP_TARGET) - temp_current);\n+\n+    /* Don't accumulate errors if the integrated error is superior\n+     * to the max duty cycle(pwm_period)\n+     */\n+    if ((fabsf(sum_error) * INS_TEMP_CTRL_KI < INS_TEMP_CTRL_DUTY_MAX)) {\n+        sum_error = sum_error + error;\n+    }\n+\n+    output = INS_TEMP_CTRL_KP * error + INS_TEMP_CTRL_KI * sum_error;\n+\n+    if (output > INS_TEMP_CTRL_DUTY_MAX) {\n+      output = INS_TEMP_CTRL_DUTY_MAX;\n+    } else if (output < 0) {\n+      output = 0;\n+    }\n+\n+     if (dprintf(pwm_heat_duty_fd, \"%u\", output) < 0)\n+       /* could not set duty cycle */\n+       {}","path":"sw/airborne/modules/ins/ins_temp_ctrl.c","position":86,"original_position":86,"commit_id":"082dbcc8b04077f015a3f487937025b16c649d6a","original_commit_id":"082dbcc8b04077f015a3f487937025b16c649d6a","user":{"login":"flixr","id":104257,"avatar_url":"https://avatars.githubusercontent.com/u/104257?v=3","gravatar_id":"","url":"https://api.github.com/users/flixr","html_url":"https://github.com/flixr","followers_url":"https://api.github.com/users/flixr/followers","following_url":"https://api.github.com/users/flixr/following{/other_user}","gists_url":"https://api.github.com/users/flixr/gists{/gist_id}","starred_url":"https://api.github.com/users/flixr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flixr/subscriptions","organizations_url":"https://api.github.com/users/flixr/orgs","repos_url":"https://api.github.com/users/flixr/repos","events_url":"https://api.github.com/users/flixr/events{/privacy}","received_events_url":"https://api.github.com/users/flixr/received_events","type":"User","site_admin":false},"body":"Would it be useful to print a warning on the console in this case?","created_at":"2017-02-26T22:54:16Z","updated_at":"2017-02-26T22:54:16Z","html_url":"https://github.com/paparazzi/paparazzi/pull/2027#discussion_r103119883","pull_request_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027","_links":{"self":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments/103119883"},"html":{"href":"https://github.com/paparazzi/paparazzi/pull/2027#discussion_r103119883"},"pull_request":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027"}}},"pull_request":{"url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027","id":107978803,"html_url":"https://github.com/paparazzi/paparazzi/pull/2027","diff_url":"https://github.com/paparazzi/paparazzi/pull/2027.diff","patch_url":"https://github.com/paparazzi/paparazzi/pull/2027.patch","issue_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/2027","number":2027,"state":"open","locked":false,"title":"add temperature control module for Bebop2","user":{"login":"martinmm","id":450645,"avatar_url":"https://avatars.githubusercontent.com/u/450645?v=3","gravatar_id":"","url":"https://api.github.com/users/martinmm","html_url":"https://github.com/martinmm","followers_url":"https://api.github.com/users/martinmm/followers","following_url":"https://api.github.com/users/martinmm/following{/other_user}","gists_url":"https://api.github.com/users/martinmm/gists{/gist_id}","starred_url":"https://api.github.com/users/martinmm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinmm/subscriptions","organizations_url":"https://api.github.com/users/martinmm/orgs","repos_url":"https://api.github.com/users/martinmm/repos","events_url":"https://api.github.com/users/martinmm/events{/privacy}","received_events_url":"https://api.github.com/users/martinmm/received_events","type":"User","site_admin":false},"body":"It is possible to control the temperature of the MPU6xxx in the Bebop2\r\nthrough resistors powered by PWM_6. Seems this does not make a big\r\ndifference even if flying in cold conditions but does rather improve\r\nthings than do harm.","created_at":"2017-02-25T21:56:22Z","updated_at":"2017-02-26T22:54:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3229295304b66fa65787c664043628b754e6c004","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027/commits","review_comments_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027/comments","review_comment_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/2027/comments","statuses_url":"https://api.github.com/repos/paparazzi/paparazzi/statuses/082dbcc8b04077f015a3f487937025b16c649d6a","head":{"label":"martinmm:master_ins_temp_ctrl","ref":"master_ins_temp_ctrl","sha":"082dbcc8b04077f015a3f487937025b16c649d6a","user":{"login":"martinmm","id":450645,"avatar_url":"https://avatars.githubusercontent.com/u/450645?v=3","gravatar_id":"","url":"https://api.github.com/users/martinmm","html_url":"https://github.com/martinmm","followers_url":"https://api.github.com/users/martinmm/followers","following_url":"https://api.github.com/users/martinmm/following{/other_user}","gists_url":"https://api.github.com/users/martinmm/gists{/gist_id}","starred_url":"https://api.github.com/users/martinmm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinmm/subscriptions","organizations_url":"https://api.github.com/users/martinmm/orgs","repos_url":"https://api.github.com/users/martinmm/repos","events_url":"https://api.github.com/users/martinmm/events{/privacy}","received_events_url":"https://api.github.com/users/martinmm/received_events","type":"User","site_admin":false},"repo":{"id":1407892,"name":"paparazzi","full_name":"martinmm/paparazzi","owner":{"login":"martinmm","id":450645,"avatar_url":"https://avatars.githubusercontent.com/u/450645?v=3","gravatar_id":"","url":"https://api.github.com/users/martinmm","html_url":"https://github.com/martinmm","followers_url":"https://api.github.com/users/martinmm/followers","following_url":"https://api.github.com/users/martinmm/following{/other_user}","gists_url":"https://api.github.com/users/martinmm/gists{/gist_id}","starred_url":"https://api.github.com/users/martinmm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinmm/subscriptions","organizations_url":"https://api.github.com/users/martinmm/orgs","repos_url":"https://api.github.com/users/martinmm/repos","events_url":"https://api.github.com/users/martinmm/events{/privacy}","received_events_url":"https://api.github.com/users/martinmm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/martinmm/paparazzi","description":"Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.","fork":true,"url":"https://api.github.com/repos/martinmm/paparazzi","forks_url":"https://api.github.com/repos/martinmm/paparazzi/forks","keys_url":"https://api.github.com/repos/martinmm/paparazzi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/martinmm/paparazzi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/martinmm/paparazzi/teams","hooks_url":"https://api.github.com/repos/martinmm/paparazzi/hooks","issue_events_url":"https://api.github.com/repos/martinmm/paparazzi/issues/events{/number}","events_url":"https://api.github.com/repos/martinmm/paparazzi/events","assignees_url":"https://api.github.com/repos/martinmm/paparazzi/assignees{/user}","branches_url":"https://api.github.com/repos/martinmm/paparazzi/branches{/branch}","tags_url":"https://api.github.com/repos/martinmm/paparazzi/tags","blobs_url":"https://api.github.com/repos/martinmm/paparazzi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/martinmm/paparazzi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/martinmm/paparazzi/git/refs{/sha}","trees_url":"https://api.github.com/repos/martinmm/paparazzi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/martinmm/paparazzi/statuses/{sha}","languages_url":"https://api.github.com/repos/martinmm/paparazzi/languages","stargazers_url":"https://api.github.com/repos/martinmm/paparazzi/stargazers","contributors_url":"https://api.github.com/repos/martinmm/paparazzi/contributors","subscribers_url":"https://api.github.com/repos/martinmm/paparazzi/subscribers","subscription_url":"https://api.github.com/repos/martinmm/paparazzi/subscription","commits_url":"https://api.github.com/repos/martinmm/paparazzi/commits{/sha}","git_commits_url":"https://api.github.com/repos/martinmm/paparazzi/git/commits{/sha}","comments_url":"https://api.github.com/repos/martinmm/paparazzi/comments{/number}","issue_comment_url":"https://api.github.com/repos/martinmm/paparazzi/issues/comments{/number}","contents_url":"https://api.github.com/repos/martinmm/paparazzi/contents/{+path}","compare_url":"https://api.github.com/repos/martinmm/paparazzi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/martinmm/paparazzi/merges","archive_url":"https://api.github.com/repos/martinmm/paparazzi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/martinmm/paparazzi/downloads","issues_url":"https://api.github.com/repos/martinmm/paparazzi/issues{/number}","pulls_url":"https://api.github.com/repos/martinmm/paparazzi/pulls{/number}","milestones_url":"https://api.github.com/repos/martinmm/paparazzi/milestones{/number}","notifications_url":"https://api.github.com/repos/martinmm/paparazzi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/martinmm/paparazzi/labels{/name}","releases_url":"https://api.github.com/repos/martinmm/paparazzi/releases{/id}","deployments_url":"https://api.github.com/repos/martinmm/paparazzi/deployments","created_at":"2011-02-24T19:19:33Z","updated_at":"2015-06-22T10:49:36Z","pushed_at":"2017-02-26T22:37:44Z","git_url":"git://github.com/martinmm/paparazzi.git","ssh_url":"git@github.com:martinmm/paparazzi.git","clone_url":"https://github.com/martinmm/paparazzi.git","svn_url":"https://github.com/martinmm/paparazzi","homepage":"http://paparazzi.enac.fr","size":71110,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"paparazzi:master","ref":"master","sha":"002a36c4a75e8cef3e5a896044fec00e66fb06e4","user":{"login":"paparazzi","id":318080,"avatar_url":"https://avatars.githubusercontent.com/u/318080?v=3","gravatar_id":"","url":"https://api.github.com/users/paparazzi","html_url":"https://github.com/paparazzi","followers_url":"https://api.github.com/users/paparazzi/followers","following_url":"https://api.github.com/users/paparazzi/following{/other_user}","gists_url":"https://api.github.com/users/paparazzi/gists{/gist_id}","starred_url":"https://api.github.com/users/paparazzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paparazzi/subscriptions","organizations_url":"https://api.github.com/users/paparazzi/orgs","repos_url":"https://api.github.com/users/paparazzi/repos","events_url":"https://api.github.com/users/paparazzi/events{/privacy}","received_events_url":"https://api.github.com/users/paparazzi/received_events","type":"Organization","site_admin":false},"repo":{"id":1068018,"name":"paparazzi","full_name":"paparazzi/paparazzi","owner":{"login":"paparazzi","id":318080,"avatar_url":"https://avatars.githubusercontent.com/u/318080?v=3","gravatar_id":"","url":"https://api.github.com/users/paparazzi","html_url":"https://github.com/paparazzi","followers_url":"https://api.github.com/users/paparazzi/followers","following_url":"https://api.github.com/users/paparazzi/following{/other_user}","gists_url":"https://api.github.com/users/paparazzi/gists{/gist_id}","starred_url":"https://api.github.com/users/paparazzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paparazzi/subscriptions","organizations_url":"https://api.github.com/users/paparazzi/orgs","repos_url":"https://api.github.com/users/paparazzi/repos","events_url":"https://api.github.com/users/paparazzi/events{/privacy}","received_events_url":"https://api.github.com/users/paparazzi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paparazzi/paparazzi","description":"Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.","fork":false,"url":"https://api.github.com/repos/paparazzi/paparazzi","forks_url":"https://api.github.com/repos/paparazzi/paparazzi/forks","keys_url":"https://api.github.com/repos/paparazzi/paparazzi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paparazzi/paparazzi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paparazzi/paparazzi/teams","hooks_url":"https://api.github.com/repos/paparazzi/paparazzi/hooks","issue_events_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/events{/number}","events_url":"https://api.github.com/repos/paparazzi/paparazzi/events","assignees_url":"https://api.github.com/repos/paparazzi/paparazzi/assignees{/user}","branches_url":"https://api.github.com/repos/paparazzi/paparazzi/branches{/branch}","tags_url":"https://api.github.com/repos/paparazzi/paparazzi/tags","blobs_url":"https://api.github.com/repos/paparazzi/paparazzi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paparazzi/paparazzi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paparazzi/paparazzi/git/refs{/sha}","trees_url":"https://api.github.com/repos/paparazzi/paparazzi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paparazzi/paparazzi/statuses/{sha}","languages_url":"https://api.github.com/repos/paparazzi/paparazzi/languages","stargazers_url":"https://api.github.com/repos/paparazzi/paparazzi/stargazers","contributors_url":"https://api.github.com/repos/paparazzi/paparazzi/contributors","subscribers_url":"https://api.github.com/repos/paparazzi/paparazzi/subscribers","subscription_url":"https://api.github.com/repos/paparazzi/paparazzi/subscription","commits_url":"https://api.github.com/repos/paparazzi/paparazzi/commits{/sha}","git_commits_url":"https://api.github.com/repos/paparazzi/paparazzi/git/commits{/sha}","comments_url":"https://api.github.com/repos/paparazzi/paparazzi/comments{/number}","issue_comment_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/comments{/number}","contents_url":"https://api.github.com/repos/paparazzi/paparazzi/contents/{+path}","compare_url":"https://api.github.com/repos/paparazzi/paparazzi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paparazzi/paparazzi/merges","archive_url":"https://api.github.com/repos/paparazzi/paparazzi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paparazzi/paparazzi/downloads","issues_url":"https://api.github.com/repos/paparazzi/paparazzi/issues{/number}","pulls_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls{/number}","milestones_url":"https://api.github.com/repos/paparazzi/paparazzi/milestones{/number}","notifications_url":"https://api.github.com/repos/paparazzi/paparazzi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paparazzi/paparazzi/labels{/name}","releases_url":"https://api.github.com/repos/paparazzi/paparazzi/releases{/id}","deployments_url":"https://api.github.com/repos/paparazzi/paparazzi/deployments","created_at":"2010-11-10T11:14:08Z","updated_at":"2017-02-25T17:28:14Z","pushed_at":"2017-02-26T22:37:47Z","git_url":"git://github.com/paparazzi/paparazzi.git","ssh_url":"git@github.com:paparazzi/paparazzi.git","clone_url":"https://github.com/paparazzi/paparazzi.git","svn_url":"https://github.com/paparazzi/paparazzi","homepage":"http://paparazziuav.org","size":72890,"stargazers_count":680,"watchers_count":680,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":675,"mirror_url":null,"open_issues_count":110,"forks":675,"open_issues":110,"watchers":680,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027"},"html":{"href":"https://github.com/paparazzi/paparazzi/pull/2027"},"issue":{"href":"https://api.github.com/repos/paparazzi/paparazzi/issues/2027"},"comments":{"href":"https://api.github.com/repos/paparazzi/paparazzi/issues/2027/comments"},"review_comments":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027/comments"},"review_comment":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/2027/commits"},"statuses":{"href":"https://api.github.com/repos/paparazzi/paparazzi/statuses/082dbcc8b04077f015a3f487937025b16c649d6a"}}}}
{"actor":{"display_login":"flixr"}}