Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Two sensors, one interrupt pin!!!

Status
Not open for further replies.

2camjohn

Member
I have two sensors, which are essentially 'no' switches, wired with a pull up resistor.

I want to hook these up to the interrupt pin of my chip so that I can wake up the chip and read the data from these two sensors if the sensors change state.

The problem is my pic chip only has one interrupt pin.

I know that if I wire the outputs of both of these sensors together and to the interrupt pin then their states will interfere with each other. (eg if one is open, one is closed).

Is there any way I can wire both these sensors together so that a change in either is detected as an interrupt.

Thanks in advance
John
 
if they're both NO and wired with pull-ups, they're basically a (N)OR gate... if you push either one of them, or both at the same time, the interrupt pin will be pulled low, only if both are released will it be high...

that, of course, won't work for the case where one switch is already pressed, and the other is toggled on/off. if you want to detect that, you should use an XOR gate. the only type of change that can't detect is the case where one switch is already pressed, and then that switch is released at EXACTLY the same time as the other is pressed. however in reality there's no way you could press the switches that accurately and quickly so it should work fine.

just some food for thought.
 
The question is really too vague, assuming you can generate an interrupt from either device on the one pin, how do you know which one it was?.

I would suggest a couple of things to think about:

1) Do you really need interrupts on both (or either) to do the project.

2) Have you tried reading about 'interrupt on change' which usually can be used on PortB, and gives you plenty of interrupt inputs.
 
Thanks for all the info so far.


The issue which will cause me a problem is as evandude said, where if one sensor is high, the other will not create a change of state.

It is the change of state which is important.
I do not need to know which sensor caused the interrupt.


Interrupt on change is something I havent heard of before. I will go and read up on that now.

I do want to make use of the sleep feature of the chip, as my device will be on for hours. Am I able to do that with IOC ??

I just want to wake the chip once a change is detected and then process the input (changes of state from both sensors) for as long as it happens.


Thanks
 
2camjohn said:
Interrupt on change is something I havent heard of before. I will go and read up on that now.

I do want to make use of the sleep feature of the chip, as my device will be on for hours. Am I able to do that with IOC ??

I think so, it's commonly used for things like keypads in remote controls, so pressing any key wakes the processor up and processes the key press.
 
A pair of diodes and a resistor should do what you want. Each doide is connected to a sensor output on one end and the interrupt pin on the other. The diodes should allow current to flow from the interrupt pin to the sensor output. A pull up resistor should be put at the interrupt input. This setup is called a "diode-OR". So each sensor can pull the interrupt pin low without affecting the state of the other sensor ouput. Thie is just a simple cheap way to do what an or gate does.

Brent
 
yes brent, but that really only applies to something that has high and low output states. a NO switch to ground has two states: low, and open circuit. so you could just put the switches in parallel going to ground in that case, with a single pullup. but as he said, he needs to be able to trigger on a change of either switch, so an OR gate isn't really going to help him.
 
evandude: Sorry I wasn't a little clearer but I was talking about the output from his current switch setup with a pullup resistors for each switch. You would need 2 other port pins in addition to the interrupt pin but if you have extra pins it doesn't get much simpler. Interrupt on change would be a better solution if it's available.

Brent
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top