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