First of all hello. I find myself in trouble while trying to simulate the behaviour of a photo interrupter sensor by using Arduino Uno R3. The idea is to get rid of the sensor and use Arduino to send the signals instead, in order to be able to control over device by my own demand.
According to the datasheet - the sensor is powered by 3.3V and has the following outputs. HIGH - if voltage is >2.4V LOW - if voltage is < 0.4V
I have connected my Arduino's PWM pin10 to sensor's output pin and GND to GND and wrote a simple test code that does the state change inside a loop like this:
analogWrite(PinNr, 170);// send High signal 170 = 3.3v PWM output delay(120); // wait 120ms analogWrite(PinNr,0); // send Low signal delay(120); // wait 120ms
Problem is that it does not work this way.
If I connect a simple 3V battery to sensor's output Pin and GND to GND through a simple push button and quickly push and release the button this method works perfect. I need to be able to do this by using Arduino and not by hand so I think the problem relates to the type of signal (Arduino PWM vs analog).
I looked into a way of converting the Arduino PWM signal to analog by using a Low pass filter, yet I have trouble understanding what is the cufoff frequency and the response time of the RC filter that I should take into consideration. For example I know Arduino PWM pin 10 runs at a 500hz frequency and I would like that the filter should respond to the state change HIGH- delay(120)-LOW-delay(120) as fast as possible. Sensor datasheet specifies that any voltage > 2.4v will be interpreted as a HIGH signal and any voltage < 0.4v will be interpreted as a LOW voltage, so I think that ripple can have a greater marje.
Please help me understand what values to choose for the RC