RPM on a 2, 7 Segment Displays from Sparkfun

I’m trying to display RPM on a 2 digit 7 segment display that I have. To get RPM I am using an encoder. I have been able to get the Display to work with the encoder and show a count but not a RPM that is updating. Any help would be appreciated!

//GPIO declarations
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
byte segmentClock = 6;
byte segmentLatch = 5;
byte segmentData = 7;

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Motor encoder output pulse per rotation (change as required)
#define ENC_COUNT_REV 1024

// Encoder output to Arduino Interrupt pin
#define ENC_IN 3

// Analog pin for potentiometer
int speedcontrol = 0;

// Pulse count from encoder
volatile long encoderValue = 0;

// One-second interval for measurements
int interval = 1000;

// Counters for milliseconds during interval
long previousMillis = 0;
long currentMillis = 0;

// Variable for RPM measuerment
int rpm = 0;

// Variable for PWM motor speed output
int motorPwm = 0;

void setup()
{
// Setup Serial Monitor
Serial.begin(9600);

// Set encoder as input with internal pullup
pinMode(ENC_IN, INPUT_PULLUP);

// Attach interrupt
attachInterrupt(digitalPinToInterrupt(ENC_IN), updateEncoder, RISING);

// Setup initial values for timer
previousMillis = millis();
}
void loop()
{

// Update RPM value every second
currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;

// Calculate RPM
rpm = (float)(encoderValue * 60 / ENC_COUNT_REV);

// Only update display when there is a reading
if ( rpm > 0) {

Serial.println(rpm);

}

encoderValue = 0;
}
}

void updateEncoder()
{
// Increment value for each pulse from encoder
encoderValue++;
showNumber(rpm);
}

//Takes a number and displays 2 numbers. Displays absolute value (no negatives)
void showNumber(float value)
{
int rpm = abs(value); //Remove negative signs and any decimals

//Serial.print("number: ");
//Serial.println(rpm);

for (byte x = 0 ; x < 2 ; x++)
{
int remainder = rpm % 10;

postNumber(remainder, false);

rpm /= 10;
}

//Latch the current segment data
digitalWrite(segmentLatch, LOW);
digitalWrite(segmentLatch, HIGH); //Register moves storage register on the rising edge of RCK
}

//Given a number, or ‘-’, shifts it out to the display
void postNumber(byte rpm, boolean decimal)
{
// - A
// / / F/B
// - G
// / / E/C
// -. D/DP

#define a 1<<0
#define b 1<<6
#define c 1<<5
#define d 1<<4
#define e 1<<3
#define f 1<<1
#define g 1<<2
#define dp 1<<7

byte segments;

switch (rpm)
{
case 1: segments = b | c; break;
case 2: segments = a | b | d | e | g; break;
case 3: segments = a | b | c | d | g; break;
case 4: segments = f | g | b | c; break;
case 5: segments = a | f | g | c | d; break;
case 6: segments = a | f | g | e | c | d; break;
case 7: segments = a | b | c; break;
case 8: segments = a | b | c | d | e | f | g; break;
case 9: segments = a | b | c | d | f | g; break;
case 0: segments = a | b | c | d | e | f; break;
case ’ ': segments = 0; break;
case ‘c’: segments = g | e | d; break;
case ‘-’: segments = g; break;
}

if (decimal) segments |= dp;

//Clock these bits out to the drivers
for (byte x = 0 ; x < 8 ; x++)
{
digitalWrite(segmentClock, LOW);
digitalWrite(segmentData, segments & 1 << (7 - x));
digitalWrite(segmentClock, HIGH); //Data transfers to the register on the rising edge of SRCK
}
}

Please read the "How to use this forum" post at the top of any of the boards. Pay particular attention to the part about how to properly post code. Ignoring the forum guidelines is a good way to get your thread ignored by the members.

void updateEncoder()
{
  // Increment value for each pulse from encoder
  encoderValue++;
  showNumber(rpm);
}

showNumber probably doesn't belong in the ISR. That call should be from loop up there where you are printing the rpm.

Does the rpm print right on the serial monitor?

Thanks for the reply! Yeah I didn't see that post until this morning and it's my first time ever posting in here. I will make sure to follow the correct formatting going forward.

Right now in the serial monitor it is print correctly. Just seems to be an issue between getting that number to show up on the displays. I was able to get it to work with the encoder and get it to count up and down and display with some different code but for some reason this one I just can't seem to figure out.

How is the display connected. You appear to have some sort of driver for it because you’re only using a couple of pins. Normally a 7 segment would take 7 or 8 pins.

I'm using sparkfun's large digit drivers. I know they work because they will display the correct number another set of code I wrote that uses the encoder to basically move a count up or down and display. I think I'm just missing some piece of the puzzle now or changing some code to get it.
Even now something come's up on the board when I run the RPM program it just doesn't update and the display lights up random segments instead of the number

Delta_G:
showNumber probably doesn't belong in the ISR. That call should be from loop up there where you are printing the rpm.

Have you fixed this?

Yeah even after moving it nothing changed on the display.

Ok. Post the new code then.