| ??? 05/16/03 21:38 Read: times |
#45702 - RE: people try to understand Responding to: ???'s previous message |
Waqar:
You are making a mountain out of a mole hill. The problem for one line is pretty easy. It can use the SAME general concepts as the RC/5 example somebody provided earlier. Or follow the morse code example.....it would also show how to look at the pulses. Translating this concept to look at 8 lines simultaneously takes a state machine which is not so trivial AS I SAID BEFORE. You need to look at the sample code I put on another thread here where you sample the inputs at a periodic rate, AS I TOLD YOU ALSO BEFORE. Look for current sample being opposite level of previous sample. That will tell you when the input has changed state. Repeating again what HAS BEEN SAID BEFORE once you know a pulse is starting (or stopping) you sample it for a number of the periodic sample times. This number you can count in a memory variable until either you decide you have looked too long or you see the next change of state of the pulse. The count you gather multiplied by the periodic rate is the detected pulse width! The very easiest way to obtain the periodic sample rate is to use a timer interrupt that is programmed to interrupt at the rate you need. (Maybe 10 msec is a good start for dial detection). Setup the detection logic as a short subroutine that you can call each timer interrupt time. Have this subroutine use a variable called a state variable that controls how you look at the current call. In C language this variable would be used in a switch statement to change the code path in the subroutine depending on if you wait for first dial pulse to start, or if you wait while pulse is in progress, or if you are waiting in interpulse time for next pulse to start, or if you are waiting in the time that the digit pules sequence is finished but you have to wait since a new digit may start before you decide to timeout...etc etc etc. In assembly language you can do the same thing with either a branch table or a series of comapres and jumps. In one state as you detect the each pulse being within an acceptable range of width you will increment a counter that keeps track of how many pulses seen in this dial sequence (ie determining which digit dialed). In another state as you find that the digit sequence is done you will increment another counter that tells you how many digits you have received so far and you would take the pulse counter accumulated from the current digit and place it into a buffer that has the current detected string in it (ie first digit, second digit, .... Nth digit count. Waqar. You seem to come across like this dial detection sequence can be done by a guru in 20 minutes. Guess again. Whilest it is not too hard to design and code it will take a couple of days of work to get it working properly. This is why you don't see responses here handing you a code snippett that does the job. I for one like to share things here, BUT not at the expense of taking a whole day and nite and next day to do it. So if it still seems too complicated ..... then you need to either get a different hobby OR wire me 3 days if consulting fees and I'll write the thing for you. My email address, while easily found here, is: mkaras@CarouselDesign.com. Michael Karas |



