Hexen:
I've done this, and used the serial plotter.
The RPM reads perfectly. My issue is the "wall" I'm hitting by using less revolutions to determine RPM.
You have, but we cannot see it. Without data we cannot evaluate what is happening. Obviously it is something very minute where the data would show what is wrong. We don't have your hardware so we cannot implement your sketch and test for ourselves. We will need the values of each tag, not just an XY plot. It likely a maths problem as noted. I see integer division, therefore I see a (large) potential problem.
Hexen: Doesn't work here. You're providing a set interval by which to display the RPM. In my circumstance, I need this interval to be as quickly as possible, which is why I'm using every X revolutions.
I suspect you have not studied it carefully.
Does my program work the way it is intended using your hardware?
If my program is not updating the results often enough then just change the time interval. It could produce a new RPM value for every revolution but that would be much too fast for your eyes to see. Using "every X revolutions" cannot be as fast as the max that my program can do
Robin2:
I suspect you have not studied it carefully.
Does my program work the way it is intended using your hardware?
If my program is not updating the results often enough then just change the time interval. It could produce a new RPM value for every revolution but that would be much too fast for your eyes to see. Using "every X revolutions" cannot be as fast as the max that my program can do
...R
I can probably adapt something like that to work for me. Its not that it won't work at all, but the situation is slightly different. I may be able to get it to work updating no less often than every 100 ms, although 50 ms would be ideal. One of the issues with update intervals comes into play with the PID controlling a stepper motor. If new data isn't provided often enough, the PID struggles to be accurate. I might try your code to see if I can make it work under my particular circumstances. Thank you for that.
adwsystems:
You have, but we cannot see it. Without data we cannot evaluate what is happening. Obviously it is something very minute where the data would show what is wrong. We don't have your hardware so we cannot implement your sketch and test for ourselves. We will need the values of each tag, not just an XY plot. It likely a maths problem as noted. I see integer division, therefore I see a (large) potential problem.
I can provide a screenshot later today, but I don't understand how it is needed.
We are talking about serial data for a single variable, not a full X/Y plot.
Using a lower revolution count at the beginning of my loop seems to put a 'maximum' on the rpm variable. It will read perfectly fine below that maximum, but no matter how much I physically increase the RPM of the engine, the RPM variable will not go above that imaginary boundry.
Hexen:
I can provide a screenshot later today, but I don't understand how it is needed.
We are talking about serial data for a single variable, not a full X/Y plot.
Using a lower revolution count at the beginning of my loop seems to put a 'maximum' on the rpm variable. It will read perfectly fine below that maximum, but no matter how much I physically increase the RPM of the engine, the RPM variable will not go above that imaginary boundary.
Then you aren't understanding where I believe the problem is. The serial output will not be a single variable, but all 6 values used in the computation.
All of these:
revolutions
rpm
timeold
rpmicros
revs
need to be output. In doing so you may see the problem, if it is what I suspect, before you even get it posted.
Hexen:
I can probably adapt something like that to work for me. Its not that it won't work at all, but the situation is slightly different. I may be able to get it to work updating no less often than every 100 ms, although 50 ms would be ideal. One of the issues with update intervals comes into play with the PID controlling a stepper motor. If new data isn't provided often enough, the PID struggles to be accurate.
I use that code in a program that uses PID to control the speed of a small DC motor. The PID value is recalculated after every revolution. The DC motor runs up to 15000 RPM. Your stepper motor won't be going that fast.
Robin2:
I use that code in a program that uses PID to control the speed of a small DC motor. The PID value is recalculated after every revolution. The DC motor runs up to 15000 RPM. Your stepper motor won't be going that fast.
...R
No, the stepper isn't going that fast. Its not particularly the speed of the stepper, but the speed of the PID calibrations. The stepper motor is means to control RPM rise of the engine. So if I want the engine to only increase at a rate of 1000 RPM/second, I need as many inputs as I can get within a second to make sure the PID is able to adjust accordingly. We're talking probably 180* of rotation per second, maximum, but with the ability to do several full rotations.
adwsystems:
Then you aren't understanding where I believe the problem is. The serial output will not be a single variable, but all 6 values used in the computation.
All of these:
revolutions
rpm
timeold
rpmicros
revs
need to be output. In doing so you may see the problem, if it is what I suspect, before you even get it posted.
You're right, I misunderstood you.
I'll change the formula around later to display all of the needed quantities in the RPM computation.
I've slightly edited the original code I posted. I can get it to read an individual rotation on the engine without any issues, even up to high RPM.
Once I add the code back in to measure sensors or output Serial data, the issue returns. I then become limited on maximum RPM that the variable will hold. Is it possible that the loop is taking too long to run?
I've tried to switch to noInterrupts() and interrupts(), but if anything, the issue gets worse. The readings I get that way are much more erratic.
Hexen:
I've slightly edited the original code I posted.
Unless you post the revised code here we cannot help. And PLEASE do NOT change code in an existing Reply - put the new code in your next Reply so we can follow the changes and relate them to the discussion.
I'm also doing many other calculations after I get the RPM number. I'm taking readings from a load cell, a pair of 5v analog sensors, doing math on about a dozen variables, etc. All of these involving that RPM number calculated. Should I do these before or after interrupts() in the above code?