What is the loop time for OperatorControl function?
I wrote a program to figure this out myself, but then I couldn’t even figure that out because I remembered how difficult it was to even try and debug with these PIC controllers.
I don’t have a background in PIC or C programming. But I can program. I normally program controllers like PLCs and other controllers that support online programming, and allows me to pause the controller, and check variables. (Break Points) So I learned in this controller, you can’t do that. You have to debug using print statements to a terminal window. The problem I’VE ALWAYS HAD, is the print statements don’t seem to me they EVER MATCH what the ACTUAL VARIBLE IS IN THE CONTROLLER.
For example, back to my problem, I started off with no timer and setting a variable called count = count +1 in the OperatorControl function, then slapping a PrinttoScreen “count” variable. Last I remember this controller does a loop every 26.2ms. So I put an IF statement, if count >= to 38, then print another statement. I assumed I would see this print statement every 1 second in my terminal…I don’t…it’s faster than that….
So I decided to use the EasyC timer, it support milliseconds, so I set my If statement to if timer >= 1000, then print to screen…yah…it works…But now the same problem I have every single year with the printF or now print-to-screen, is that it doesn’t seem like the variable that is being printed is actually what my variable is inside the controller, or is it?
See ZIP attached. This simple timing program should capture and measure the loop time of OperatorControl function and print that information to screen for me, instead every time the print-to-screen prints the variable count to screen, it increments 1,2,3,4,5, hits about 16, then it jumps to 1568,1569,1570 to something like 1700, then finally enters the If statement, prints the count variable one final time, resets the timer, resets the count = 0, then starts all over.
Why, why, can’t I ever get the 2004, 2005, 2006 controllers to DEBUG right? Why does my count variable count from 1 to 16, then jump up to 1500? What is wrong with my code? Am I using the printF statement incorrectly?
Finally, since I can’t trust what print screen is telling me what my variable is, does anyone just know what the loop time of OperatorControl function loop time is? I think it’s FASTER than 26.2ms per loop. The reason I want to know, is because I wrote another velocity function that is going to be part of a PID function I need to know my sampling time to pull this off. And within that function, it looks like it was executing fast, but I will never know, because I can’t get the printF to work for me and stop lying about what the variables are in my program.
Can someone help set me straight?
test.zip (5.19 KB)
test.zip (5.19 KB)