Author Topic: Strange behaviors with microcontroller digital inputs  (Read 1573 times)

0 Members and 1 Guest are viewing this topic.

Offline tyguy2Topic starter

  • Supporter
  • ****
  • Posts: 303
  • Country: us
Strange behaviors with microcontroller digital inputs
« on: September 22, 2019, 04:10:38 am »
Hello all,

I've embedded a SAMD21G (Basis for the Arduino Zero) into a PCB I've been designing. I've been using pins PA19 and PA18 (Arduino pins 12 and 10 respectively) to act as inputs for 2 different signals entering the device. The first is connected to a reed switch with an external 4.7k ohm pull up resistor with the reed switch connected to ground. The second is connected to a LDO's output to detect if a device external to the PCB has been powered on (schematics attached). This is attached to a 4.7k ohm pull down resistor. The issue I'm having is that after a few hours of operation, the micro begins to not accurately detect if these sources are high or low. Checking with a multimeter, I've noticed the voltages at the inputs are 1.53-ish volts for the reed switch and 1.23-ish volts for the LDO, rather than the standard 0v or 3.3v. Does anyone know what could be causing this and how I'd fix it?

Thanks
[Sarcastic comment] clever joke [/sarcastic comment]
Bitcoin:
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
 

Offline Kasper

  • Frequent Contributor
  • **
  • Posts: 742
  • Country: ca
Re: Strange behaviors with microcontroller digital inputs
« Reply #1 on: September 22, 2019, 05:31:28 am »
Is your 3.3V source still at 3.3V when the problem occurs?
 

Offline tyguy2Topic starter

  • Supporter
  • ****
  • Posts: 303
  • Country: us
Re: Strange behaviors with microcontroller digital inputs
« Reply #2 on: September 22, 2019, 05:40:37 am »
Yes, it remains at 3.3v
[Sarcastic comment] clever joke [/sarcastic comment]
Bitcoin:
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
 

Offline EEEnthusiast

  • Frequent Contributor
  • **
  • Posts: 375
  • Country: in
  • RF boards, Precision Analog, Carpentry
    • https://www.zscircuits.in/
Re: Strange behaviors with microcontroller digital inputs
« Reply #3 on: September 22, 2019, 06:10:38 am »
The LDO output going to 1.23 is surprising and it looks like the reference voltage of the LDO. Is there something which gets heated on the board? Also check the VIO supply of the microcontroller. Check if it is floating or some soldering issue. This is mostly coming from a power issue.
Making products for IOT
https://www.zscircuits.in/
 

Offline Twoflower

  • Frequent Contributor
  • **
  • Posts: 737
  • Country: de
Re: Strange behaviors with microcontroller digital inputs
« Reply #4 on: September 22, 2019, 09:03:19 am »
Can you read back the IO-config of the controller of the pins in question? Just in case you're actually chasing a SW issue that by accident re-configures your input pin. But from the datasheet the pull-down would be too weak (about 40k) for the voltage you see.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9938
  • Country: nz
Re: Strange behaviors with microcontroller digital inputs
« Reply #5 on: September 22, 2019, 10:38:29 am »
The issue I'm having is that after a few hours of operation, the micro begins to not accurately detect if these sources are high or low.

Wild stab in the dark, check if this is happening at exactly the same time after power on (down to the second or near abouts).

If so i would suspect something related to the tick counter/timer overflowing and causing weirdness to occur.
Especially if you are using the tick count for things and comparing with previous tick counts (or some arduino library is)

etc.. If the previous tick count is 65520 but suddenly the current tick count is now zero some code may never be called.
(Unless you have specifically added code to handle this situation )

Yes i know this doesn't explain the 1.53V but checking if the bug is happening at exactly the same time is still useful to know.
« Last Edit: September 22, 2019, 10:45:48 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Strange behaviors with microcontroller digital inputs
« Reply #6 on: September 22, 2019, 10:41:06 am »
I not even sure how the detect circuit works to begin with.
The micro gpio is only able to detect voltage.
The LDO is a voltage regulator.
So, the circuit should only detect if the LDO is on or not.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6253
  • Country: fi
    • My home page and email address
