Increasing accuracy of Puck.light() #2067
Replies: 7 comments
-
Posted at 2017-03-07 by @gfwilliams Thanks! Are you using an up to date firmware though? I just tried here and I don't seem to be able to reproduce it...
It's possible that the older firmware is using different code that doesn't have any delay in it at all? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-07 by oesterle @gfwilliams, I'm also doing |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-07 by @gfwilliams
Ahh, you didn't mention that bit ;) Just normal analogWrite, or the forced software version? Did you experiment with different timeouts? I'm not sure how I feel about this - making |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-08 by oesterle I called it exactly as above, not with the I tried different timeouts; 50ms seemed the minimum in my code to get consistency. I'm fine with a 1/20 second reading in my use case. You also mention not taking more than 5 readings/second, so that's a gating factor, anyway. You could also have a I'm using this, BTW, in a kitchen-sink app that exercises all the sensors, incl NFC, and the RGB LEDs. I'll share that here soon. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-08 by @gfwilliams I guess maybe the thing to do would be to detect of the pin state was af_output, and if so to wait the full 50ms - otherwise just the 5ms should do it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-08 by oesterle That sounds like an elegant solution – especially as it requires no user attention. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-08 by @gfwilliams I did that today, so it'll be in the 1v92 release :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-03-07 by oesterle
@gfwilliams,
Puck.light()
is returning lower values than expected after the first call. Probably because I'm lighting up LED1.Short story: I think this can be fixed by extending the settling time delay in
jswrap_puck_light()
.I type this in the console, and I get:
The last 0.559 reading is the most accurate.
Here's my workaround that gives consistent light readings:
Like your C code for
jswrap_puck_light()
, I reset the LED1 pin, take a reading, wait, and take another (better) reading. But I wait 50 milliseconds, rather than 5 milliseconds.Beta Was this translation helpful? Give feedback.
All reactions