external interrupt
Special_K
Posts: 162
This may be a stupid question. But, I was reading the new Nuts and Volts and they had an article on external interrupts...
Does the BS2 or any parallax chip have this function?
I looked in the manual and I did not see it mentioned.
Does the BS2 or any parallax chip have this function?
I looked in the manual and I did not see it mentioned.
Comments
No PBASIC Stamp has external interrupt capability, but polling can come awfully close when used with the BS2p series Stamps.See PollWait, PollRun, etc.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...
I find that many times people THINK they need interrupts, but usually it can be accomplished using a simple latch or something.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
·
My own feeling is that true interrupts are only necessary when the possible speed of your main state-machine loop prevents handling an "interrupt" event quickly enough, or because the hardware of your platform dictates such an approach. In the case of the former, on a Stamp, presuming you have a slot free to handle the POLL code, you'd probably be OK. In the case of the latter, you may need a chip with true interrupt capability.
The POLL commands allow for you to check the state of an I/O pin "between" every program instruction, and then your code jumps to a pre-defined slot. You may want to see some of Tracy Allen's write-ups on multi-slot task management if you take this approach -- it can make it easier to simulate a "return from interrupt" after your POLL slot has run. emesystems.com/BS2SX.htm#Crossbank
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
www.emesystems.com/BS2poll.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
_________________code snipet____________________
DO
IF IN0=0 THEN
GOSUB bumped
ENDIF
mainloop:
GOSUB GET_sonar
SELECT cm
CASE > 25
GOTO TOir
CASE < 15
GOSUB Ping_Around
CASE < 10
GOSUB Backward
GOSUB Ping_Around
'CASE 16 TO 25
' GOSUB Forward
ENDSELECT
_________________code snipet_ end___________________
the program then goes to a subroutine if the BOEbot is stuck.
_________________code snipet____________________
bumped: 'start bumper subroutine
LFT = 750 'set lft value to stop
RHT = 750 'set rht value to stop
SEROUT Sdat,baud+$8000,[noparse][[/noparse]"!SC", 01, 0, LFT.LOWBYTE, LFT.HIGHBYTE, CR] 'apply stop values
SEROUT Sdat,baud+$8000,[noparse][[/noparse]"!SC", 00, 0, RHT.LOWBYTE, RHT.HIGHBYTE, CR] 'apply stop values
FREQOUT sound, 200, 2000
PAUSE 100
FREQOUT sound, 50, 3400
GOTO mainloop
RETURN
_________________code snipet__ end__________________
This subroutine has to back the BOEbot up enough to get it out of its jam. However sometimes the BOEbot backs up into things. I modified two limit switches from the VEX systems and the act as bumpers. The problem is that since the value is being sent to a PSC it just backs up even if the switch is hit. The PSC will keep going backward. I thought that the interrupt would help. Any ideas?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
it is I guess a combination of fast IR using Sony IR units, sonar and a bumper switch. The sonar is on a turret with two servos later I will have it sweep and then raise and sweep again (it keeps getting stuck unter the couch).
Post Edited (Special_K) : 6/12/2006 9:35:35 PM GMT
The PAUSE in your original backward routine will burn you btw, because during the PAUSE, the Stamp will be doing nothing, parsing no input, while the pause is in effect. Your PSC, though, will keep your bot rolling backwards.
Like I said above, you could use a counter to time your backup, or you could use your PING (a more elegant solution) to actually check the distance in front of you and see if you've backed away from the obstacle enough. The problem with that, of course, is that if your bumpers triggered the backup and NOT the PING, then you don't have good way to tell.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Thanks for the ideas.
Oh, one other thing I saw in a casual persual of your code..... where you have
You could combine the "both" part like this:
Also, though I haven't tested this, you could probably save an I/O pin by using one line to read data from both IR detectors, and use separate clock lines. Only one detector will be sending out data so you can use just the one pin to read from either one, depending on which one is enabled.
Lastly, I saw that you are using a discrete pin to send out pulses to your PING servo. You could hook that servo up to your PSC, saving another pin. The trick there of course, is timing your program so it reads the PING only after the servo has gotten to the proper place. On my bots, I "read" the actual position of the servo from the PSC to verify that it's gotten where I want it go before going further. Refer to the PSC documentation for info about reading actual servo positions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
I tried to make the code a little tighter but I never got it smaller. the READ_IRBOTH: is just the two bits mashed together.
thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST