Hi more knowlegable people.
I've made a little robot that runs into walls. It's meant to do that, but it's not meant to try to burrow through the wall - so I have what I'm sure is the normal bits and pieces - just debounced trigger switches and a ~10ms main loop that can react fast enough to change direction and stop the burrowing...
But that's not how I wanted it - I think looping and testing the state of the switches every 10ms is a bit primitive - ideally I wanted to have the swtiches trigger an interrupt, and here's the problem - the exact nature of the reaction depends on which triggerswitch is closed (i.e. turn left OR right), but, if I understand my picaxe book and manual properly, it seems picaxes allow only one interrupt condition.
So I can interrupt on either the left bumper, or the right bumper, but not EITHER (not, I don't want BOTH, just EITHER).
This sounds a bit limiting to me, so I'm assuming that I'm not ITFM properly (ITFM is like reading the FM, but my brain can't make sense of it and interprets it badly....). My question is - is this the case? and if so, what do people do if they want two different interrupt conditions, with two different kinds of responses?
While I'm talking about the pixaxe book ("programming and customizingthe picaxe microcontoller"), has anyone else got a copy that seems to be royally screwed up? the indexing is all out of whack, some of the text seems just wrong, the figure and table labelling is really out of kilter etc. etc. etc.is it just my copy? or is this a known thing?
Thank in advance for any help!
EM.
From my recolection, you
From my recolection, you should be able to set the int mask so as to be triggered by multiple triggers, and at that point, poll the triggers to find out which was set off. Not sure if all of this can be done fast enough, but it’s worth a try…
hmmm, I’m not so sure that will work…
Thanks for your thoughts VDB,
As I understand it, all conditions of the int mask must be simultaneously satsisfied, so if I set the interrupt to trigger on say, a high state of pin 1, then I do something like:
set int %00000001, %00000001
of if I want 1 and 2:
set int %00000011, %00000011
But this wil require that BOTH one and two are set high before the interrupt. I need 1 OR 2. Since I there is only one interrupt condition, I don’t know the best way to do it…?
Thanks again.
E.]
perhaps way
I’ve tried and searched and then came the X2 series picaxe chips. The X2 series seem to support multiple interrupt conditions. If you use an X1 chip you can also try the NOT keyword.
I havent tested it, but the documentation says the X1 and X2 both support this. perhaps you can use this to trigger the interrupt when both bumpers are NOT low instead of testing if Left_bumper=1 OR rightBumper=1
SETINT NOT input,mask (X1 parts only) => Picaxe manual 2 : page 178 => setint command
I can only tell you that on
I can only tell you that on X2 parts you can do this, as for the X1 parts, you could try setting a common interrupt for the two switches and then, once the interrupt is triggered, check them individually with an input pin (if one is high and the other is low then you know which one got triggered).
hmm, yep, I’m using an
hmm,
yep, I’m using an 18X1, and I’m not 100% certain how I’d go about using the ‘setint not’ command, it doesn’t look very different to the setint command, but with the input values inverted…
Yes, after a bit more
Yes, after a bit more thought about it, I could just connect the output of the left bumper via diode to the output of the right bumper (AND it’s own output pin), then set the interrupt on the output of the right bumper, then check both left and right…
hmm… why didn’t I think of that before?
grr, sleepy, obviously.