In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Jimbo wrote: [2] Hello all, I am trying to convert a BS2 program to SX/B to use with a Ping)) sensor. The problem I'm running into is that SX/B doesn't seem to want to let a Word variable operate. The number in the variable is never higher than 80. This limits PING)) to about 4 inch distance where I need it to detect objects about 6 feet away. It should be able to easily do it as the specs say it can sense out to about 3 meters. If I change the Tim var. to byte from Word it seems to have no effect on the program. I just don't see why I can't get Tim to be greater that 80 unless the problem is with the pulsein parameters. but Itried different parms and nothing works. I have been trying to make this work for two nights now with no luck. I suspect I'm missing something basic here. (wouldn't be the first time.) Thanks, Jim W. ' ========================================================================= ' File...... PING)).SXB ' Purpose... To sense an object 6 to 8 feet away ' Author.... ' E-mail.... ' Started... ' Updated... ' ========================================================================= ' Program Description ' ------------------------------------------------------------------------- ' Device Settings DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- Tim Var word 'Never seems to go over 80 should hold some large number ' ------------------------------------------------------------------------- INTERRUPT ' ------------------------------------------------------------------------- PROGRAM Start ' ========================================================================= Pgm_ID: DATA "SX/B Template", 0 ' ------------------------------------------------------------------------- ' Subroutines / Jump Table lights sub ' ------------------------------------------------------------------------- Start: ' initialization code here Main: DO PULSOUT RC.7, 5 'maybe not the right parm? tried experimrnting with no luck PULSIN RC.7, 1, Tim ' I think the distance problem is here! watch tim ' Tim always equals 80 but goes lower as object comes closer if Tim < 250 then break gosub lights endif High rb.5 high rb.4 high rb.3 high rb.2 high rb.1 pauseus 200 loop lights: if tim < 79 then low RB.5 endif if tim < 70 then ' these work but in inches not in feet low RB.4 endif if tim < 60 then low RB.3 endif if tim < 50 then low RB.2 endif if tim < 40 then low RB.1 endif if tim < 30 then low RB.0 endif pauseus 1009 return GOTO Main [/2] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=188113 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)