GrumpyGel
Well-Known Member
Ah yeh, that's a lot simpler than a switchThe code below is the software I'm using to control both the coolant pump and the vac pump. The threshold was originally set to 250 and this controls the vac level. This was the default level from the author. I tried changing it to 100 but the pump didn't turn off at all, so I turned on the serial port monitor and noticed with no vacuum it was showing around 750 so I changed it to 500 and this seemed to work well. Looks like the higher the number the lower the vac.
Now I need to reconfigure things so I can get at it again if necessary without stripping the car.
#define DEBUG 1 // comment this out to turn off serial comms once you've set the threshold & hysteresis #define SENSE_PIN A0 // connect to the output of the sensor - you also need to feed it 5V and gnd #define RELAY_PIN 10 // connect to the relay input. Check whether the relay is active high or low! #define HYSTERESIS 50 // stops the pump cycling on and off when close to threshold #define THRESHOLD 250 // Where does it turn on/off. Can't remember what my final number was but this is a good start void setup() { //Coolant pump controller setup // Set-up PWM on the Arduino UNO at 1Hz on Digital pin D9 pinMode(9, OUTPUT); // Set digital pin 9 (D9) to an output TCCR1A = _BV(COM1A1) | _BV(WGM11); // Enable the PWM output OC1A on digital pins 9 TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS12); // Set fast PWM and prescaler of 256 on timer 1 ICR1 = 31249; // Set the PWM frequency to 2Hz: 16MHz/(256 * 2Hz) - 1 = 31249 OCR1A = 14062; // Set the duty-cycle to approx 45%: 31249 / 45 = 14062 30 = 9374 //Vacuum pump controller Setup #ifdef DEBUG Serial.begin(9600); Serial.println("Debug Mode: Serial Comms Enabled"); Serial.print("Threshold: "); Serial.println(THRESHOLD); Serial.print("Hysteresis: "); Serial.println(HYSTERESIS); #endif pinMode(SENSE_PIN, INPUT); pinMode(RELAY_PIN, OUTPUT); #ifdef DEBUG Serial.println("Pump Priming"); #endif digitalWrite(RELAY_PIN, LOW); delay(5000); digitalWrite(RELAY_PIN, HIGH); } void loop() { int value = analogRead(SENSE_PIN); #ifdef DEBUG Serial.print("ANALOG READ: "); Serial.println(value); delay(100); #endif if (value > (THRESHOLD + HYSTERESIS)) { digitalWrite(RELAY_PIN, LOW); #ifdef DEBUG Serial.println("RELAY ON"); #endif } else if ( value < THRESHOLD - HYSTERESIS) { digitalWrite(RELAY_PIN, HIGH); #ifdef DEBUG Serial.println("RELAY OFF"); #endif } else { // do nothing } }
Have to say that's 1 thing I'd love to get into 1 day, using an Arduino to do 'stuff'.