I'm trying to create a tx/rx project using 16f84 micro controllers. I have the encode/decode, and send routines. My problem comes to the receiver side, I'm trying to recover the clock from the signal in software, and I've been coming up with different ways of trying it. This algorithm seems like it would work.
Each byte lasts 100us, so at 50us is where my edge would lie. I plan to sample the signal every 10us, using the starting 10us to store the starting edge, and the last 10us to calculate the error. This means I sample the signal 8 times, each time the sample matches the starting edge, I increase its counter.
When we're done sampling, I check this counter, if the edge fell on target, then the counter should equal 4. if it falls short, I know I'm sampling too to late, and I should sample earlier. I don't worry about sampling too late, since to the algorithm it would seem that it was still sampling too early, but the bits would be shifted.
What do you guys think about this? is 8 samples going to be sufficient? am I completely wrong? thanks.
Each byte lasts 100us, so at 50us is where my edge would lie. I plan to sample the signal every 10us, using the starting 10us to store the starting edge, and the last 10us to calculate the error. This means I sample the signal 8 times, each time the sample matches the starting edge, I increase its counter.
When we're done sampling, I check this counter, if the edge fell on target, then the counter should equal 4. if it falls short, I know I'm sampling too to late, and I should sample earlier. I don't worry about sampling too late, since to the algorithm it would seem that it was still sampling too early, but the bits would be shifted.
What do you guys think about this? is 8 samples going to be sufficient? am I completely wrong? thanks.