Community
cancel
Showing results for 
Search instead for 
Did you mean: 
JWend2
Novice
1,756 Views

Having trouble reading digital input using Sparkfun GPIO breakout board

I'm very new to this (I've messed around with Arduinos a little bit) and I just started using my Edison and I am currently trying to get it working with an infrared sensor (TSOP38238), after struggling for quite a while I realized my problem was simply with any kind of digital input. As mentioned in the title I'm using the Sparkfun GPIO breakout board (https://www.sparkfun.com/products/13038 SparkFun Block for Intel® Edison - GPIO - DEV-13038 - SparkFun Electronics), so all IO is level shifted to 3.3V. I decided to really simplify things, I had the 3.3 VCC connected to a 10k Ohm resistor and a jumper I could remove connecting it to ground, and a line between the resistor and the jumper going to GP44 on the GPIO board (See image below). In theory when the jumper is removed the pin should read high, and when the jumper is added it should read low. I created a very simple C++ program to just set the pin as input and read it 4 times per second, printing the response. What I saw happening was that when I started the program with no jumper it was reading high, and as soon as I added the jumper it would drop low. However, once I took the jumper out it would stay low for about 5 seconds before going high again. When I hooked up my multimeter I could see as soon as I took the jumper out the voltage was only around 1.2V for that 5 seconds (hence reading low) and would then go back to the 3.3. It is acting like there is a very large capacitor it is charging. And sure enough, when I replaced the 10k Ohm resistor with a 330 Ohm resistor it now registers the change almost instantly (faster than I can notice at least). Worrying that it was something in my code I connected to my device using the serial port, insured that GP44 was in input mode and read the values from "/sys/kernel/debug/gpio_debug/gpio44/current_value" and I was still seeing the same behavior. Is 0.33 mA not enough current to drive the input of this board? Again I'm very new to this so I don't fully understand how the internal pull up resistor may be effecting this, the pullmode is currently the default "pullup" and pullstrength is the default "50k", is this something I should change? The final application I plan on making will be battery powered so I would like to minimize power consumption where possible.

 

And for those curious my C++ code is simply:

# include "mraa.hpp"

int main() {

mraa_gpio_context pin31 = mraa_gpio_init(31);

mraa_gpio_dir(pin31, MRAA_GPIO_IN);

int in;

for (;;) {

in=mraa_gpio_read(pin31);

printf("switch %d \n",in);

usleep(250000);

}

return mraa::SUCCESS;

}

9 Replies
idata
Community Manager
54 Views

Hi VaultDweller,

 

 

Have you tried to apply a different VCC? I'm wondering if this is due to a lack of current when powering the block, so when it's time to go up 3.3V it struggles to get there, and maybe that's why it's taking 5 seconds. I would suggest you to give it a try, just to discard or confirm this scenario.

 

 

Regards,

 

Pablo
JWend2
Novice
54 Views

Pablo,

Well the Sparkfun GPIO board is level shifted and only has the one 3.3 VCC pin, so if I use the 1.8 VCC I'll never read anything as high. Unless I'm just completely misunderstanding what you are saying, most of this is very new to me.

I did get it working with a 1k resistor for R1, I just don't understand why a 10k resistor causes this 5 second lag. I do suspect it is something to do with the Sparkfun GPIO board and the voltage shift to 3.3 though. At the end of the day it is working so I guess I shouldn't complain too much. Maybe I'll create a post over on Sparkfun and see if anyone there can point out to me why this might be happening.

idata
Community Manager
54 Views

Hi VaultDweller,

 

 

I meant to apply 3.3V but from an external power supply, instead of the 3.3V provided by the Sparkfun block, that way we would confirm if this is a current issue. And yes, it would be a good idea to contact Sparkfun, if you do please let us know their response.

 

 

Regards,

 

Pablo
idata
Community Manager
54 Views

Hi,

 

 

Do you have updates on this? Did you get any other information from the Sparkfun support team?

 

 

Regards,

 

Pablo
JWend2
Novice
54 Views

I did make a post over on the Sparkfun forum, but no one has yet to reply. I'll be sure to update this thread if I do find any answers.

My post over there: https://forum.sparkfun.com/viewtopic.php?f=14&t=43822&sid=3e2f2e8397fb22f7d5b616172ea95e2d https://forum.sparkfun.com/viewtopic.php?f=14&t=43822&sid=3e2f2e8397fb22f7d5b616172ea95e2d

idata
Community Manager
54 Views

Hi,

 

 

Thank you for the update, please let us know their response as it may help some other users.

 

 

Regards,

 

Pablo
idata
Community Manager
54 Views

Hi,

 

 

Were you contacted by Sparkfun? Did they provide some input on related to their board?

 

 

Regards,

 

Pablo
JWend2
Novice
54 Views

There were no replies to my post on their forum, so I reached out directly to Sparkfun, they couldn't think of anything that would be causing this issue, so they are sending me a new GPIO board to see if it was perhaps just a defect with the board itself. I will let you know once the new board gets in and I test it out.

Side note, the person I talked to at Sparkfun was very helpful and was the one who suggested sending me a new board at no cost. Great customer service.

idata
Community Manager
54 Views

Hi,

 

 

That's great news! Please let us know your results with the new GPIO board. We are really happy to hear that you got some top quality service from them.

 

 

Regards,

 

Pablo
Reply