What is the resolution of EHS6 timer? | Telit Cinterion IoT Developer Community
August 31, 2015 - 4:39am, 3353 views
I want to define a 100ms timer:
Timer timer = new Timer();
UserTimerTask timerTask = new UserTimerTask();
timer.schedule(timerTask, 0, 100);
and in userTimerTask, I will toggle a Led:
if (UpTime % 2 == 0) TurnRedLedOn();
but from oscilloscope, the led on/off time is about 200ms.
How can I get a precise timer?
You could try and output time when TurnRedLedOff and TurnRedLedOn are beeing called. So that you first check if they are called at intended time.
I have MIDlet where I have to turn on/off compressor but ***** there are in secconds not milisecconds. We also took some messaurments with oscilloscope and it on/off where on time. Off perisode was exactly 1 seccond(maybe just *** 10ms off, not 100 like in your case). But I didn't use Timer but I just took current time with new Date added 1000ms and checked in thread which had while loop if current time is >= then time before with added time and it worked like it should.
Your timing is relatively short and Java is not a real time system and the JVM doesn't have the highest priority in the system - these delays may depend on system load etc. and 100% accuracy cannot be guaranteed.
So to get it better I'd try to do the code as simple as possible - so please try to just use sleep in the loop for LED blinking and check if it is any better. Creating Timer and TimerTask objects may also add additional delays.
Thanks for reply.
I want connect DS28E02 (http://www.maximintegrated.com/en/products/digital/memory-products/DS28E02.html) on one of EHS6 GPIO pin, whick is running at 12.5kbps or 37.5kbps. If there is no precise timer at short interval, how can I work with this IC?
In your first post it seemed that you only want a LED blinking driven by GPIO pin.
You can set one of the GPIO pins as input and check the state or ***** pulses. Or you can set it as output and change its state. Switching the GPIO pin state by Java code will not give you the precise and guaranteed timing.
If you want to connect 1-wire interface to the module and transfer data you should rather use one of the available interfaces with some converter to 1-wire standard (i2c or SPI which in fact use the same lines as GPIO pins or RS232).
The timings and for these interfaces is not controlled by Java but provided in some lower level.
Thanks. I will use other IC.