Could this Code be running a NANO out of CPU cycles??

So I have a sketch done up for a Engine Tachometer that uses LED’s rather than a Needle to indicate the RPM. On the bench it works as intended up to about 3000 RPM but then the Serial output simply Stops???

As seen in the attached code the engines RPM is set at 6000 and the Shift indicator is set at 4500.

I cannot see anything in my code that would cause it to stop working at 3000 RPM so am wondering if I am running the NANO out of CPU Cycles at the 3000 RPM Mark.

I turned off the Serial output to see if that made any difference - It did not.

If anyone can see anything in the code that might cause this I would be most appreciative if you could let me know.

Thanks in advance.

2812-LED-Tach-Rev-Working_Code_as_of_20-07-29.ino (10.2 KB)

Post the code properly an someone might look at it.

In the mean time, do the math yourself. 10 bits per character sent on serial. Divide your baud rate by 10 and see how many actual characters you can send per second. Then how many characters you are sending per second at 3000 rpm? How many can you send at 3500 rpm?

UP you baud rate and try the program again.

Paul

I think you need to clear up these many warnings.

You have “StartFlag = 1” instead of “StartFlag == 1” as the conditional expression in an ‘if’ statement. You are passing ‘delay’ (the name of a function) to functions that take an unsigned long value. You have written statements that have no effect (do a comparison and don’t store the result).

.ino: In function 'void loop()':
.ino:63:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   if (StartFlag = 1)
       ~~~~~~~~~~^~~
.ino: In function 'void ShiftPointWarning()':
.ino:114:19: warning: invalid conversion from 'void (*)(long unsigned int)' to 'long int' [-fpermissive]
   BlinkBlue (delay);
                   ^
.ino:133:6: note:   initializing argument 1 of 'void BlinkBlue(long int)'
 void BlinkBlue(long delayTime)
      ^~~~~~~~~


.ino:115:18: warning: invalid conversion from 'void (*)(long unsigned int)' to 'long int' [-fpermissive]
   BlinkOFF (delay) ;
                  ^
.ino:175:6: note:   initializing argument 1 of 'void BlinkOFF(long int)'
 void BlinkOFF(long delayTime)
      ^~~~~~~~


.ino: In function 'void OverRevWarning()':
.ino:126:18: warning: invalid conversion from 'void (*)(long unsigned int)' to 'long int' [-fpermissive]
   BlinkRed (delay);
                  ^
.ino:154:6: note:   initializing argument 1 of 'void BlinkRed(long int)'
 void BlinkRed(long delayTime)
      ^~~~~~~~
.ino:127:18: warning: invalid conversion from 'void (*)(long unsigned int)' to 'long int' [-fpermissive]
   BlinkOFF (delay);
                  ^
.ino:175:6: note:   initializing argument 1 of 'void BlinkOFF(long int)'
 void BlinkOFF(long delayTime)
      ^~~~~~~~
.ino: In function 'void BlinkBlue(long int)':
.ino:143:16: warning: statement has no effect [-Wunused-value]
     LED_NUMBER < NumLedsToLight; ++LED_NUMBER;
     ~~~~~~~~~~~^~~~~~~~~~~~~~~~


.ino:133:21: warning: unused parameter 'delayTime' [-Wunused-parameter]
 void BlinkBlue(long delayTime)
                     ^~~~~~~~~


.ino: In function 'void BlinkRed(long int)':


.ino:164:16: warning: statement has no effect [-Wunused-value]
     LED_NUMBER < NumLedsToLight; ++LED_NUMBER;
     ~~~~~~~~~~~^~~~~~~~~~~~~~~~
.ino:154:20: warning: unused parameter 'delayTime' [-Wunused-parameter]
 void BlinkRed(long delayTime)
                    ^~~~~~~~~
.ino: In function 'void BlinkOFF(long int)':
.ino:175:20: warning: unused parameter 'delayTime' [-Wunused-parameter]
 void BlinkOFF(long delayTime)
                    ^~~~~~~~~
.ino: In function 'void DisplayCurrentRpm()':
.ino:239:16: warning: statement has no effect [-Wunused-value]
     LED_NUMBER < NumLedsToLight;  LED_NUMBER ++;
     ~~~~~~~~~~~^~~~~~~~~~~~~~~~
.ino: In function 'void InitializeAllLeds(long int)':
.ino:258:16: warning: statement has no effect [-Wunused-value]
     LED_NUMBER < NumLedsToLight; ++LED_NUMBER;
     ~~~~~~~~~~~^~~~~~~~~~~~~~~~
.ino:249:29: warning: unused parameter 'delayTime' [-Wunused-parameter]
 void InitializeAllLeds(long delayTime)
                             ^~~~~~~~~
Sketch uses 8058 bytes (24%) of program storage space. Maximum is 32256 bytes.
Global variables use 439 bytes (21%) of dynamic memory, leaving 1609 bytes for local variables. Maximum is 2048 bytes.

Albeix:
works as intended up to about 3000 RPM but then the Serial output simply Stops???

For things that work "up to about 3000" I would pay close attention to data types. An 'int' variable can only hold a value up to 32767. If you don't need negative values you can use "unsigned int" to get values up to 65535. For negative values, try "long int" which can hold +/-2.1 billion.