On 11/02/2013 04:27 AM, Cristian Maglie wrote:
In data giovedě 31 ottobre 2013 13:16:59, Anthony May ha scritto:
Any chance of this being added to 1.5.x ?Seems very nice, there is a pointer to the source code?
Here is the source. It's merely a thin wrapper around millis() and micros().
May be it simpler to made it available through a library?
C
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
As usual, I'm not convinced that the problem(s) this is trying to solve are worth the complication of having two similar but different functions (millis() and elapsedMillis()).
We're talking about:
ellapsedMillis em;// ...if (em < 1000) // ...
vs.
unsigned long n = millis();// ...if (millis() - n < 1000) // ...
right? The former doesn't necessarily seem simpler to me as the latter makes the behavior explicit and without adding much overhead to the code.
I think a big part of the simplicity of Arduino is in the minimal nature of its API and I think additions like this make the API more complicated without sufficient compensating utility.
David
On Sat, Nov 2, 2013 at 7:37 AM, Paul Stoffregen <pa...@pjrc.com> wrote:
On 11/02/2013 04:27 AM, Cristian Maglie wrote:
In data giovedě 31 ottobre 2013 13:16:59, Anthony May ha scritto:
Any chance of this being added to 1.5.x ?Seems very nice, there is a pointer to the source code?
Here is the source. It's merely a thin wrapper around millis() and micros().
May be it simpler to made it available through a library?
C
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
As usual, I'm not convinced
not convinced that the problem(s) this is trying to solve are worth the complication of having two similar but different functions (millis() and elapsedMillis()).
We're talking about:ellapsedMillis em;// ...if (em < 1000) // ...vs.unsigned long n = millis();// ...if (millis() - n < 1000) // ...right? The former doesn't necessarily seem simpler to me as the latter makes the behavior explicit and without adding much overhead to the code.
I agree with David. To make correct use of elapsedMillis, one must have a fairly sophisticated understanding of C++ object lifespans. Consider the plausible but incorrect:
void loop()
{
elapsedMillis em;
if (em > 5000) // turn on LED after 5 seconds
digitalWrite(13, HIGH);
}
Of course everyone here understands why this fails and how to correct it. But when you imagine explaining to a beginner, it seems less like a “much needed hardware abstraction” to me.
Mikal
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
// create elapsedMillis outside loop(), to retain its value each time loop() runs.
Mikal makes a good point, building on Dave�s point. One of the concepts I see students (other than those who are good at math) struggle with more than most are variables. "How do variables get their value?" is the usual question. My usual answer is �You give them value, using the = operator, like so: �variable = 5, or variable = analogRead(A0). In the latter case, you know that the function analogRead() is going to return a value when it runs, and you�re putting the value in the variable.�
But this proposal makes a variable that changes its value automagically. That�s confusing and inconsistent with the above explanation. �So if we did implement this, what would be a simpler explanation of variables that�s consistent with this new one that changes on its own?
t.
On Nov 3, 2013, at 1:54 AM, Mikal Hart <mh...@sundial.com> wrote:
I agree with David.� To make correct use of elapsedMillis, one must have a fairly sophisticated understanding of C++ object lifespans.� Consider the plausible but incorrect:�void loop(){� elapsedMillis em;���if (em > 5000) // turn on LED after 5 seconds��� digitalWrite(13, �HIGH);}�Of course everyone here understands why this fails and how to correct it.� But when you imagine explaining to a beginner, it seems less like a �much needed hardware abstraction� to me.�Mikal�From:�Anthony May [mailto:tech...@gmail.com]�
Sent:�Sunday, November 03, 2013 12:13 AM
To:�devel...@arduino.cc
Subject:�Re: [Developers] Request to have elapsedMillis/elapsedMicros data-type added to standard Arduino�
David A. Mellis wrote:As usual, I'm not convinced
�
...and the eyes of a thousand former wishful contributors who are no longer here (& a precious few who still are) all roll in unison...
�i understand you need to Just Say No to a lot of well-intentioned suggestions in projects like this. �but...�
not convinced that the problem(s) this is trying to solve are worth the complication of having two similar but different functions (millis() and elapsedMillis()).
�
every Arduino forum - which almost by definition are aimed at novice/non-programmers - regularly sees posts describing problems with timing & "unexpected" temporal behaviour.
�
most of the AVR's hardware has been abstracted by the Arduino platform in functions like digitalWrite(), analogRead(), a bunch of math, bits & bytes, serial, interrupts even!
�but not the glaring exception of the timer(s), critical to so many applications, but which are still only presented to the novice user "as is", and with no consideration of wrap-around. �why?�We're talking about:�
ellapsedMillis em;// ...if (em < 1000) // ...
�vs.�
unsigned long n = millis();// ...
if (millis() - n < 1000) // ...��right? �The former doesn't necessarily seem simpler to me as the latter makes the behavior explicit and without adding much overhead to the code.�
i think you've forgotten what it's like being new to a high-level language, or being a "non--programmer".
�"digitalWrite(13, HIGH)" �is pure magic of hardware abstraction of great benefit for the novice.�
so is " if ( MyElapsedMillisVariable > 250) { do stuff } ", whether for a 1-off comparison, or even if I have to zero it or subtract 250 from it afterward.
�
IMHO that's not a complication, it's a much needed hardware abstraction, whose overhead is minimal.
�Anthony.��--�
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to�developers+...@arduino.cc.--�
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to�developers+...@arduino.cc.
Did I mention my long-held belief elapsedMillis would be contraversial? There's a reason I've never brought it up here....
These are all good points. The variable scope issue has come up a few times over the last couple years. But overall, feedback from users about elapsedMillis has been very positive. Everybody seems to "get it" pretty easily. Then again, Teensy tends to appeal to slightly more technically savvy users, so I wouldn't claim that experience necessarily would apply to all or even many Arduino users.
I've long intended to package elapsedMillis as a library (AFAIK just add keywords.txt) and publish it somewhere, maybe on the playground? But that's never been a priority. Perhaps if someone felt strongly enough about this, they could put in that relatively minor amount of work as a first step? A readme.txt file could be included, soliciting feedback. Maybe over time, such feedback might lead to a better sense of whether this feature belongs in the official core?
On 11/04/2013 05:31 AM, Tom Igoe wrote:
Mikal makes a good point, building on Dave’s point. One of the concepts I see students (other than those who are good at math) struggle with more than most are variables. "How do variables get their value?" is the usual question. My usual answer is “You give them value, using the = operator, like so: variable = 5, or variable = analogRead(A0). In the latter case, you know that the function analogRead() is going to return a value when it runs, and you’re putting the value in the variable.”
But this proposal makes a variable that changes its value automagically. That’s confusing and inconsistent with the above explanation. So if we did implement this, what would be a simpler explanation of variables that’s consistent with this new one that changes on its own?
t.
On Nov 3, 2013, at 1:54 AM, Mikal Hart <mh...@sundial.com> wrote:
I agree with David. To make correct use of elapsedMillis, one must have a fairly sophisticated understanding of C++ object lifespans. Consider the plausible but incorrect:void loop(){elapsedMillis em;
if (em > 5000) // turn on LED after 5 seconds
digitalWrite(13, HIGH);}Of course everyone here understands why this fails and how to correct it. But when you imagine explaining to a beginner, it seems less like a “much needed hardware abstraction” to me.Mikal
From: Anthony May [mailto:tech...@gmail.com]
Sent: Sunday, November 03, 2013 12:13 AM
To: devel...@arduino.cc
Subject: Re: [Developers] Request to have elapsedMillis/elapsedMicros data-type added to standard Arduino
David A. Mellis wrote:As usual, I'm not convinced
...and the eyes of a thousand former wishful contributors who are no longer here (& a precious few who still are) all roll in unison...
i understand you need to Just Say No to a lot of well-intentioned suggestions in projects like this. but...
not convinced that the problem(s) this is trying to solve are worth the complication of having two similar but different functions (millis() and elapsedMillis()).
every Arduino forum - which almost by definition are aimed at novice/non-programmers - regularly sees posts describing problems with timing & "unexpected" temporal behaviour.
most of the AVR's hardware has been abstracted by the Arduino platform in functions like digitalWrite(), analogRead(), a bunch of math, bits & bytes, serial, interrupts even!
but not the glaring exception of the timer(s), critical to so many applications, but which are still only presented to the novice user "as is", and with no consideration of wrap-around. why?
We're talking about:
ellapsedMillis em;// ...if (em < 1000) // ...
vs.
unsigned long n = millis();// ...if (millis() - n < 1000) // ...
right? The former doesn't necessarily seem simpler to me as the latter makes the behavior explicit and without adding much overhead to the code.
i think you've forgotten what it's like being new to a high-level language, or being a "non--programmer".
"digitalWrite(13, HIGH)" is pure magic of hardware abstraction of great benefit for the novice.
so is " if ( MyElapsedMillisVariable > 250) { do stuff } ", whether for a 1-off comparison, or even if I have to zero it or subtract 250 from it afterward.
IMHO that's not a complication, it's a much needed hardware abstraction, whose overhead is minimal.
Anthony.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
Did I mention my long-held belief elapsedMillis would be contraversial?� There's a reason I've never brought it up here....
On 11/04/2013 05:31 AM, Tom Igoe wrote:
Mikal makes a good point, building on Dave�s point. One of the concepts I see students (other than those who are good at math) struggle with more than most are variables. "How do variables get their value?" is the usual question. My usual answer is �You give them value, using the = operator, like so: �variable = 5, or variable = analogRead(A0). In the latter case, you know that the function analogRead() is going to return a value when it runs, and you�re putting the value in the variable.� But this proposal makes a variable that changes its value automagically. That�s confusing and inconsistent with the above explanation. �So if we did implement this, what would be a simpler explanation of variables that�s consistent with this new one that changes on its own?
[Paul] I've long intended to package elapsedMillis as a library (AFAIK just add keywords.txt) and publish it somewhere, maybe on the playground?� But that's never been a priority.� Perhaps if someone felt strongly enough about this, they could put in that relatively minor amount of work as a first step?� A readme.txt file could be included, soliciting feedback.� Maybe over time, such feedback might lead to a better sense of whether this feature belongs in the official core?
[Paul] I've long intended to package elapsedMillis as a library (AFAIK just add keywords.txt) and publish it somewhere, maybe on the playground?
* Last post to developer forum on this thread unless further issues are raised - direct emails from now onwards to avoid clutter*
Initial stub article has been created on the Playground (and linked to from main libraries page) -> http://playground.arduino.cc//Code/ElapsedMillis
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
You received this message because you are subscribed to a topic in the Google Groups "Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/a/arduino.cc/d/topic/developers/FAw_W0Vn7kg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to developers+...@arduino.cc.
Matthew,
AFAIK, no (normal) github zip will work as it typically is called [reponame]-master.zip., so I need to come up for a solution to work with auto install in arduino ide, as it seems it makes a folder same name if only one folder in root of zip or a folder the same name as the zip in other cases.
I have little time to work on this at due to other commitments but hope to address this soon.
Pete
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
On 14/11/2013 10:42 PM, Knight, Dave wrote:
Maybe this is a dumb question, but why exactly do you want to read a pwm output pin?
Very sensible question, Dave
and thanks to the others who replied to my email.
I posted an instructable
"Arduino for Beginners, controlled by Android, No coding required, No soldering required"
http://www.instructables.com/id/Arduino-for-Beginners-controlled-by-Android-No-cod/
which controls all the digital and analog pins from your Android mobile.
I am now adding plotting to the android app and wanted to plot the digital pin states.
So I just added a loop to digitalRead each pin and output the result.
BUT when I tried reading a pin set to PWM, Arduino'a digitalRead() over rode the user's PWM setting and made the pin output low.
When I replace Arduino's version of digitalRead with the one suggested by Greg (myDigitalRead below), everything works.
Pete, I checked the Atmel docs and looks to me like you can always read the digital state, and result of Greg's code supports this.So I think this is a bug in the Arduino library and would like to raise request for it be fixed.
Is there a web page on submitting change requests?
matthew
int myDigitalRead(uint8_t pin) { uint8_t timer = digitalPinToTimer(pin); uint8_t bit = digitalPinToBitMask(pin); uint8_t port = digitalPinToPort(pin); if (port == NOT_A_PIN) return LOW; // If the pin that support PWM output, we need to turn it off // before getting a digital reading. //this is MY digital read, I want PWM on. //if (timer != NOT_ON_TIMER) turnOffPWM(timer); if (*portInputRegister(port) & bit) return HIGH; return LOW; }
On 14/11/2013 10:42 PM, Knight, Dave wrote:
Maybe this is a dumb question, but why exactly do you want to read a pwm output pin?
On Thursday, November 14, 2013, Matthew Ford wrote:
While writing a sketch for beginners, I was doing a digital read of a PWM output
And it did not do as I expected.
What I was expecting was HIGH and LOW in about the PWM ratio
But always got LOW.
Then found this in the code
I don't see any reason to override a uses PWM setting just because their code asks for a read.
matthew
int digitalRead(uint8_t pin)
{
uint8_t timer = digitalPinToTimer(pin);
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
if (port == NOT_A_PIN) return LOW;
// If the pin that support PWM output, we need to turn it off
// before getting a digital reading.
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
if (*portInputRegister(port) & bit) return HIGH;
return LOW;
}
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.