Selectable Program Modes in one program
Scott Portocarrero
Posts: 72
I have two separate programs I would like to combine into 1. The first program is the autonomous one and the second robot is the remote control one. Basically at processor startup I would like the BS2 to wait for a level of 556 or 557 (AUX2 switch position 0 on remote control) which means RC mode. Otherwise goto autonomous mode. Can someone take a look at my code and tell me what I am doing wrong?
Comments
It might be better to put the pulsin command inside a for..next loop that executes a bunch of times - something like this;
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
For instance with the autonomous select switch in the ON position the pulse width that your receiver is sending may be 1100, with it OFF it may be 1900. That would correspond to PULSIN values of 550 and 850. As it is now you are only going into rc mode if the pulse width is within a 4 microsecond window.
Better to say - IF (pselect < 600) THEN...
Rich H
25 times through the loop is close to the same as the pause of 500 that you had originally. I don't know the details of exactly how the PULSIN command works, looping makes sure that the input is thoroughly checked. With it running the PULSIN only one time, something could occur where the signal gets missed.
Rich H
Great! Which part worked?
I would start by having two subroutines. Autonomous and RC
In your rc loop I would change it to;
I would then add this to your Autonomous (main) routine;
That way every time through the loop it will check to see if it needs to do something different.
If there is no signal when PULSIN listens while in the loop it will cause a delay of about 1/8 of a second before it times out. That may cause a problem if you want it to run with the receiver off, if you will always have the receiver on then it would be fine.
Rich H