i am reading a voltage in on pin0, the voltage comes from a Vibration MEMS sensor (CN0532) then thru a voltage divider (as output voltage from sensor is 12v +-2v) if there is no vibration then the voltage doesnt change and the arduino outputs a reading of 12v as expected, however when i add vibration and voltage changes the arduino crashes.
i have checked connections, nothing loose (the arduino isnt subject to the vibration)
Any idea on what my problem is?
Perhaps the arduino is not able to output fast enough?
thanks
// Define analog input
#define ANALOG_IN_PIN A0
// Floats for ADC voltage & Input voltage
float adc_voltage = 0.0;
float in_voltage = 0.0;
// Floats for resistor values in divider (in ohms)
float R1 = 10000.0;
float R2 = 4700.0;
// Float for Reference Voltage
float ref_voltage = 5.0;
// Integer for ADC value
int adc_value = 0;
void setup(){
// Setup Serial Monitor
Serial.begin(9600);
//Serial.println("DC Voltage Test");
}
void loop(){
// Read the Analog Input
adc_value = analogRead(ANALOG_IN_PIN);
// Determine voltage at ADC input
adc_voltage = (adc_value * ref_voltage) / 1024.0;
// Calculate voltage at divider input
in_voltage = adc_voltage / (R2/(R1+R2));
// Print results to Serial Monitor to 2 decimal places
//Serial.print("Input Voltage = ");
Serial.println(in_voltage, 2);
// Short delay
delay(500);
}
Hi Folks, thanks for replies and sorry for delay in replying back.
Did some more work on this and here is summary.
The vibration sensor outputs voltage (12v) into voltage divider and then into analog pin A0 of the Arduino, then data is sent via serial port into Labview.
Previously i was using Labview to download code into Arduino UNO and I didnt realise this....guess this was causing things to freeze up..
Anyway i changed Labview code so it reads in from serial port from Arduino UNO, so all good there.
My issue now is to find out often the Arduino outputs through the serial port, or what is the sampling rate, i need this to create a frequency domain chart in Labview.
Read up a bit about it but not too clear on a method to figure this out.
The problem your breadboard is that if the connection to 0v from the voltage divider is bad/loose/falls out , you will put 12v ( or so) into the analog input and maybe destroy or at least crash the Arduino.
I’d solder something up