Digital Input with 3.1V - constanly changing and triggering interrupt

Hi all,

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.

Cheers,
Nils

Use a comparator IC. You will then be able to fully control all your parameters - threshold and hysteresis.

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?

Simplest solution: use a 3.3V Arduino to avoid level shifting circuitry with each input.

DrDiettrich:
Simplest solution: use a 3.3V Arduino to avoid level shifting circuitry with each input.

...but then, what about the 1.5V low?

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.

Cheers,
Nils

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.

What about the issue I raised in reply #4?

The attachement has gone invisable on my screen...

The eBay board I can simply attach to the wires or somehow. That’s all, it would be simple to add if nothing is against it.

Attached now the documentation of the bus. Blocks the file name before. Perhaps you see something helpful or another way...

Cheers,
Nils

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. :sunglasses:

IMG_0076.jpg
Expand!

OK, so that is seriously mixed up!

Try the diode. :astonished:

And you certainly should not be using interrupts! :roll_eyes:

nilsro:
Attached now the documentation of the bus.

Right. Use a comparator.

Hi

I build the diode in a simulation and it works fine. Attached my setup. The increases the voltage above the limit. Thanks a lot! :smiley:

But some questions:

  • How would the comparator solution be better as I understood the digital input is still a comparator but with wrong reference voltage for 3V input?
  • How should a cool solution looks like? Like to understand it for new projects.
  • Why not using interrupts for detecting status changes?

Cheers
Nils

Schaltung.pdf (6.23 KB)

I do not trust simulations as such. The simulation agrees with my explanation, but whether it actually suits your circuit is another matter. :grinning:

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! :astonished:

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:
IMG_0076.jpg
Expand!

OK, so that is seriously mixed up!

Try the diode. :astonished:

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?

Hi Paul,

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...

Regards,
Nils

nilsro:

  • How would the comparator solution be better as I understood the digital input is still a comparator but with wrong reference voltage for 3V input?

I explained that in reply #1.

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.