## Re: [Gumstix-users] GPIO in/out usage

 Re: [Gumstix-users] GPIO in/out usage From: Dave Hylands - 2005-12-23 05:56:26 ```Hi Chris, On 12/22/05, Chris Dollar wrote: > The led is digikey pn 350-1526-ND. It is made by dialight (their pn > 558-6003-007). Here is the link to the digikey catalog page with the spe= cs: > http://dkc3.digikey.com/PDF/T053/1652.pdf > > Is there a formula to calculate resistor size values for switch and led > applications like this? The normal way of figuring out the current limiting resistor for an LED uses ohms law: V =3D I R R =3D V / I V is the voltage drop across the resistor and I is the current running through the resistor. Normally, you would use V =3D Vcc - Vf where Vf is the forward voltage drop across the LED. The current through the LED will be the same as the current through the resistor. So, if Vcc =3D 5v, Vf =3D 3.5v, and I =3D 20 mA, we get R =3D V/I =3D (5 - 3.5)/0.02 =3D 1.5/0.02 =3D 75 ohms. In your particular example, Vf is greater than Vcc, so it's conceivable that the LED wouldn't light up at all. For the pullup for the switch, the resistor value chosen will depend on the underlying technology being used. 10k is a common value for TTL with 5v Vcc. With CMOS, 100k is perfectly fine. I normally use 10k unless I'm thinking about low power. The lower the value you pick, the more current will run through the pullup when the low side of the resistor is at logic low. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ ```

 [Gumstix-users] GPIO in/out usage From: Chris Dollar - 2005-12-22 15:23:49 Attachments: Message as HTML ```I recently bought a breakout-gs board to do some simple hardware interfacin= g with. I've never done anything hardware related so I figured I'd start out by wiring a simple switch and led to the GPIO lines. So far everything has worked great but I'm not sure that I am really going at this the right way. I ran a wire from GPIO 59 (lcd pads) and another from a ground pad. In between I added a momentary NO pushbutton switch. If I set the GPIO to output and set I could see when I pressed the button that the setting went to clear. So that was fine, but it didn't really make sense to me to drive the GPIO as output when a button press seemed more like an input?? Then I played around with the sample char driver in the wiki and some other interrupt driver code I found in the mailing list. In both of those it appears that the GPIOs are set as inputs so I thought I would give that a try. Using either of those drivers I saw the interrupt being triggered all the time unless I pressed my switch, then it stopped. I was able to edit that code and get it to work with the GPIO set as output and then the interrupt was triggered when I pressed the button. Am I missing something here? Is setting the GPIO as output to trigger interrups like I am doing th= e wrong way to do this? That brings me to my led. I got it from digikey because it said it was 3.4vand I knew the GPIOs could output 3.3v. It is rated at 20 milli amps. If I hook this up to a GPIO and groun= d and drive the GPIO on output set I see the led come on, and when I clear th= e line it goes out. Great! Seems like it works to me, but I just wanted to make sure I wasn't doing something that was bad form. Guess you can tell I'm really new at this. The mailing list and wiki have been a great resource in getting to where I am now, so thanks to all of you gumstix folks out there! Thanks for the help. Chris ```
 Re: [Gumstix-users] GPIO in/out usage From: Alexandre Pereira Nunes - 2005-12-22 15:56:41 ```Chris Dollar escreveu: > I recently bought a breakout-gs board to do some simple hardware > interfacing with. I've never done anything hardware related so I > figured I'd start out by wiring a simple switch and led to the GPIO > lines. So far everything has worked great but I'm not sure that I am > really going at this the right way. > > I ran a wire from GPIO 59 (lcd pads) and another from a ground pad. > In between I added a momentary NO pushbutton switch. If I set the > GPIO to output and set I could see when I pressed the button that the > setting went to clear. So that was fine, but it didn't really make > sense to me to drive the GPIO as output when a button press seemed > more like an input?? Then I played around with the sample char driver > in the wiki and some other interrupt driver code I found in the > mailing list. In both of those it appears that the GPIOs are set as > inputs so I thought I would give that a try. Using either of those > drivers I saw the interrupt being triggered all the time unless I > pressed my switch, then it stopped. I was able to edit that code and > get it to work with the GPIO set as output and then the interrupt was > triggered when I pressed the button. Am I missing something here? Is > setting the GPIO as output to trigger interrups like I am doing the > wrong way to do this? It should be configured as input, I don't know what's wrong but something is missing here. > > That brings me to my led. I got it from digikey because it said it > was 3.4v and I knew the GPIOs could output 3.3v. It is rated at 20 > milli amps. If I hook this up to a GPIO and ground and drive the GPIO > on output set I see the led come on, and when I clear the line it goes > out. Great! Seems like it works to me, but I just wanted to make > sure I wasn't doing something that was bad form. AFAIK, even though the led junction tension is supposed to be at 3.4v (it varies a bit from piece to piece and with ageing), it certainly emmits some light with a lower tension (specially because a 3.4v junction is probably a very bright one), however, good practics recommends you still put a series resistor, so that it determines the current instead of leave it up to the led's junction, otherwise you risk flowing too much current from the pxa, which may or may not burn it or the led to death. > > Guess you can tell I'm really new at this. The mailing list and wiki > have been a great resource in getting to where I am now, so thanks to > all of you gumstix folks out there! > When it comes to hardware I'm kind of new myself, and so are some folks around here, but there are some experienced guys who can answer your questions deeply than me. I'm sure they will :-) Cheers, Alexandre ```
 Re: [Gumstix-users] GPIO in/out usage From: Dave Hylands - 2005-12-22 18:30:58 ```Hi Chris, > I ran a wire from GPIO 59 (lcd pads) and another from a ground pad. In > between I added a momentary NO pushbutton switch. If I set the GPIO to > output and set I could see when I pressed the button that the setting wen= t > to clear. So that was fine, but it didn't really make sense to me to dri= ve > the GPIO as output when a button press seemed more like an input?? Then = I > played around with the sample char driver in the wiki and some other > interrupt driver code I found in the mailing list. In both of those it > appears that the GPIOs are set as inputs so I thought I would give that a > try. Using either of those drivers I saw the interrupt being triggered a= ll > the time unless I pressed my switch, then it stopped. I was able to edit > that code and get it to work with the GPIO set as output and then the > interrupt was triggered when I pressed the button. Am I missing somethin= g > here? Is setting the GPIO as output to trigger interrups like I am doing = the > wrong way to do this? For inputs, you need something to drive the input all the time. The interrupt in the sample driver is set to detect edges. When you press the button you're setting the pin to ground (or logic low). When you release the button, the input is now not connected to anything. CMOS technology is very sensitive and a floating input will tend to follow nearby signals (due to capacative coupling). So what's probably happening is that the input line is following some other line which is transitioning and thus creating edges. The normal way to connect a switch is to have a pullup resistor go from the input to your positive voltage (Vcc), and have the pushbutton go from the input to ground. Any resistor value between 10k and 100k should be fine for a pullup in this scenario (higher values draw less current). Then when the button is not pressed, the pullup will pull the input upto Vcc (logic 1), and when you press the switch it will overcome the pullup (almost zero ohms in the switch) and you'll get a logic low. As a general rule, you don't want to connect a switch up to an ouput. It's possible to damage things. If the output is driven high by the processor and your switch connects the output to ground, then you're effectively shorting Vcc and ground. The effect will depend on the amount of resistance in the circuit. > That brings me to my led. I got it from digikey because it said it was > 3.4v and I knew the GPIOs could output 3.3v. It is rated at 20 milli amp= s. > If I hook this up to a GPIO and ground and drive the GPIO on output set I > see the led come on, and when I clear the line it goes out. Great! Seem= s > like it works to me, but I just wanted to make sure I wasn't doing someth= ing > that was bad form. As a general rule, you should insert a current limiting resistor. Is the LED you got a white or blue LED? They often have larger voltage drops. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ ```
 Re: [Gumstix-users] GPIO in/out usage From: Chris Dollar - 2005-12-22 20:23:27 Attachments: Message as HTML ```Hi Dave, Thanks for the detailed info. I had seen references to a pullup resistor while I was investigating the whole thing, but I didn't understand its purpose. > The normal way to connect a switch is to have a pullup resistor go > > from the input to your positive voltage (Vcc), and have the pushbutton > > go from the input to ground. So if I understand correctly I have 2 lines (wires) coming off of GPIO 59. One of those wires goes to my switch, which then goes to ground. The other goes from the GPIO to the resistor and from the resistor to Vcc. |-------resistor--------Vcc | GPIO--------|--------switch------GRND Since I am using the breakout-gs new version with Vcc as battery voltage (which I guess is 5v with the wall wart) is there anything different that I would need to do to step that voltage down to 3.3v or does the resistor do all that? > As a general rule, you should insert a current limiting resistor. Is > > the LED you got a white or blue LED? They often have larger voltage > > drops. The led I am using is blue. I don't have the part number with me now but I can get its specs if that would be helpful. Thanks for the help! Chris On 12/22/05, Dave Hylands wrote: > > Hi Chris, > > > I ran a wire from GPIO 59 (lcd pads) and another from a ground pad. I= n > > between I added a momentary NO pushbutton switch. If I set the GPIO to > > output and set I could see when I pressed the button that the setting > went > > to clear. So that was fine, but it didn't really make sense to me to > drive > > the GPIO as output when a button press seemed more like an input?? The= n > I > > played around with the sample char driver in the wiki and some other > > interrupt driver code I found in the mailing list. In both of those it > > appears that the GPIOs are set as inputs so I thought I would give that > a > > try. Using either of those drivers I saw the interrupt being triggered > all > > the time unless I pressed my switch, then it stopped. I was able to > edit > > that code and get it to work with the GPIO set as output and then the > > interrupt was triggered when I pressed the button. Am I missing > something > > here? Is setting the GPIO as output to trigger interrups like I am doin= g > the > > wrong way to do this? > > For inputs, you need something to drive the input all the time. The > interrupt in the sample driver is set to detect edges. When you press > the button you're setting the pin to ground (or logic low). When you > release the button, the input is now not connected to anything. CMOS > technology is very sensitive and a floating input will tend to follow > nearby signals (due to capacative coupling). So what's probably > happening is that the input line is following some other line which is > transitioning and thus creating edges. > > The normal way to connect a switch is to have a pullup resistor go > from the input to your positive voltage (Vcc), and have the pushbutton > go from the input to ground. Any resistor value between 10k and 100k > should be fine for a pullup in this scenario (higher values draw less > current). > > Then when the button is not pressed, the pullup will pull the input > upto Vcc (logic 1), and when you press the switch it will overcome the > pullup (almost zero ohms in the switch) and you'll get a logic low. > > As a general rule, you don't want to connect a switch up to an ouput. > It's possible to damage things. If the output is driven high by the > processor and your switch connects the output to ground, then you're > effectively shorting Vcc and ground. The effect will depend on the > amount of resistance in the circuit. > > > That brings me to my led. I got it from digikey because it said it wa= s > > 3.4v and I knew the GPIOs could output 3.3v. It is rated at 20 milli > amps. > > If I hook this up to a GPIO and ground and drive the GPIO on output set > I > > see the led come on, and when I clear the line it goes > out. Great! Seems > > like it works to me, but I just wanted to make sure I wasn't doing > something > > that was bad form. > > As a general rule, you should insert a current limiting resistor. Is > the LED you got a white or blue LED? They often have larger voltage > drops. > > -- > Dave Hylands > Vancouver, BC, Canada > http://www.DaveHylands.com/ > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id=16865&opclick > _______________________________________________ > gumstix-users mailing list > gumstix-users@... > https://lists.sourceforge.net/lists/listinfo/gumstix-users > ```
 Re: [Gumstix-users] GPIO in/out usage From: Dave Hylands - 2005-12-22 21:38:28 ```Hi Chris, > So if I understand correctly I have 2 lines (wires) coming off of GPIO 5= 9. > One of those wires goes to my switch, which then goes to ground. The oth= er > goes from the GPIO to the resistor and from the resistor to Vcc. > > |-------resistor--------Vcc > | > GPIO--------|--------switch------GRND Yep - that's exactly correct. Although, I would probably conenct the two wires together at the switch rather than at the breakout board, just because there's more room to play with :) > Since I am using the breakout-gs new version with Vcc as battery voltage > (which I guess is 5v with the wall wart) is there anything different that= I > would need to do to step that voltage down to 3.3v or does the resistor d= o > all that? I think it's the older breakout's that suffer from this. The newer ones should be OK. You can check by measuring Vcc. Using a larger resistor value, rather than a smaller one would be appropriate then, although 10k is probably still fine. I use 10k inline resistors to connect 5v to 3.3v, and for many devices this is fine. If you're paranoid, connect two resistors together. Connect R1 from Vcc to the R2. Connect the other side of R2 to GND. Make R2 be double the value of R1, and the junction between them will be at 3.3v (if Vcc is at 5v). Connect your pullup to that. I'd make R1 be at least 10k. > The led I am using is blue. I don't have the part number with me now bu= t I > can get its specs if that would be helpful. Yes - that would be useful. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ ```
 Re: [Gumstix-users] GPIO in/out usage From: Chris Dollar - 2005-12-23 02:31:38 Attachments: Message as HTML ```The led is digikey pn 350-1526-ND. It is made by dialight (their pn 558-6003-007). Here is the link to the digikey catalog page with the specs= : http://dkc3.digikey.com/PDF/T053/1652.pdf Is there a formula to calculate resistor size values for switch and led applications like this? Thanks again! Chris On 12/22/05, Dave Hylands wrote: > > Hi Chris, > > > So if I understand correctly I have 2 lines (wires) coming off of GPIO > 59. > > One of those wires goes to my switch, which then goes to ground. The > other > > goes from the GPIO to the resistor and from the resistor to Vcc. > > > > |-------resistor--------Vcc > > | > > GPIO--------|--------switch------GRND > > Yep - that's exactly correct. Although, I would probably conenct the > two wires together at the switch rather than at the breakout board, > just because there's more room to play with :) > > > Since I am using the breakout-gs new version with Vcc as battery > voltage > > (which I guess is 5v with the wall wart) is there anything different > that I > > would need to do to step that voltage down to 3.3v or does the resistor > do > > all that? > > I think it's the older breakout's that suffer from this. The newer > ones should be OK. You can check by measuring Vcc. > > Using a larger resistor value, rather than a smaller one would be > appropriate then, although 10k is probably still fine. I use 10k > inline resistors to connect 5v to 3.3v, and for many devices this is > fine. > > If you're paranoid, connect two resistors together. Connect R1 from > Vcc to the R2. Connect the other side of R2 to GND. Make R2 be double > the value of R1, and the junction between them will be at 3.3v (if Vcc > is at 5v). Connect your pullup to that. I'd make R1 be at least 10k. > > > The led I am using is blue. I don't have the part number with me now > but I > > can get its specs if that would be helpful. > > Yes - that would be useful. > > -- > Dave Hylands > Vancouver, BC, Canada > http://www.DaveHylands.com/ > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id=16865&opclick > _______________________________________________ > gumstix-users mailing list > gumstix-users@... > https://lists.sourceforge.net/lists/listinfo/gumstix-users > ```
 Re: [Gumstix-users] GPIO in/out usage From: Dave Hylands - 2005-12-23 05:56:26 ```Hi Chris, On 12/22/05, Chris Dollar wrote: > The led is digikey pn 350-1526-ND. It is made by dialight (their pn > 558-6003-007). Here is the link to the digikey catalog page with the spe= cs: > http://dkc3.digikey.com/PDF/T053/1652.pdf > > Is there a formula to calculate resistor size values for switch and led > applications like this? The normal way of figuring out the current limiting resistor for an LED uses ohms law: V =3D I R R =3D V / I V is the voltage drop across the resistor and I is the current running through the resistor. Normally, you would use V =3D Vcc - Vf where Vf is the forward voltage drop across the LED. The current through the LED will be the same as the current through the resistor. So, if Vcc =3D 5v, Vf =3D 3.5v, and I =3D 20 mA, we get R =3D V/I =3D (5 - 3.5)/0.02 =3D 1.5/0.02 =3D 75 ohms. In your particular example, Vf is greater than Vcc, so it's conceivable that the LED wouldn't light up at all. For the pullup for the switch, the resistor value chosen will depend on the underlying technology being used. 10k is a common value for TTL with 5v Vcc. With CMOS, 100k is perfectly fine. I normally use 10k unless I'm thinking about low power. The lower the value you pick, the more current will run through the pullup when the low side of the resistor is at logic low. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ ```

No, thanks