我在使用Z4D-C01 采集输出时,无法准确的读取输出信号,OMRON 关于Z4D-C01 timing diagram的信息不完整,有没有关于Z4D-C01 timing diagram的信息分享?
Which arduino are you using?
I don't know about accuracy but looking at the datasheet, its seems you could try 2 methold to read the sensor
methold 1 - Continuous Read
#define PLS_PIN 4
#define OUT A0
void setup() {
Serial.begin(115200);
pinMode(PLS_PIN, OUTPUT);
digitalWrite(PLS_PIN, HIGH);
delayMicroseconds(600); //800us delay. tr1+tr2 600us max
}
void loop() {
Serial.print("ADC readout:");
Serial.println(analogRead(OUT));
//delayMicroseconds(80); //Output Update every 80 microseconds.
//but should not be necessary as analogRead() is slow
}
Method 2 Polling
#define PLS_PIN 4
#define OUT A0
void setup() {
Serial.begin(115200);
pinMode(PLS_PIN, OUTPUT);
digitalWrite(PLS_PIN, LOW);
}
void loop() {
Serial.print("ADC readout:");
digitalWrite(PLS_PIN, HIGH);
delayMicroseconds(600);//tr1+tr2 600us max
Serial.println(analogRead(OUT));
//delayMicroseconds(80); //Output Update every 80 microseconds.
//but should not be necessary as analogRead() is slow
digitalWrite(PLS_PIN, LOW);
delay(1); //1ms polling
}
a uno has 10-bit ADC ie recolution of approx 5mV per bit.
hope that helps....
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
