Hello, I'm trying to make a simple circuit made of a TON block and a timer. I found that I was not able to light the LED in the correct 2000ms (it was about 10x slower). I tought that it was maybe because of my blank.cpp file being to heavy so I decided to make it lighter and , lo and behold, it got much faster, (but still 2x too slow). I added my "heavy" blank.cpp file. Is there anyway to make it faster?

A big thank you to all of yall.
Quote 0 0
What is this code for? What platform are you running this on? It is hard to identify the issue without knowing what you're trying to do. Your code seems to be trying to access I2C data, but it has tons of cryptic variables (what are vars p,j,m,n for?), not to mention that m was declared twice. I imagine you're trying to use these vars to iterate through a two-dimension array. If that's the case, you should use nested loops instead. 

If you're concerned with performance of your code, you should setup some timers and measure how long it takes to execute each function (updateBuffersIn and updateBuffersOut). Once you have that number you can tell if your code is running too slow of if the cycle time of your program is too short. Ideally your hardware layer code should take less than half of your cycle time to execute. If it is taking more than that, it might interfere with the accurate cycling. The default cycle time for a blank OpenPLC Editor project is 20ms.
Quote 0 0