![]() |
sensors could be shorted
well since I was paranoid, our team taped all the touch sensor pos/neg connections to make sure they didn't short.
some simple code like this can test your sensors if not (rc_sw1 = 1) then skip1 PWM1 = 254 skip1 just press the sensor, see if it moves PWM1, and change rc_sw1 to rc_sw2, rinse and repeat actually found one or two that didn't work on ours 907 Brian Lim |
Thank you gwross. But I use 2.0. Don't want to mess with a possibly buggy compiler.
If neg_logic <> fun then you_use_twopointfive fun = 254 - syntax_frustrations goto end_of_code you_use_twopointfive: fun = 254 - syntax_frustrations - compiler_worries + normal_logic end_of _code Hmm. They seem about equal. Oh well. I don't want to download another program. Until next year anyway. Oops. Went off on a tangent. But anyway, I like converting the switches to a binary nibble. You don't have to use a byte for an analog input, and all you have to do is move their bits to their respective places in the nibble. |
Brian, why don't you just use debug to test sensors?
|
For those of you that may still be struggling with autonomous code, here is some code snippets that may help.
loopCnt VAR byte 'Loop counter Low byte loopCntHigh VAR nib 'Loop counter High nibble StradegyNumber VAR nib 'The Stradegy number selected on robot Stradegy1 VAR rc_swB.bit5 ' Stradegy Selection Switch 1 Stradegy2 VAR rc_swB.bit6 ' Stradegy Selection Switch 2 Stradegy3 VAR rc_swB.bit7 ' Stradegy Selection Switch 3 loopCnt=0 loopCntHigh=0 MainLoop: '>>>>>>>>>>>>>>>>>>> LOOP COUNTER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IF auton_mode THEN IF (loopCnt + 1 > 255) THEN loopCntHigh = loopCntHigh + 1 loopCnt = 0 ELSE loopCnt = loopCnt + 1 ENDIF ELSE loopCnt = 0 loopCntHigh = 0 ENDIF '>>>>>>>>>> STRADIGY SELECTION <<<<<<<<<<<<<<<<<<<<<< 'This section move the stradegy switches into the StradegyNumber varible for program use StradegyNumber.Bit0 = Stradegy1 StradegyNumber.Bit1 = Stradegy2 StradegyNumber.Bit2 = Stradegy3 '>>>>>>>>>> AUTONOMOUS MODE <<<<<<<<<<<<<<<<<<<<< IF auton_mode THEN 'Check for Autonomous mode SELECT StradegyNumber CASE 0 'Stradegy 0 code goes here CASE 1 'Stradegy 1 code goes here CASE 2 'Stradegy 2 code goes here CASE 3 'Stradegy 3 code goes here CASE 4 'Stradegy 4 code goes here CASE ELSE 'Not a valid stradegy PWM1 = 127 PWM2 = 127 ENDSELECT 'End the autonomous mode stradegy selection ELSE 'Not in Autonomous Mode loopCnt=0 'Reset Loop Counter when not in Autonomous Mode loopCntHigh=0 ENDIF Tim Tedrow |
Quote:
Constants do not take up any extra memory or variable space. Check the Parallax manual. They do make your code much more readable! However, assuming the above example had a few programs (program1=0, program2=1, program3=2, etc...), it is confusing to stagger your indices like that. Starting it at program0=0 is preferred. |
| All times are GMT -5. The time now is 22:16. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi