-
-
Gordon
Thanks. I'll certainly be using the crystal, but drift in the clock bothers me less than scheduling inaccuracies.
I'd note that my testing so far really shows quite surprising accuracy - even if I change wastetime() to loop for 20k times, it's still accurate. So much so that I
think something must be wrong....OK, some questions
You say it's not pre-emptive - does that mean if I have a time-consuming function which lasts 10 seconds, setIntervals won't get called at all? (I know I shouldn't do this, but ...)
Is there anything in the system which might cause it to block setIntervals for some largeish time period - I'm thinking bit-bang serial, I2C, CC3000..
I presume getTime() returns a value that is read directly from hardware when you call it?
I see two solutions to deliver an accurate GetDateTime function which includes both calendar date and milliseconds:
Your suggestion - a global date-time variable updated every second
A getDT function which, when called, reads GetTime and updates a global clock variable according to time elapsed since the last time it was called.
If setInteval can get delayed, and I have long-ish functions, then I suspect I need to use #2. The problem is that so far I can't duplicate a problem case :)
Martin
-
Hi
I'm trying to add high-quality logging and I want to put an accurate time-stamp
on each line. Gordon has provided an example using setInterval to increment
an internal clock global variable, which can then be read by other code. But my
experience of other microcontrollers made me a bit concerned about how this
might work. For example, perhaps there's some other code which delays setinterval
by a few MS - not significant really but perhaps this might miss the rollover to the
next second.So, I've just written a quick test program. It uses setInterval to setup a callback every
1 second, and then calls getTime() to see how close setInterval is being called to every second. (I couldn't get the upload code attachment to work, so it's pasted below)The results are quite surprising - setInterval is calling my target function with an accuracy of less than 1/10 ms. To try to push it off track, I've setup another 10
setIntervals, all just wasting time. It doesn't affect it... even if I make them waste
a lot of time. (This is a bit of a puzzle, it almost suggests that successive setIntervals
will interrupt each other to make sure they all start close to target time??)Of course, it's possible that some other activity - e.g. hardware interfacing might hit the accuracy if interrupts are off for a while.
var startTime=0; var seconds=0; var acc=0; function checkTime() { var t=getTime(); seconds++; var d=(t-startTime)-seconds; acc = acc+d; print(seconds,t-startTime,d, acc/seconds, (d-acc/seconds)*1000); } function wasteTime() { var a,b,c; for(var i=0;i++;i<200) a=b*c+b*a; } function testTime() { startTime=getTime(); for(var i=0;i<10;i++) setInterval(wasteTime,1000); setInterval(checkTime,1000); }
-
-
-
Hi
Without thinking about it, I created a script with
var reset=0;
in the top level. I then used save();
Once I'd done this, I obviously couldn't use reset() to clear the memory, and
hard-reset reloaded the same program..I really couldn't see how to get out of this. But I messed about for a while and
eventually somehow it went away.If there is a way to undefine a variable or clear the program memory without using
reset() it would be useful to document here please :) -
Hi
I was trying to dump out onewire IDs in Hex. I took the device ID
from ow.search and called toString(16). I think this caused Espurino
to crash.... the device ID was a huge negative number when normally
printed.Sorry for not quoting the number itself.
Martin
P.S. Where should I post bug reports if not here?
-
-
-
-
Gordon
On http://www.espruino.com/WIZnet the link to the git builds doesn't work, sorry
Is there any particular reason for the choice of the WIZ550io module? Just wondering
if http://www.shopwiznet.com/wiz820io might work as it's smaller. It's an older chip, but maybe the API is the same? (I'll check if you don't immediately know)
Thanks
martin
-
-
-
I've just taken delivery of a pre-order Espruino. I think it has 1.43 firmware on it.
I have Chrome 33. Win 8.1 ProI can connect in web IDE. It says 'upgrade firmware'. I can see firmware URL
in the upgrade page as soon as I go to it: http://www.espruino.com/binaries/espruinĀo_1v53_espruino_1r3.binI follow the instructions
- Disconnect then connect - check URL appears. All fine.
- Disconnect, then press BTN1 and then RST - I get nice blue glowing LED
- But now... Windows beeps to say device disconnected, the list of serial ports
is empty.. - Connect says "invalid serial port"
I can't get beyond this. It seems that as soon as I'm in firmware update mode, the
serial port isn't there. Strangely, the port IS present in control panel / devicesI have Win 8.1, and I've installed the CDC driver.
Any ideas? I suspect my firmware is so old I must use another method?
- Disconnect then connect - check URL appears. All fine.
-
-
Hi
I'm designing a project which will be a little tight on space, and having a micro USB
sticking out of the edge may use up too much room.Are the power inputs available on any other pins?
(Maybe I missed it, but a discussion of power in general - i.e. USB voltage and how much we can draw from the regulator would be good :))
Thanks
Martin
-
-
-
Hi
I've tried to write a clock module, but it needs to do an internal setInterval to call an internal function. I tried to setInterval(this.tick,1000) but it fails.
I think I found some example code - this defines the function to be called by setInterval in the exported init function - which I think means it will be cloned every time the class is used - which wastes memory a bit.
Is there any way to have a module function that is called by setInterval...?
Thanks
Martin