Can you tell us a little about your project? At this point I would just be guessing more than usual.I need internal wpu because for my project i need to enable and disable them on the fly in software. Is there another easy alternative?![]()
Dave
Always wear safety glasses while programming.
Sure, it is a lasergame system. the mag module performs a handshaking with the gun module. i.e. gun asks the mag if there are still ammo in the mag. if there are, the gun receives a signal and the ammo is used.
there are 2 pics 16f684 communicating. the mag ra5 is set as input and used at default low state (porta.5=0, wpu disabled).
when the gun sends a +5v to mag's ra5 for 1ms, mag then sets ra5 as output and it sends +5v out via ra5 to the gun as a reply then ra5 is set again as input at logic low. this ra5 pin is used as input/output for handshaking. TRISA is used to chang pin direction as needed.
so my trouble is, if i use an external 10k weak pulldown to avoid leaving it floating (and triggering a fake int on ra5 if there is some noise) i won't be able to disable the pull down in software when i'll be using the pin as output. do you see?
Last edited by xnihilo; - 1st April 2008 at 15:56.
There should be no problem with using a 10k pull-down resistor. So the gun pin (the one that's connected to RA5 of the mag) goes to an input immediately after sending a 1ms high signal? This pull-down resistor would therefore stop the gun input pin floating as well.
Please correct me if I've mis-interpreted you
Cheers
Rob
I agree with Rob.
You can have an external pull up or down and still do what you want.
Think of it like this.
If you had a switch connected to a pin (input) that is set to receive a high signal when the switch is closed you would have a pull down resistor to hold the pin low so not to give a false reading.
If you had a mosfet or relay connected to a pin (output) that is set to go high to activate the mosfet or relay you would have a pull down resistor to hold the pin low so not to have the mosfet or relay coming on when is is not supposed to.
The thing I will suggest in your case is a 100K pull down might be better. It should increase the sensitivity.
Dave
Always wear safety glasses while programming.
Problem when switching internal-pull up could be some false interrupts events. Your software MUST compensate for it. But i see no advantage to do so.... too bad... i can't take beer 'till few months ... in some occasion, it's an eye opener![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
In fact RA5 of the PIC used in the gun is connected to RA5 of the pic used in the mag.
Pins used for this handhasking, both in the gun and in the mag are used both as input and output in a specific sequence.
GUN (with weak PD) MAG (with 10K external weak pull down)
RA5 RA5
OUTPUT, LOW INPUT, LOW
Set high for 1ms Portachange interrupt is triggered, goto int handler
1ms delay RA5 becomes an output pin
RA5 becomes input RA5 starts outputing 5V ONLY if an ammo is available in the mag
start polling RA5 2ms delay
RA5 reverts to output RA5 reverts to input
Here the gun either received a 5V pulse on RA5 (got an ammo from the mag) or no pulse was received, which means mag is empty
The respective programs continue...
That's how I implemented my handshaking between the pics. I would have used separate pins one for input, one for output for each pic but I don't have enough free pins, anyway, such usage of the pic should be okay anyway
What will happen when the 5V output is sent. As there is a 10K weak pullup connecting the pin to the ground... I guess some current will sink to the ground but most of it will reach the target pic, right?
Bookmarks