Re: Strange behaviors with microcontroller digital inputs
« Reply #7 on: September 22, 2019, 12:50:12 pm »
Are you absolutely sure the two resistors are 4.7kΩ and not say 470Ω?  Measure them, to be sure.
 

Offline Kasper

  • Frequent Contributor
  • **
  • Posts: 742
  • Country: ca
Re: Strange behaviors with microcontroller digital inputs
« Reply #8 on: September 23, 2019, 05:52:46 am »
When your DMM says 1.5V, it could mean it is quickly switching between 0 and 3V.  If you have access to an oscilloscope that could be helpful to see if it is actually 1.5V or something else is happening. For example your MCU could be setting pin to output low and then changing it to input and repeating.  If you dont have a scope, test it with the simpliest code you can just to be more confident it is doing what you expect.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3238
  • Country: gb
Re: Strange behaviors with microcontroller digital inputs
« Reply #9 on: September 23, 2019, 12:01:54 pm »
When your DMM says 1.5V, it could mean it is quickly switching between 0 and 3V.  If you have access to an oscilloscope that could be helpful to see if it is actually 1.5V or something else is happening. For example your MCU could be setting pin to output low and then changing it to input and repeating.  If you dont have a scope, test it with the simpliest code you can just to be more confident it is doing what you expect.

Quite possibly the LDO oscillating due to too too low a capacitance or too high an ESR on the output cap.  This is the opposite of most conventional LDO's and caught me out on a different part when the MLCC capacitance dropped below the minimum required due to voltage derating.
 

Offline Kasper

  • Frequent Contributor
  • **
  • Posts: 742
  • Country: ca
Re: Strange behaviors with microcontroller digital inputs
« Reply #10 on: September 23, 2019, 02:41:47 pm »
When your DMM says 1.5V, it could mean it is quickly switching between 0 and 3V.  If you have access to an oscilloscope that could be helpful to see if it is actually 1.5V or something else is happening. For example your MCU could be setting pin to output low and then changing it to input and repeating.  If you dont have a scope, test it with the simpliest code you can just to be more confident it is doing what you expect.

Quite possibly the LDO oscillating due to too too low a capacitance or too high an ESR on the output cap.  This is the opposite of most conventional LDO's and caught me out on a different part when the MLCC capacitance dropped below the minimum required due to voltage derating.

That does seem like a possibility but the op says the supply is 3.3V when the problem is occuring so assuming that is true, I think it is something else.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6253
  • Country: fi
    • My home page and email address
Re: Strange behaviors with microcontroller digital inputs
« Reply #11 on: September 23, 2019, 02:49:40 pm »
The reason I suggested that maybe the resistors were much smaller than believed, is that having higher current (7 mA if 470 Ω, 70 mA if 47 Ω) should work fine for a while, but later on, generate "odd" effects due to point heat on the microcontroller chip, especially if internal pull-ups/downs were also enabled.
 

Offline tyguy2Topic starter

  • Supporter
  • ****
  • Posts: 303
  • Country: us
Re: Strange behaviors with microcontroller digital inputs
« Reply #12 on: September 23, 2019, 06:27:04 pm »
When your DMM says 1.5V, it could mean it is quickly switching between 0 and 3V.  If you have access to an oscilloscope that could be helpful to see if it is actually 1.5V or something else is happening. For example your MCU could be setting pin to output low and then changing it to input and repeating.  If you dont have a scope, test it with the simpliest code you can just to be more confident it is doing what you expect.

Apologies for the late reply! I checked with an true RMS multimeter in AC mode, got 3.3v, so something internal to the micro is causing this. It happens on both pins, so I can assume it's not something external to the circuitry, so I'm move inclined to believe there's an error in my code. That raises an entire other bag of worms though. I'm just using Arduino to program this, and I'm just calling digitalRead on pins that have been set to pinMode(INPUT). Any ideas? I am utilizing the DAC built into the chip, but I feel like that wouldn't effect the digital I/O?
« Last Edit: September 24, 2019, 05:25:30 am by tyguy2 »
[Sarcastic comment] clever joke [/sarcastic comment]
Bitcoin:
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
 

Offline Kasper

  • Frequent Contributor
  • **
  • Posts: 742
  • Country: ca
