[TriEmbed] IR sensor vs trigger
Jon Wolfe
jonjwolfe at yahoo.com
Wed Jul 30 21:09:02 CDT 2014
I agree with the others, it sounds like the trigger should get the interrupt.
Like Jeff said, you want your interrupt to execute in as short of a time as possible. One approach might be to just set a flag on trigger presses then process the action in the main loop. That could still leave you with 1 sec latency if you are detecting IR hits, which would probably be pretty noticeable.
I have never tried this on a tiny, but I'm making it a personal mission to find a use case for it, but you could use an RTOS, like http://www.femtoos.org/ Looks promising. I've used ChibiOS on Cortex M3/4's and found it pretty nice to work with, YMMV.
The other alternative approaches might be to try to reduce the 1 second detection loop. Or, to try to architect your own "cooperative multitasking" or coroutines. In short, write your detect loop so that instead of looping for 1 second, it just does a little bit of work and returns to the main loop, remembering where is was in the loop between each call. I use this approach a lot.
I will say that you should try to handle debouncing the trigger in hardware as much as you can. I've tried software debouncing mechanical encoders in interrupt driven routines, and I can attest that it is maddening.
Lastly, you *could* always just buy a separate tiny for the detection, but I have no ulterior motive or bias there ;)
________________________________
From: Joe Fair <joe at fairanswers.com>
To: triembed at triembed.org
Sent: Saturday, July 26, 2014 4:09 PM
Subject: [TriEmbed] IR sensor vs trigger
Ok. I'm pretty close on getting my home made laser tag with at tiny 85s going, but now i have a question about design.
The loop I'm using detects a trigger pull, then a hit on the sensors. however, The pulse in function I'm using to sense IR ha a timeout of 1 second. If there is no inbound signal it is only checking got a trigger pull once a second.
So i need to use an interrupt, but does it matter if i use one on the trigger pull or the ir sensor?
Joe
_______________________________________________
Triangle, NC Embedded Computing mailing list
TriEmbed at triembed.org
http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
TriEmbed web site: http://TriEmbed.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20140730/51550b0a/attachment.htm>
More information about the TriEmbed
mailing list