Digital Tachometer for record player (LCD display)

[I updated due to calculation errors: Robert]

Alex I looked at the code, try the edits below and let me know how it goes.

** Pyramid's code works between 28 and 100 Hz, you need to change the lower limit to less than 20 (say 17 Hz)

// the loop function runs over and over again forever
void loop()
{
if (UPDATE && DONE)
{ RPM = CALIBRATE / RPM_COUNT; //* compute RPM
if (RPM > 17 && RPM < 100)

**You may need to extend the 1% range in which the code operates (1% of 20 is 0.2 Hz). Try with 1% first, if needed go to 2% here

if (RPM > SETPOINT * 0.98 && RPM < SETPOINT * 1.02) { //* only autocorrect if speed within 2%


** The calculation between RPM and frequency needs to change. The core PID routine calculates error in RPM and then converts to hundredths of Hz (ie button pushes) in this code line. For me it was 33.3 RPM/50 Hz = 2/3 * 100 = 200/3. In your case, 33.333RPM/19.5Hz * 100

ADJFREQ = PIDOUT * 3333.3 /19.5; //* amount of frequency adjustment needed in 0.01 Hz



**Good luck!
 
Last edited:
[I updated due to calculation errors: Robert]

** The calculation between RPM and frequency needs to change. The core PID routine calculates error in RPM and then converts to hundredths of Hz (ie button pushes) in this code line. For me it was 33.3 RPM/50 Hz = 2/3 * 100 = 200/3. In your case, 33.333RPM/19.5Hz * 100

ADJFREQ = PIDOUT * 3333.3 /19.5; //* amount of frequency adjustment needed in 0.01 Hz

**

BTW, for my classic 60Hz one: Do I need to change my code for 60Hz?
Like that?:

ADJFREQ = PIDOUT * 3333.3 /60; //* amount of frequency adjustment needed in 0.01 Hz
 
Alex, yes the motor frequency that results in 33.3 RPM needs to be used to convert the RPM error (PIDOUT) to button pushes (ADJFREQ).

BUT I realized that I calculated this wrong, I was using the reciprocal!

It should be ADJFREQ = RPM * button pushes/Hz * Hz/RPM * = button pushes

For a 60 Hz motor: ADJFREQ = PIDOUT * 100 * 60 /33.3333 = PIDOUT * 180

Technically, you should take the actual frequency at the time, but there is no easy way to read the SG4 frequency. Fixing this error speeds up the correction pulses by about 3x so it converges more quickly. You may need to adjust the PID parameters depending you your turntable reacts.
 
Hi Robert, So and then, how about for 20Hz setup? Is it also needed to be fixed?
Can We do more clear change by adding examples. I'll attached two INO skates (one for 20Hz and one for 60Hz).
Can you please edit these and attach these back to the thread?
That will be very clear and helpful.
 

Attachments

  • Tach_PID_20Hz.txt
    7.7 KB · Views: 81
  • Tach_PID-60Hz.txt
    7.7 KB · Views: 86
Last edited:
Strange that it works at 60 Hz but not at 20 Hz.

Try adding a debug print statement to display m after this line to see if you are getting any button pushes:

m = int(abs(ADJFREQ)+0.5); //* integer number of button pushes, offset by 0.5

You can see that coding is not a strength ;-)