{"action":"created","issue":{"url":"https://api.github.com/repos/purduesigbots/pros/issues/32","repository_url":"https://api.github.com/repos/purduesigbots/pros","labels_url":"https://api.github.com/repos/purduesigbots/pros/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/purduesigbots/pros/issues/32/comments","events_url":"https://api.github.com/repos/purduesigbots/pros/issues/32/events","html_url":"https://github.com/purduesigbots/pros/issues/32","id":246168304,"number":32,"title":"Ultrasonic sensor seems to return zero periodically","user":{"login":"bradamiller","id":2307917,"avatar_url":"https://avatars2.githubusercontent.com/u/2307917?v=4","gravatar_id":"","url":"https://api.github.com/users/bradamiller","html_url":"https://github.com/bradamiller","followers_url":"https://api.github.com/users/bradamiller/followers","following_url":"https://api.github.com/users/bradamiller/following{/other_user}","gists_url":"https://api.github.com/users/bradamiller/gists{/gist_id}","starred_url":"https://api.github.com/users/bradamiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradamiller/subscriptions","organizations_url":"https://api.github.com/users/bradamiller/orgs","repos_url":"https://api.github.com/users/bradamiller/repos","events_url":"https://api.github.com/users/bradamiller/events{/privacy}","received_events_url":"https://api.github.com/users/bradamiller/received_events","type":"User","site_admin":false},"labels":[{"id":644194180,"url":"https://api.github.com/repos/purduesigbots/pros/labels/Platform:%20Any","name":"Platform: Any","color":"0052cc","default":false},{"id":644190114,"url":"https://api.github.com/repos/purduesigbots/pros/labels/Priority:%20Medium","name":"Priority: Medium","color":"fbca04","default":false},{"id":644190106,"url":"https://api.github.com/repos/purduesigbots/pros/labels/Project:%20PROS%20Kernel","name":"Project: PROS Kernel","color":"5319e7","default":false},{"id":644190102,"url":"https://api.github.com/repos/purduesigbots/pros/labels/Type:%20Bug","name":"Type: Bug","color":"ee0701","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-07-27T21:02:34Z","updated_at":"2017-08-12T23:33:58Z","closed_at":null,"body":"#### Expected Behavior:\r\nThe VEX Ultrasonic sensor should always return a reasonable value for the distance\r\n#### Actual Behavior:\r\nI'm seeing a zero value about every 50ms in between the correct values.\r\n#### Steps to reproduce:\r\nI wrote this test program that gets the time of  a zero value and subtracts the last time we saw a zero\r\nto look for a repeatable period:\r\n```\r\n Ultrasonic ultra;\r\n const int leftMotor = 1;\r\n const int rightMotor = 10;\r\n\r\nvoid operatorControl() {\r\n\t\tultra = ultrasonicInit(4, 3);\r\n\t\tint lastTime = 0;\r\n\t\twhile (1) {\r\n\t\t\tint distance = ultrasonicGet(ultra);\r\n\t\t\tif (distance == 0) {\r\n\t\t\t\t// if this is a zero range value\r\n\t\t\t\tunsigned long thisTime = millis();\r\n\t\t\t\tint time = thisTime - lastTime;  // time since last zero\r\n\t\t\t\tprintf(\"millis: %d\\n\", time);\r\n\t\t\t\twhile (ultrasonicGet(ultra) == 0); // wait for the distance to become nonzero\r\n\t\t\t\tlastTime = thisTime; // update the last time we saw a zero\r\n\t\t\t}\r\n\t\t}\r\n}\r\n```\r\n#### System information:\r\nmac os 10.12.6\r\n\r\nKernel Version:\r\n2.12\r\n\r\n#### Additional Information\r\n"},"comment":{"url":"https://api.github.com/repos/purduesigbots/pros/issues/comments/322012314","html_url":"https://github.com/purduesigbots/pros/issues/32#issuecomment-322012314","issue_url":"https://api.github.com/repos/purduesigbots/pros/issues/32","id":322012314,"user":{"login":"HotelCalifornia","id":6646541,"avatar_url":"https://avatars1.githubusercontent.com/u/6646541?v=4","gravatar_id":"","url":"https://api.github.com/users/HotelCalifornia","html_url":"https://github.com/HotelCalifornia","followers_url":"https://api.github.com/users/HotelCalifornia/followers","following_url":"https://api.github.com/users/HotelCalifornia/following{/other_user}","gists_url":"https://api.github.com/users/HotelCalifornia/gists{/gist_id}","starred_url":"https://api.github.com/users/HotelCalifornia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HotelCalifornia/subscriptions","organizations_url":"https://api.github.com/users/HotelCalifornia/orgs","repos_url":"https://api.github.com/users/HotelCalifornia/repos","events_url":"https://api.github.com/users/HotelCalifornia/events{/privacy}","received_events_url":"https://api.github.com/users/HotelCalifornia/received_events","type":"User","site_admin":false},"created_at":"2017-08-12T23:33:58Z","updated_at":"2017-08-12T23:33:58Z","body":"> I'm fairly confident that these zeros were the result of the ping timing out, so the zero value would be a clue to the user that the data being returned is no longer valid.\r\n\r\n> ... and encouraging users to filter out the 50ms zeros when not near the top of the ultrasonic's range.\r\n\r\nI think this supports the idea that we add a defined value for the result of a ping timeout, instead of keeping those as zero and leaving users to guess what the zero means."}}
{"actor":{"display_login":"HotelCalifornia"}}