What is the propagation time of the Optocoupler? It takes time for the optocoupler output to change, after the input LED is energized.
Look at figure 12, here:
What is your Rload?
What is the propagation time of the Optocoupler? It takes time for the optocoupler output to change, after the input LED is energized.
Look at figure 12, here:
What is your Rload?
hi what ever the specs are on the hardware, i can get the circuit to work. if i move the print command the code does not work. how does the print command effect the digital read command or more accurate the position of the print command
time signal is on 1 sec time signal is off 1 sec.
because i can get it to work, the problem is not in the optocoupler, it is not in the processor (unless the processor is faulty) there is something in the code
this is when you set the input of the optocoupler high
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
then next line is reading the optocoupler output and it takes 4.9µs to do so and then print whatever you read
Serial.println(digitalRead(ledin));
as @camsysca said
because depending on how it works, may be 4.9µs later you don't have the value ready to be read in.
if you add printing text, that slows down a bit the execution of the code and may be that's enough for the propagation to be OK
just a thought
(and I'm unsure about your 4N25 wiring)
Why not connect to an interrupt pin and not worry about delays
hi guys i have had time to think about where you were heading with the optocoupler.
the code was to fast for the optocoupler to switch off. i can get 18 digitalReads before it goes low. problem solved.
thank you for you inputs
So the topic can be marked solved?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.