Hi Guys.
I have set up a controller for my diy MVHR system using two fans, an arduino , and a relative humidity sensor,
I set a target RH level and when the RH is higher than the target the fans increase speed in relation to how far above the target the actual RH is.
It's working pretty good. I'm using 24v 4 wire motors 1, pos wire, 1, neg wire, 1, 0-10v input to control the speed and 1, output wire, 2 pulses per revolution.
I have attached the 2 pulses per rev wire to an input and I'm getting a reading but I don't think it's accurate.
I'd like to add that I know practically nothing and would just like to know enough to be able to read the revs.
It's not essential to the running of the sketch but I think it would be a nice feature.
If it's not a 5V signal then you have probably just damaged your Arduino
Do you have a datasheet for your fan?
The datasheet does not specify what the tach output is.
It's probably an open collector output but without knowing for sure I can't tell you that it is safe to connect to your Arduino.
Do you have a DMM so that you can measure the tach output voltage when the fan is running?
then I guess that it's a NPN output that deserves a pullup resistor.
At least it's a digital output, not analog.
Or it could be 24V or anything inbetween
It's showing 2.6/2.7/2.8
Serial monitor read out is
minimum -31488.
maximum 7903.
What I planned to be revs.
That is when it is not conneced to the Arduino, correct?
The DMM connected between the white and blue wires?
Now you need to post your code.
In the IDE go to EDIT -> Copy for Forum and paste the code here.
Just want to be absolutely certain it is safe to connect the tach output to your Arduino
It's a bit of a mess but working,
I was cleaning it up a bit so it didn't look daft.
I'm actually getting a more sensible reading now.
from80 to 880
Anyway here's the code hope you can help.
#include <Timer.h>
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogReadSerial
*/
int norMalmax=80;
int norMalmin=30;
int targetRH=60;
int potPin=A0;
int pin9;
int pin5;
int fanPin=5;
const int revPin=10;
float potVal;
int inPin=3;
int normalSpeed=30;
int boostSpeed=80;
int fanSpeed;
float fanVal;
float revs;
const int inpin=3;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
//pinMode(potPin,INPUT);
pinMode(fanPin,OUTPUT); // 0-10v out to control fan speed
}
// the loop routine runs over and over again forever:
void loop() {
// read the output on analog pin0
int sensorValue = analogRead(A0);
analogWrite(fanPin,fanVal);
fanSpeed=(255./1023.)*sensorValue;
sensorValue=sensorValue/10.23; // simulates RH%
fanSpeed=sensorValue-targetRH;
fanSpeed=(fanSpeed*4)+30;
if(fanSpeed<normalSpeed){fanSpeed=normalSpeed;}
if(fanSpeed>boostSpeed){fanSpeed=boostSpeed;}
revs=analogRead(revPin);
fanVal=fanSpeed*2.5;
analogWrite (pin5,fanVal);
// print out the value you read:
Serial.print("Relative Humidity ");
Serial.print(sensorValue);
Serial.print(" ");
Serial.print("Fanspeed ");
Serial.print(fanSpeed);
Serial.println(" %");
Serial.println(fanVal);
Serial.println(revs);
delay(2000); } // delay in between reads for stability
So you don't care if it's safe to connect to your Arduino?
I forgot to say I'm using the input from a pot to simulate the RH value so I can turn it up and down to test.
It's already done.
Doesn't mean it won't eventually burn out your Arduino but it's up to you.
OK I'll disconnect it.
I don't want to tell you to do something that may potentially be bad for your Arduino.
With the fan disconnected from your Arduino, connect your DMM between the white and blue wires and check the voltage.
What is the voltage?
2.5v
Do you have an oscilloscope?