I have a project running with a 12f675 that ive been working on for a while using an rs232 input. My problem is that it isnt totally reliable, close, but not perfect. I have a 4 digit string coming through rs232 and accept this data via the code below...
Code:
serin 3,2,digit1
serin 3,2,digit2
serin 3,2,digit3
serin 3,2,digit4
To make sure that I am getting a value that isnt corrupted, I try to check everthing in a range and go back to main to get more serial data if it doesnt look right with the following code...
Code:
check3:
if digit1 = 48 then goto main
if digit1 = 46 then goto main
if digit4 = 46 then goto main
if digit1 < 46 then goto main
if digit1 > 57 then goto main
if digit2 < 46 then goto main
if digit2 > 57 then goto main
if digit3 < 46 then goto main
if digit3 > 57 then goto main
if digit4 < 46 then goto main
if digit4 > 57 then goto main
if digit1 = 47 then goto main
if digit2 = 47 then goto main
if digit3 = 47 then goto main
if digit4 = 47 then goto main
return
Often, the display keeps old data that is behind the rs232 stream by a few seconds, im sure because it isnt seeing what it likes and continues to loop thought the serin's until it gets something that it see's as appropriate. Is there a better way to do this?
Thanks
Bookmarks