Let's Make Robots!

IF / OR Interrupt? Picaxe...

Hey guys,

I am playing with a 40x2 and the hintsetup and hserinsetup commands also with the flags commands... I would like to interrupt on either a hint signal OR a hserin input NOT both at the same time. It seems that with the various flags conditions, you can stack-up a bunch of stuff that has to be true to interrupt, but there is no "OR" --just a bunch of ANDS


Basically, "if hint1=1 and hint2=1 then inturrupt" but not "if hint1=1 OR hint2=1 then interrupt"...

anyone got any thoughts?


--I should add to this:

I would like to interrupt on many different conditions and then when the code zaps down to the interrupt sub-routine, I would then like to use something like: if flags=%00000100 then... if flags=%01000000 then...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Would it be possible to feed both signals throug an OR chipp before feeding the one result into the 40x2? Or are both signals too different?
one is a simple 1 or 0 and the other is a hserint --the heserint is an interrupt when the picaxe gets some serial data in the background...

I was going to suggest the brute force external OR, but Rik beat me to it.

How about dividing the logic to trap for two conditions:

"if hint1=1 and hint2=0 then inturrupt"

followed by

"if hint1=0 and hint2=1 then interrupt"

You basically create two conditions that recreate an OR function.

Can't you use both the setintflags(for serin) command and the setint(for normal interrupts)?
you would need the flags command to know which one was interrupted once you get to the interrupt sub-routine.

HIntSetup %00000111 ' Allow Pin Interrupt Flags 
HSetIntFlags %00001000 ' Interrupt on any Pin Interrupt Flag
Do : Loop

If hint0flag = 1 Then ...
If hint1flag = 1 Then ...
If hint2flag = 1 Then ...


(from picaxeforum.co.uk) i didn't know the existence of interrupt flags until i posted that question on the picaxe forums 3 months ago. Here's s the full page in case you're interested

The X1 and X2 both support NOT. 

SETINT NOT  input,mask (X1 parts only) => Picaxe manual 2 : page 178 => setint command 

You can try to negate the conditions where the interrupt shouldn't fire. E.g. if you want pins 3 OR 4 to be high to trigger the interrupt, write it like NOT (pin3=0 AND pin4=0) which is the same as (pin3=1 OR pin4=1).

I'm not sure which options are available for the X2, but I think negation on interrupts should work. 

I think you got something going there... Thanks, friend... I got some test-codeing to do!

Let me know how it works out.

Two hungry babies really eat away all my time so I dont get around to doing any roboting these day. I'm very curious to see if this works as planned. You never know how it goes with those more obscure picaxe commands.

I know there are a couple of other users who faced the same interrupt dilemma. 

Yup, Today it's my turn at this problem (aka this problem??). Using a 28X2 with two bumper switches (B.0, B.1) and a serial input on C.7 = hserin.

I already coded proofs of concept: one program that responds to bumpers and another program that responds to serial data coming in. Both programs are running around in the main loop, waiting for stuff to happen.

Check out the different setintflags statements
setintflags %00001000, %00001000 ' this waits for any of the hint0, hint1, hint2 = B.0, B.1, B.2 to call
setintflags %00100000, %00100000 ' this waits for serial data to be received in the background

Now I want to integrate both concepts into one program:
setintflags %00101000, %00101000 ' this breaks the program but still compiles just fine

So, after consulting CtC over Skype, I am considering to hardwire the serial line to B.2. This is an unused input that can trigger a hardware interrupt on a falling or rising edge, just like my two bumpers.

Cross your fingers for me.