{"action":"created","comment":{"url":"https://api.github.com/repos/debaal/SolderingIron/pulls/comments/24152591","id":24152591,"diff_hunk":"@@ -34,47 +34,51 @@ void control_init(void)\n \tDDRD |= (1<< PD4);\n \tw = config.default_temp;\n }\n-\n-void control(void)\n+uint8_t t=0;\n+void control(int16_t temp)\n {\n-\t// XXX test this\n-\tint16_t temp = tip_get_temp();\n+\tstatic int16_t old_temp = 0;\n \tint16_t e = w - temp; \n-\t//display_fixed_point((uint16_t)(config.pid_p * 10),-1);\n-\t   //guarding preventing esum over/underflows\n+\t\n+\t//guarding\n \tif(esum >= (int32_t)(0x3fff - e)){\n \t\tesum = 0x3fff;\n \t} else if(esum <= (int32_t)(-0x3fff + e)){\n \t\tesum = (-0x3fff);\n \t}else{\n-\t\t\tesum += e;\n+\t\tesum += e;\n \t}\n-\n-\tint16_t p = (uint32_t)(config.pid_p*e)/(uint32_t)128;\n-\tint16_t i = (int32_t)((int32_t)config.pid_i*(int32_t)Ta*(int32_t)esum)/(uint32_t)128;\n-\tint16_t d = (int32_t)(config.pid_d/Ta*(e - eold))/(uint32_t)128;\n+\t\n+\tint16_t p = ((int32_t)((int32_t)config.pid_p*(int32_t)e))/(int32_t)128;\n+\tint16_t i = 0;//(int32_t)((int32_t)config.pid_i*(int32_t)Ta*(int32_t)esum)/(uint32_t)128;\n+\tint16_t d = 0;//(int32_t)(config.pid_d/Ta*(e - eold))/(uint32_t)128;\n \tint16_t y = (int32_t)((int32_t)p + (int32_t)i + (int32_t)d);\n \teold = e;\n-\n-\t   //guarding\n+\t\n+\t\n+\t//guarding\n \tif(y > 255){\n \t\ty = 255;\n \t} else if (y < 0){\n \t\ty = 0;\n \t}\n-\n+\t\t\n \ty_buffer = y;\n }\n \n void adc_callback(uint16_t raw){\n-\ttip_temperature_from_adc(raw);//convert it and let it remember\n-\tPORTD |= (1<<PD4); //set pwm pin high\n-\tcontrol();\n+\tint16_t t = tip_temperature_from_adc(raw);//convert it and let it remember\n+\tif(y_buffer > 0){\n+\t\tPORTD |= (1<<PD4) ; //set pwm pin high","path":"Firmware/includes/controller.c","position":71,"original_position":71,"commit_id":"e13829c6358e5c3f25ef184dfad4209cd956895d","original_commit_id":"e13829c6358e5c3f25ef184dfad4209cd956895d","user":{"login":"yschroeder","id":8067560,"avatar_url":"https://avatars.githubusercontent.com/u/8067560?v=3","gravatar_id":"","url":"https://api.github.com/users/yschroeder","html_url":"https://github.com/yschroeder","followers_url":"https://api.github.com/users/yschroeder/followers","following_url":"https://api.github.com/users/yschroeder/following{/other_user}","gists_url":"https://api.github.com/users/yschroeder/gists{/gist_id}","starred_url":"https://api.github.com/users/yschroeder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yschroeder/subscriptions","organizations_url":"https://api.github.com/users/yschroeder/orgs","repos_url":"https://api.github.com/users/yschroeder/repos","events_url":"https://api.github.com/users/yschroeder/events{/privacy}","received_events_url":"https://api.github.com/users/yschroeder/received_events","type":"User","site_admin":false},"body":"There is a race condition here:\r\nIf the `TIMER0_COMPA_vect` is called before this line runs in the current `TIMER0` loop, then it heats for the rest of this timer cycle which is not intended. It also runs during the next ADC conversion which might be the reason you are seeing maximum ADC results.","created_at":"2015-02-05T09:50:04Z","updated_at":"2015-02-05T09:50:04Z","html_url":"https://github.com/debaal/SolderingIron/pull/40#discussion_r24152591","pull_request_url":"https://api.github.com/repos/debaal/SolderingIron/pulls/40","_links":{"self":{"href":"https://api.github.com/repos/debaal/SolderingIron/pulls/comments/24152591"},"html":{"href":"https://github.com/debaal/SolderingIron/pull/40#discussion_r24152591"},"pull_request":{"href":"https://api.github.com/repos/debaal/SolderingIron/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/debaal/SolderingIron/pulls/40","id":28709734,"html_url":"https://github.com/debaal/SolderingIron/pull/40","diff_url":"https://github.com/debaal/SolderingIron/pull/40.diff","patch_url":"https://github.com/debaal/SolderingIron/pull/40.patch","issue_url":"https://api.github.com/repos/debaal/SolderingIron/issues/40","number":40,"state":"open","locked":false,"title":" Controller is working now","user":{"login":"oni303","id":464666,"avatar_url":"https://avatars.githubusercontent.com/u/464666?v=3","gravatar_id":"","url":"https://api.github.com/users/oni303","html_url":"https://github.com/oni303","followers_url":"https://api.github.com/users/oni303/followers","following_url":"https://api.github.com/users/oni303/following{/other_user}","gists_url":"https://api.github.com/users/oni303/gists{/gist_id}","starred_url":"https://api.github.com/users/oni303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oni303/subscriptions","organizations_url":"https://api.github.com/users/oni303/orgs","repos_url":"https://api.github.com/users/oni303/repos","events_url":"https://api.github.com/users/oni303/events{/privacy}","received_events_url":"https://api.github.com/users/oni303/received_events","type":"User","site_admin":false},"body":"disabled compA interrupt if not needed.\r\nThis somehow fixes PWM generation for very some duty cycles.\r\n\r\nI and D factors are disabled at the moment.\r\n\r\nThere still is a bug with high ADC values.\r\nDuty cycle becomes one timer tick and never recovers.\r\nNo clue why, for now.","created_at":"2015-02-05T09:30:08Z","updated_at":"2015-02-05T09:50:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"20172b1b65c9623f24dbe0b1acedb48794ae8f8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/debaal/SolderingIron/pulls/40/commits","review_comments_url":"https://api.github.com/repos/debaal/SolderingIron/pulls/40/comments","review_comment_url":"https://api.github.com/repos/debaal/SolderingIron/pulls/comments/{number}","comments_url":"https://api.github.com/repos/debaal/SolderingIron/issues/40/comments","statuses_url":"https://api.github.com/repos/debaal/SolderingIron/statuses/e13829c6358e5c3f25ef184dfad4209cd956895d","head":{"label":"oni303:controller","ref":"controller","sha":"e13829c6358e5c3f25ef184dfad4209cd956895d","user":{"login":"oni303","id":464666,"avatar_url":"https://avatars.githubusercontent.com/u/464666?v=3","gravatar_id":"","url":"https://api.github.com/users/oni303","html_url":"https://github.com/oni303","followers_url":"https://api.github.com/users/oni303/followers","following_url":"https://api.github.com/users/oni303/following{/other_user}","gists_url":"https://api.github.com/users/oni303/gists{/gist_id}","starred_url":"https://api.github.com/users/oni303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oni303/subscriptions","organizations_url":"https://api.github.com/users/oni303/orgs","repos_url":"https://api.github.com/users/oni303/repos","events_url":"https://api.github.com/users/oni303/events{/privacy}","received_events_url":"https://api.github.com/users/oni303/received_events","type":"User","site_admin":false},"repo":{"id":30109745,"name":"SolderingIron","full_name":"oni303/SolderingIron","owner":{"login":"oni303","id":464666,"avatar_url":"https://avatars.githubusercontent.com/u/464666?v=3","gravatar_id":"","url":"https://api.github.com/users/oni303","html_url":"https://github.com/oni303","followers_url":"https://api.github.com/users/oni303/followers","following_url":"https://api.github.com/users/oni303/following{/other_user}","gists_url":"https://api.github.com/users/oni303/gists{/gist_id}","starred_url":"https://api.github.com/users/oni303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oni303/subscriptions","organizations_url":"https://api.github.com/users/oni303/orgs","repos_url":"https://api.github.com/users/oni303/repos","events_url":"https://api.github.com/users/oni303/events{/privacy}","received_events_url":"https://api.github.com/users/oni303/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oni303/SolderingIron","description":"Idea for an OpenSource Soldering Iron","fork":true,"url":"https://api.github.com/repos/oni303/SolderingIron","forks_url":"https://api.github.com/repos/oni303/SolderingIron/forks","keys_url":"https://api.github.com/repos/oni303/SolderingIron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oni303/SolderingIron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oni303/SolderingIron/teams","hooks_url":"https://api.github.com/repos/oni303/SolderingIron/hooks","issue_events_url":"https://api.github.com/repos/oni303/SolderingIron/issues/events{/number}","events_url":"https://api.github.com/repos/oni303/SolderingIron/events","assignees_url":"https://api.github.com/repos/oni303/SolderingIron/assignees{/user}","branches_url":"https://api.github.com/repos/oni303/SolderingIron/branches{/branch}","tags_url":"https://api.github.com/repos/oni303/SolderingIron/tags","blobs_url":"https://api.github.com/repos/oni303/SolderingIron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oni303/SolderingIron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oni303/SolderingIron/git/refs{/sha}","trees_url":"https://api.github.com/repos/oni303/SolderingIron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oni303/SolderingIron/statuses/{sha}","languages_url":"https://api.github.com/repos/oni303/SolderingIron/languages","stargazers_url":"https://api.github.com/repos/oni303/SolderingIron/stargazers","contributors_url":"https://api.github.com/repos/oni303/SolderingIron/contributors","subscribers_url":"https://api.github.com/repos/oni303/SolderingIron/subscribers","subscription_url":"https://api.github.com/repos/oni303/SolderingIron/subscription","commits_url":"https://api.github.com/repos/oni303/SolderingIron/commits{/sha}","git_commits_url":"https://api.github.com/repos/oni303/SolderingIron/git/commits{/sha}","comments_url":"https://api.github.com/repos/oni303/SolderingIron/comments{/number}","issue_comment_url":"https://api.github.com/repos/oni303/SolderingIron/issues/comments/{number}","contents_url":"https://api.github.com/repos/oni303/SolderingIron/contents/{+path}","compare_url":"https://api.github.com/repos/oni303/SolderingIron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oni303/SolderingIron/merges","archive_url":"https://api.github.com/repos/oni303/SolderingIron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oni303/SolderingIron/downloads","issues_url":"https://api.github.com/repos/oni303/SolderingIron/issues{/number}","pulls_url":"https://api.github.com/repos/oni303/SolderingIron/pulls{/number}","milestones_url":"https://api.github.com/repos/oni303/SolderingIron/milestones{/number}","notifications_url":"https://api.github.com/repos/oni303/SolderingIron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oni303/SolderingIron/labels{/name}","releases_url":"https://api.github.com/repos/oni303/SolderingIron/releases{/id}","created_at":"2015-01-31T10:53:26Z","updated_at":"2015-02-05T09:28:36Z","pushed_at":"2015-02-05T09:27:37Z","git_url":"git://github.com/oni303/SolderingIron.git","ssh_url":"git@github.com:oni303/SolderingIron.git","clone_url":"https://github.com/oni303/SolderingIron.git","svn_url":"https://github.com/oni303/SolderingIron","homepage":null,"size":1058,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"debaal:master","ref":"master","sha":"d4ccd086dba6cdfc167b9c76a70ac74a1b4e331a","user":{"login":"debaal","id":9631621,"avatar_url":"https://avatars.githubusercontent.com/u/9631621?v=3","gravatar_id":"","url":"https://api.github.com/users/debaal","html_url":"https://github.com/debaal","followers_url":"https://api.github.com/users/debaal/followers","following_url":"https://api.github.com/users/debaal/following{/other_user}","gists_url":"https://api.github.com/users/debaal/gists{/gist_id}","starred_url":"https://api.github.com/users/debaal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debaal/subscriptions","organizations_url":"https://api.github.com/users/debaal/orgs","repos_url":"https://api.github.com/users/debaal/repos","events_url":"https://api.github.com/users/debaal/events{/privacy}","received_events_url":"https://api.github.com/users/debaal/received_events","type":"User","site_admin":false},"repo":{"id":26376709,"name":"SolderingIron","full_name":"debaal/SolderingIron","owner":{"login":"debaal","id":9631621,"avatar_url":"https://avatars.githubusercontent.com/u/9631621?v=3","gravatar_id":"","url":"https://api.github.com/users/debaal","html_url":"https://github.com/debaal","followers_url":"https://api.github.com/users/debaal/followers","following_url":"https://api.github.com/users/debaal/following{/other_user}","gists_url":"https://api.github.com/users/debaal/gists{/gist_id}","starred_url":"https://api.github.com/users/debaal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debaal/subscriptions","organizations_url":"https://api.github.com/users/debaal/orgs","repos_url":"https://api.github.com/users/debaal/repos","events_url":"https://api.github.com/users/debaal/events{/privacy}","received_events_url":"https://api.github.com/users/debaal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/debaal/SolderingIron","description":"An OpenSource Soldering Iron","fork":false,"url":"https://api.github.com/repos/debaal/SolderingIron","forks_url":"https://api.github.com/repos/debaal/SolderingIron/forks","keys_url":"https://api.github.com/repos/debaal/SolderingIron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/debaal/SolderingIron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/debaal/SolderingIron/teams","hooks_url":"https://api.github.com/repos/debaal/SolderingIron/hooks","issue_events_url":"https://api.github.com/repos/debaal/SolderingIron/issues/events{/number}","events_url":"https://api.github.com/repos/debaal/SolderingIron/events","assignees_url":"https://api.github.com/repos/debaal/SolderingIron/assignees{/user}","branches_url":"https://api.github.com/repos/debaal/SolderingIron/branches{/branch}","tags_url":"https://api.github.com/repos/debaal/SolderingIron/tags","blobs_url":"https://api.github.com/repos/debaal/SolderingIron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/debaal/SolderingIron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/debaal/SolderingIron/git/refs{/sha}","trees_url":"https://api.github.com/repos/debaal/SolderingIron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/debaal/SolderingIron/statuses/{sha}","languages_url":"https://api.github.com/repos/debaal/SolderingIron/languages","stargazers_url":"https://api.github.com/repos/debaal/SolderingIron/stargazers","contributors_url":"https://api.github.com/repos/debaal/SolderingIron/contributors","subscribers_url":"https://api.github.com/repos/debaal/SolderingIron/subscribers","subscription_url":"https://api.github.com/repos/debaal/SolderingIron/subscription","commits_url":"https://api.github.com/repos/debaal/SolderingIron/commits{/sha}","git_commits_url":"https://api.github.com/repos/debaal/SolderingIron/git/commits{/sha}","comments_url":"https://api.github.com/repos/debaal/SolderingIron/comments{/number}","issue_comment_url":"https://api.github.com/repos/debaal/SolderingIron/issues/comments/{number}","contents_url":"https://api.github.com/repos/debaal/SolderingIron/contents/{+path}","compare_url":"https://api.github.com/repos/debaal/SolderingIron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/debaal/SolderingIron/merges","archive_url":"https://api.github.com/repos/debaal/SolderingIron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/debaal/SolderingIron/downloads","issues_url":"https://api.github.com/repos/debaal/SolderingIron/issues{/number}","pulls_url":"https://api.github.com/repos/debaal/SolderingIron/pulls{/number}","milestones_url":"https://api.github.com/repos/debaal/SolderingIron/milestones{/number}","notifications_url":"https://api.github.com/repos/debaal/SolderingIron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/debaal/SolderingIron/labels{/name}","releases_url":"https://api.github.com/repos/debaal/SolderingIron/releases{/id}","created_at":"2014-11-08T22:20:54Z","updated_at":"2015-02-05T07:38:08Z","pushed_at":"2015-02-05T07:38:06Z","git_url":"git://github.com/debaal/SolderingIron.git","ssh_url":"git@github.com:debaal/SolderingIron.git","clone_url":"https://github.com/debaal/SolderingIron.git","svn_url":"https://github.com/debaal/SolderingIron","homepage":"","size":1339,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":13,"forks":5,"open_issues":13,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/debaal/SolderingIron/pulls/40"},"html":{"href":"https://github.com/debaal/SolderingIron/pull/40"},"issue":{"href":"https://api.github.com/repos/debaal/SolderingIron/issues/40"},"comments":{"href":"https://api.github.com/repos/debaal/SolderingIron/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/debaal/SolderingIron/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/debaal/SolderingIron/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/debaal/SolderingIron/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/debaal/SolderingIron/statuses/e13829c6358e5c3f25ef184dfad4209cd956895d"}}}}