I like to control a server PSU and the pinout to detect the status is about 3.1V. As I am running out of analog inputs I like to use a digital input to detect high and low with my 5V Arduino Every. I read mostly it should work even with 3.3V but it seems that the arduino is jumping around low and high and the PSU does not deliver 3.3V.
I checked it with a cheap oscilloscope it the voltage on the pin looks stable.
I found that to get high readings the voltage must be over 3V with my board and low reading below 1,5V constants - Arduino Reference So it could be too near to 3V.
Any ideas to solve this behavior without changing the circuit? One idea is to use a optocoupler which I used to decouple a second PSU from ground which is connected in series. There it works fine.
Can it be the classical issue, declareing that input as pinMode( x, INPUT) instead of INPUT_PULLUP?
What kind of output is pulling the ttroubeling input? An open drain device?
I would get problems with the board which is still finished. And a pin compatible nano 33 would not have enough power to supply the LCD with the internal converter. Also a internal pull-up to 5V will bring problems for the input 3.3V line.
I am thinking about buying a bidirectional level shifter board for 2€ at EBay. As it is a simple PSU is on/off status it should be fine in my opinion. What do you think? It is a single pin only.
Attached also the description of the Pin from PSU. I like to connect only one of these.
nilsro:
I am thinking about buying a bidirectional level shifter board for 2€ at EBay. As it is a simple PSU is on/off status it should be fine in my opinion. What do you think? It is a single pin only.
Use INPUT_PULLUP on the pin and connect a diode with cathode to your input source - whatever that is as you have not explained it - and anode to the Arduino pin. This will increase the voltage seen on the pin by 0.6 V in either state.
It will also protect the Arduino from odd voltages.
I do not trust simulations as such. The simulation agrees with my explanation, but whether it actually suits your circuit is another matter.
I advise against interrupts because they are not necessary for the purpose you imply, nor are they useful.
A common "newbie" misunderstanding is that an interrupt is a mechanism for altering the flow of a program - to execute an alternate function. Nothing could be further from the truth!
An interrupt is a mechanism for performing an action which can be executed in "no time at all" with an urgency that it must be performed immediately or else data - information - will be lost or some harm will occur. It then returns to the main task without disturbing that task in any way though the main task may well check at the appropriate point for a "flag" set by the interrupt.
Now these criteria are in a microprocessor time scale - microseconds. This must not be confused with a human time scale of tens or hundreds of milliseconds or indeed, a couple of seconds. A switch operation is in this latter category and a mechanical operation perhaps several milliseconds; the period of a 6000 RPM shaft rotation is ten milliseconds.
Unless it is a very complex procedure, you would expect the loop() to cycle many times per millisecond. If it does not, there is most likely an error in code planning. The loop() will be successively testing a number of contingencies as to whether each requires action, only one of which may be whether a particular timing criteria has expired. Unless an action must be executed in the order of microseconds, it will be handled in the loop().
So what sort of actions do require such immediate attention? Well, generally those which result from the computer hardware itself, such as high speed transfer of data in UARTs(, USARTs) or disk controllers.
Paul__B:
Expand!
OK, so that is seriously mixed up!
Try the diode.
I would go for an analog input. Then you can handle all possibilities. Preferably even with a 2:1 voltage divider so you can use the 1.1V internal reference and have your readings independent from Vcc (which can be as low as 4.4-4.5V running on USB or as high as 5.1-5.2V on a not perfectly regulated phone charger).
Ok, I am running out of analog inputs thats also the reason because I uses digitals. From documentation I first understood that at least the Interrupt signal should behave like a digital one but its clear to me that the analog input would be much better to handle such things.
Perhaps for next board version a comparator like aarg mentiond could be used with a diffrent reference voltage made with resistors to compensate this two inputs?
I added the diode and it bahave like expected but the high voltage is not very stable now. So it detects a low state even with the higher voltage. Any ideas? Perhaps I have to sacrify an analog input...
nilsro:
I added the diode and it bahave like expected but the high voltage is not very stable now.
It seems not a problem from the PSU directly. If I started the PSU in stand by the Pullup is stable. If the main power is switched on by the arduino the pullup voltage and also the 5V output becomes unstable in the same way. But the 12V VIN is stabilised with a 16V 2200mF capacitor.
Any ideas what could case such things? I think this is the original cause because it does not work fine.