171 views
in Platform Packages by

Hello,

I'm developing a diagram based on the Climate Cabinet example.

The diagram on the x axys is showing the time of a machine cycle.

When the cycle starts, the on set method of the Start Cycle loads on the 3 phases time variable the program selected phases.

Then the Remaining Time property gets loaded with the sum of the three phases in ms, and the count down timer is started.

The property remaining time is updatated by a timer, if remaining time is equal to zero, the StartCycleProperty is set to false, instead if not, a delta is calculated between the remaining cycle time and the total time, to get  the elapsed time, and set the power output accordingly.

Te Remaining Time (in ms) is updated  first, with the remaining time in ms being subtracted by the amount of ms counted by the period of the timer, because the timer trigger every Timer.Period ms so from the remaining time is subtracted the just elapsed ms, this gives a sensitivity  intervalof the Timer.Period in ms.

 

The Diagram is updated by a Property observer that updates the graph when the remaining time is modified, and call the Update method witch invalidates the view,

 

With this implementation i'm expecting that when i modify the Timer.Period that updates the diagram. I'll get a refresh rate likely to be in ms every timer trigger.

I'm also printing the time on the diagram, only when the timer.period is set to 100 ms the time is correct( measured with a side  stopwatch), when i set it to 10 ms,the total time is not true to the stopwatch time.

Cannot find the cause of this, i think theoretically wise the process is correct.

 

 

1 Answer

0 votes
by
 
Best answer
Hi Riccardo,

I'm not sure if I understand the issue correctly, but please be aware that accumulating the period of a timer (each time the timer has expired) does not give you a reliable time base. (Worst case: You have a timer with 1 ms, and you want to change the content on the screen every time the timer expires - but the update of the screen cannot be faster than 20 ms (at 50 Hz)...) The period of a timer gives the desired (minimum) time of the next expiration. However, if the main loop cannot process the timer fast enough, the period may be longer.

In case you want to measure a timespan within your GUI application in milliseconds, you can call the function EwGetTicks() within a piece of native code (at start and stop) and calculate the delta. This function returns the number of milliseconds since system start.

Best regards,

Manfred.
by

(Worst case: You have a timer with 1 ms, and you want to change the content on the screen every time the timer expires

Thati is indeed what i was doing.

I'm displaying ADC readings that are much faster than 50 hz. How could that be possible? 

by
You have to separate the ADC data collection from the display update frequency.

Example: If you have 100 samples per second and you want to show one sample per pixel in x direction, the graph will cover 100 pixel per second - independent if you have 50 frames per second, 20, 10, or only 1.
by
Yes, but if the status bar of the process is moving accordingly to the fps of the display,  if i have a 100 samples per second ( so 1 sample every 10 ms)  but the refresh rate is 50 ms, on the graph the effect is a jump of 5 pixel every update, on the time axis, right?
by
Thats correct. You cannot force the display to update with the speed of your data source. You have to sync on the update of the display (= the speed of the main loop) and to present the data that have been collected since the last update.
by
Thanks Manfred

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...