In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Zoot wrote: Oh shoot, I just caught this. What is this about? Seems like it would never exit this state, as you clear TIX then wait for it to go past 4ms. If you want a delay after the sample is finished, you'd need to another state or something to allow for clearing TIX then waiting for it to count up to 4ms again: [code] IF General_Var(1) = 5 THEN ' measuring IF USD_Pin = 0 THEN ' Signal is high as long as no feedback. Once USD receives something, then signal goes low. ' wait for pulse to end. only if pulse has ended, procedures goes ahead, otherwise abortion here led2 = ison LOW USD_Pin ' pulse ended: turn pin off to keep trigger low Distance = rawdata ' move count to stable variable [b] Tix = 0 ' clear the timer ' from now on I have 5ms until the next reading of the USD (set at 1*) IF Tix >= 4000 THEN General_Var(1) = 2 ' end this step, skip the index finding step and system check ENDIF [/b] ' the above couldn't possibly exit this state???? ENDIF ENDIF [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=394074#m401111 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)