Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : counting input
Author | Message | ||||
viscomjim Guru Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi All, I have a situation where I need to count pulses on an input pin. Everything works as it should, however I can't figure out a good way to accomplish the following... I need to read pulses ranging from 1 pulse to 100 pulses. I have a subroutine that prompts a user to do something, the result being a series of pulses from 1 to 100. I know how fast the pulses come in (about 6.5 hz). At this point I am waiting the maximum amount of time (100/6.5 = 15.38 seconds) to check the input, even if there is only 1 pulse as a result of an action. Is there a way to tell the uMite that if the input doesn't change in a certain amount of time, that the input has reached it's maximum input pulse count? (I hope this is making sense). Something in the order of "after requesting pulse input, if pulses stop, then count is X" and then continue running the main code, instead of waiting the maximum amount of time required for the maximum possible pulses, even if its only 1, or 5, or 25. Sorry if this is confusing, and as usual, Thanks to this forum!!! |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6101 |
If you are using a counting input: use SETTICK 1000, checkinput to check for any count every second If count = 0 finish input routine else keep checking If you are using interrupts to do the counting, reset a timer every time a count is registered. If there are no counts for the timeout value, your program will runt eh timeout routine. A bit like the watchdog timer. You can reset timers or disable them at any time by reissuing a SETTICK command. Jim VK7JH MMedit MMBasic Help |
||||
Print this page |