DIY CNC mill gauge and interference?

Backstory - I’ve been building a ground up CNC Mill of my own design. It’s working wonderfully and of course I keep making upgrades and changes.

One such upgrade is a gauge assembly that’s using a uno, voltage dividers and a SSD1306 display. I’m calculating spindle rpm from the spindle control voltage at it’s max speed. The voltage through the 12v (1m/100k voltage divider, 55v max) power supply for the mill seems to be reading pretty accurately vs a multimeter. The voltage though the spindle controller varies with a pot from 5-100v (1m/20k voltage divider, 255v max, read some 170ish with a multimeter) reads all over the place. I’ve tried filtering however it’s still erratic. I believe I’m getting interference from the spindle itself. I’ve posted my code below to browse over. Would a low pass filter help or code filter of some sort that I’m missing. I did remove the code filter I had only because it wasn’t really working.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET     4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

//MILL VOLTAGE MEASUREMENT VARIABLES
unsigned int voltageraw;
float voltageadc;
float voltage = 0.0;

//SPIN VOLTAGE MEASUREMENT VARIABLES
unsigned int voltagerawS;
float voltageadcS;
float voltageS = 0.0;

//SPINDLE RPM MEASUREMENT VARIABLES
float RPM;
float spinmaxvolt = 100; //CHECK WITH MULTIMETER
float spinmaxrpm = 12000; //CHECK WITH LASER TACH
float voltperrpm;

//SPINDLE TEMPERATURE MEASUREMENT VARIABLES
int Vo;
float R1 = 10000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
float T1;
float T2;
float T3;


void setup(void) {
  Serial.begin(115200);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  display.display();
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(20, 0);
  display.println(F("HCM2011"));
  display.setCursor(13, 18);
  display.println(F("CNC MILL"));
  display.display();
  delay(2750);
}

void loop() {
  MILLVOLT();
  SPINVOLT ();
  TACHRPM();
  SPINTEMP();
}

void MILLVOLT() {
  voltageraw = analogRead(A3);
  voltageadc = voltageraw * 0.0048828125; //5.000/1024
  voltage = voltageadc * 11.00; //* 55 MAX VOLT/5 VOLT
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println(F("MILL VOLT"));
  display.setCursor(0, 18);
  display.println(voltage);
  display.display();
  delay(2750);
}

void SPINVOLT() {
  voltagerawS = analogRead(A1);
  voltageadcS = voltagerawS * 0.0048828125; //5.00/1024
  voltageS = voltageadcS * 51.000; // 255 MAX VOLT/5 VOLT
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println(F("SPIN VOLT"));
  display.setCursor(0, 18);
  display.println(voltageS);
  display.display();
  delay(2750);
}

void TACHRPM() { //NOT EXTREMELY PRECISE LINEAR PROJECTION OF VOLTAGE AT MAX RPM
  voltperrpm = spinmaxrpm / spinmaxvolt;
  RPM = voltageS * voltperrpm; //MOTOR VOLTAGE AT 12000 RPM IS 100V
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println(F("SPIN RPM"));
  display.setCursor(0, 18);
  display.println(RPM);
  display.display();
  delay(2750);
}

void SPINTEMP() {
  Vo = analogRead(A2);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T1 = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
  T2 = T1 - 273.15;
  T3 = ((T2 * 1.800) + 32.0) * .95; //0.95 CORRECTION VALUE
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print(F("SPIN F"));
  display.setCursor(0, 18);
  display.println(T3);
  display.display();
  delay(2750);
}

The mega328 data sheet recommends a max impedance on an analog input of 10K. Your voltage divider is more than 10K. You may benefit from a 0.1uF ceramic cap from the input to ground to lower the input impedance.

How often are you sampling?

groundFungus:
The mega328 data sheet recommends a max impedance on an analog input of 10K. Your voltage divider is more than 10K. You may benefit from a 0.1uF ceramic cap from the input to ground to lower the input impedance.

How often are you sampling?

Sampling every 8250 milliseconds. I've got some 0.1uF caps so I'll try that out.

0.1uF caps worked perfectly! Reading as expected now

BTW m as in 1m/10k means milliohms, thousandths of an ohm.

You meant 1M/10k. M = mega. Important to get this right!