Re: Strange behaviors with microcontroller digital inputs
« Reply #13 on: September 23, 2019, 07:55:23 pm »
Good idea using AC measurement to check this.  So now it seems pretty clear something is pulling those lines down repetitively.

If you want to be even more sure the MCU is the problem, take the MCU out of the circuit, replace it with resistors similar to what you expect the MCU to have internally and see what happens.

To test the MCU:
Make new code for troubleshooting.

Do nothing except set your inputs as needed and if you can, use serial monitor to increment a variable every second or so.

My guess is something happens after a while that causes your MCU to start rebooting constantly and the pin states change during the reboot.  Displaying a count through serial monitor will tell you if it has rebooted or not. Note that your counter variable will eventually overflow, possibly making it look like a reboot but if it only happens at a power of 2 then that should be obvious it was just an overflow.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3238
  • Country: gb
Re: Strange behaviors with microcontroller digital inputs
« Reply #14 on: September 23, 2019, 07:58:37 pm »
When your DMM says 1.5V, it could mean it is quickly switching between 0 and 3V.  If you have access to an oscilloscope that could be helpful to see if it is actually 1.5V or something else is happening. For example your MCU could be setting pin to output low and then changing it to input and repeating.  If you dont have a scope, test it with the simpliest code you can just to be more confident it is doing what you expect.

Quite possibly the LDO oscillating due to too too low a capacitance or too high an ESR on the output cap.  This is the opposite of most conventional LDO's and caught me out on a different part when the MLCC capacitance dropped below the minimum required due to voltage derating.

That does seem like a possibility but the op says the supply is 3.3V when the problem is occuring so assuming that is true, I think it is something else.

The schematic shows a direct connection between the micro's GPIO pin and the output of the LDO, with no series resistors.  If the voltage on the micro pin is 1.23v but the voltage at the LDO is 3.3, then there must be a bad connection between them.
 

Offline tyguy2Topic starter

  • Supporter
  • ****
  • Posts: 303
  • Country: us
Re: Strange behaviors with microcontroller digital inputs
« Reply #15 on: September 23, 2019, 11:38:44 pm »
My guess is something happens after a while that causes your MCU to start rebooting constantly and the pin states change during the reboot.  Displaying a count through serial monitor will tell you if it has rebooted or not. Note that your counter variable will eventually overflow, possibly making it look like a reboot but if it only happens at a power of 2 then that should be obvious it was just an overflow.

My code currently has variables that exist only in RAM, and I'm guessing constant resets would wipe those from memory and reset them to their initial values, but I'm observing nothing like that.

The schematic shows a direct connection between the micro's GPIO pin and the output of the LDO, with no series resistors.  If the voltage on the micro pin is 1.23v but the voltage at the LDO is 3.3, then there must be a bad connection between them.


If that were true, then we wouldn't see the same effect on the reed switch. Additionally, as I said in the previous post, I'm getting 3.3v AC RMS on the inputs, which means something is definitely wrong with the micro, not the voltages going into the micro.
[Sarcastic comment] clever joke [/sarcastic comment]
Bitcoin:
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3238
  • Country: gb
Re: Strange behaviors with microcontroller digital inputs
« Reply #16 on: September 24, 2019, 01:11:21 pm »
The schematic shows a direct connection between the micro's GPIO pin and the output of the LDO, with no series resistors.  If the voltage on the micro pin is 1.23v but the voltage at the LDO is 3.3, then there must be a bad connection between them.


If that were true, then we wouldn't see the same effect on the reed switch. Additionally, as I said in the previous post, I'm getting 3.3v AC RMS on the inputs, which means something is definitely wrong with the micro, not the voltages going into the micro.


Sorry, I must be missing something here.  Just to confirm, you are measuring 3.3v AC RMS on the micro GPIO pins, including the one directly connected to the output of an LDO where you are getting 3.3v DC?  Are you using the same ground reference when measuring the micro GPIO pins and the LDO output?
« Last Edit: September 24, 2019, 01:13:56 pm by mikerj »
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6253
  • Country: fi
    • My home page and email address
Re: Strange behaviors with microcontroller digital inputs
« Reply #17 on: September 24, 2019, 02:39:41 pm »
I'd wager a beer that the problem is that internal pull-ups or pull-downs are enabled for those pins, and the resistors resistance is smaller than intended.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf