OK…I have a strange situation here. I have the Parallax PIR from Radio Shack and hooked it up thru a bread board to IO9 on my Cobra…works great (used the code out on Fezzer). So, I decide to actually solder it to a board and use one of the 3 pin connectors. Here is where it gets strange. If I try to plug it into any of the on board 3 pin connectors already mounted on the Cobra (like IO7), it doesnt work. The pin goes high and just keeps calling my interrupt. But, if I take that same 3 pin connector and put it back on IO9, it works just great. Another slightly strange thing…if I just plug the cable (without the PIR attached) into one of those on board connectors, it immediately starts going high again. In fact, it went high a few times with me just getting my hand NEAR the thing (static electricity maybe? Who knows). So, what is the difference there between a pin like IO9 and IO7 on the Cobra that would cause this?
The code is on Fezzer but here is the basic code setting up the interrupt:
interruptPort = new InterruptPort(pin,false,Port.ResistorMode.Disabled,Port.InterruptMode.InterruptEdgeHigh);
Thanks ahead of time…Steve
Just to be sure, double check that 3 pin connector connects to right pins on the PIR.
Architect - Checked that. If I plug the same pins into 5V out (or 3.3V out), Ground, and IO9, works great. I’ve looked at the schematics till I am blue in the face ana am sure the pins are correct. The funniest (weirdest) part is that it just goes high by itself with only the cable attached and not even the PIR…strange.
Is the cable ok?
Try adding pull- down resistor and see if it helps.
Tried a few different cables. I put a 1K resistor in line between the pin on PIR and the pin on the board…is that what you are referring to?
I mean connecting IO7 with 1K resistor to the ground. That way the active state is low on that pin - guaranteed.
Hm…ok, but I’m confused…(here goes Steve COMPLETE lack of electrical knowledge), but if it is already grounded, then how does it ever get set? Sorry, thanks for the help.
Here is information on pull-down and pull-up resistors from “Expert .NET Micro Framework” by Jens Kühner:
OK, so, if you can indulge my lack of understanding here, here is a very poor electrical diagram of how I currently have this set up. And, this works. Where on here would I put a resistor for something like IO7? Thanks again so much.
Here it is. That way you will guarantee that pin is not floating.
Fantastic…THANK YOU SO MUCH I will try that this evening…REALLY appreciate your help.
Well…sad to say…did what you showed…tried every possible code settings I could, Port.ResistorMode.PullDown, Port.ResistorMode.PullUp, even set the interupt mode to Port.InterruptMode.InterruptEdgeBoth and could not get a reading. Instead of the problem I had before, now it won’t trigger at all…any more ideas? I kow I hve a lot o learn, but this can certainly get a little frustrating after a while
OK…think I have it working…went back and re-did everything…looks like I must have not had the resistor soldered correctly or something? all is well now…learned a lot wiht something I thought would be so simple…thanks again.
I am glad it worked for you.