Threading / ReapetingTimers

I have recently learned about how to utilize RepeatingTimers (threading) and would like to know what peoples opinions are on it. I couldn’t find anyone who had actually used it. Those who I talked to and had heard of it were only familiar with the concept.

For those who don’t know what what threading is its simply interrupting the main code at a set interval (per millisecond) to run a function (module) and then returns to the main code where it left off.

I would like to know:

  1. What was your overall opinion

  2. Did it work

  3. How did you use it

  4. How long was the interval (also ms per line if possible)

While this might not be the most practical programming I personally want to know since I am trying to learn all I can. I apologize if this is a repeat thread, I did my best to look for threading, but on a forum it didn’t work so well searching for threads… lol

If you are interested in learning more about RepeatingTimers and threading EasyC has a sample code that uses it: PID Interrupt Service Routine

There is an example of how to use the register repeating timers in the samples directory that comes with easyC V4, but it’s a little complex. RegisterRepeatingTimer is usually used with PID control loops or Looking for sensor Values. The motors update at 20ms intervals so setting the timer to anything less then that unless you are running steppers or something is just wasting resources.

RegisterRepeatingTimer is an interrupt call so keep the code in the function you call short and sweet. Don’t use PrintToScreen, GraphicDisplay, or Wait in functions that are called by RegisterRepeatingTimer.

Here is a an Example that we will be adding to the next release of V4. This example blinks two LED’s simultaneously at different rates.
BlinkLED.zip (1.83 KB)

Sorry if I worded the questions confusingly. When I asked how you used it, I simply meant how you used it in the code (to control what, arms, wheels?).

My main goal is simply see how people have used it, how it worked, and then to decide whether or not to build next years program incorporating RepeatingTimers. I know how use it in general, but so few people using has shied me away some. If you aren’t using it, have you run into problems or simply never heard of it till now?

Most people use this feature for controlling a mechanism. Usually slaving a sensor to a motor. The beauty of it is you can start up the Timer and just issue commands via a global variable and your good to go. This is really useful for presetting arm positions or commanding the direction with say a Gyro.

Honestly, we have hidden the feature in the api header, so unless you were advanced enough at programming to go looking through the header. You wouldn’t see the feature. We do the same with the serial port and the write to flash memory feature.