#include /* * Note 1: Averaging of voltage measurements will help reduce jitter * and improve readability on the display of your choice. * Try averaging over 100 or 1000 readings and see what works * best in your project. * * Note 2: Using measured voltages and resistances instead of nominal * values will improve the accuracy of your output. */ //physical values double fiveVoltActual = 5.072; //the measured supply voltage to arduino chip int cathodeResistorOhms = 387.2; //R7 double cathodeSensorOhms = 21770; //R2 double cathodeVoltageDividerOhms = 104870; //R1 + R2 double plateSensorOhms = 21830; //R11 double plateVoltageDividerOhms = 1017920; //R10 + R11 void setup(){ } void loop() { //take voltage measurements double cathodeSensorVoltage = analogRead(A0) * (fiveVoltActual / 1023.0); double plateSensorVoltage = analogRead(A1) * (fiveVoltActual / 1023.0); //calculate current through R2 double cathodeSensorCurrent = cathodeSensorVoltage / cathodeSensorOhms; //calculate voltage at cathode double cathodeVoltage = cathodeSensorCurrent * cathodeVoltageDividerOhms; //calculate current through R11 double plateSensorCurrent = plateSensorVoltage / plateSensorOhms; //calculate plate voltage (minus cathode voltage) double plateVoltage = (plateSensorCurrent * plateVoltageDividerOhms) - cathodeVoltage; //calculate current through cathode resistor R7 double cathodeCurrent = cathodeVoltage / cathodeResistorOhms; //calculate plate dissipation double plateDissipationPower = plateVoltage * cathodeCurrent; //send info to a display or whatever }