Interrupt using ADC and pin0

mikie_121

Member
Hi
I'm looking to generate an interrupt when either pin0 goes high or the readADC value goes above 50. I can't use an if because I have a pause line which refreshes an LCD display every second. But I need the interrupt to occur immediately when it happens (obviously).
Any help would be great.
Mike

Edited by - mikie_121 on 01/06/2007 14:39:22
 

Jeremy Leach

Senior Member
Not too clear on your logic. If you've got a regular pause, then surely you can do a regular 'IF' check? Or is it that you want the interrupt to occur immediately the condition arises?

Interrupts occur when the input pins match a given state, they don't occur on the level of an ADC input. However it might be possible to adjust the level of your input signal (with op amp, or perhaps just resistors) so that 'ADC above 50' is instead the transition from logic low to high, which <i>could </i> then generate an interrupt.
 

steliosm

Senior Member
mikie_121 could you give us a flow of your program execution? How is this LCD refreshed? What does it displays?
You could set an interrupt for the pin0 when it goes high:
setint %00000001, %00000001
 

hippy

Technical Support
Staff member
Instead of a program like this ...<code><pre><font size=2 face='Courier'> Do
Check conditions and Interrupt when needed
Pause 1 second
Update LCD
Loop </font></pre></code> which checks the conditions only once a second, this ...<code><pre><font size=2 face='Courier'> Do
For var = 1 To 1000
Check conditions and Interrupt when needed
Pause 1 mS
Next
Update LCD
Loop </font></pre></code> will check the conditions every millisecond and still update the LCD every second.
 

mikie_121

Member
problem solved. I used a separate Picaxe 08 chip to handle the readadc and output a logic high when the analogue signal goes above any threshold i set. this means i can set an interrupt to occur when either pin0 or pin1 go high on my main control chip.

thanks for all the suggestions.

Edited by - mikie_121 on 01/06/2007 14:40:25
 

mikie_121

Member
i found that the picaxe 08 wasn't giving me a fast enough update, so i used hippies suggestion and it seems to work really well. thanks again
Mike
 
Top