IR Remote Applications
Bot Learner
Posts: 9
Hi all!
I just finished the IR Remote for the Boe-Bot kit and it was a lot of fun!
I did have a problem, though.
While doing Chapter 3 Project 1 I·tried to modify·the 7BitRemoteBoeBot.bs2 code to include input from the IR LEDs for collision avoidance, but couldn't get it to work. The input at IN0 was always a zero so there was no movement with the remote control 2 or ChUp command. After making multiple changes with no success,·I tried the code suggestions in the Solutions section. These changes didn't work either as the input at IN0 was still always zero.··Then I moved the commands to check the IR detectors to just after the DO command and before the GOSUB Get_Ir_Remote_Code instruction in the main routine and it worked great. (Code attached)
I'm thinking the problem is ·in the timing of checking the IR detectors while the code keeps jumping to the Get_Ir_Remote_Code· subroutine before the IR detectors are polled. Anyone have any insights into the problem?
TIA
Bot Learner
I just finished the IR Remote for the Boe-Bot kit and it was a lot of fun!
I did have a problem, though.
While doing Chapter 3 Project 1 I·tried to modify·the 7BitRemoteBoeBot.bs2 code to include input from the IR LEDs for collision avoidance, but couldn't get it to work. The input at IN0 was always a zero so there was no movement with the remote control 2 or ChUp command. After making multiple changes with no success,·I tried the code suggestions in the Solutions section. These changes didn't work either as the input at IN0 was still always zero.··Then I moved the commands to check the IR detectors to just after the DO command and before the GOSUB Get_Ir_Remote_Code instruction in the main routine and it worked great. (Code attached)
I'm thinking the problem is ·in the timing of checking the IR detectors while the code keeps jumping to the Get_Ir_Remote_Code· subroutine before the IR detectors are polled. Anyone have any insights into the problem?
TIA
Bot Learner
Comments
Cool; glad you liked it.
I think your code needs to make sure to check for an object during the IR remote's pause between messages.· Since the PBASIC program only grabs the first 7 bits, the code has to wait until the existing message ends.· So, add PAUSE 4 after the Get_Ir_Remote_Code subroutine call.· Then, check the IR detectors after that, and there should be no interference.
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
I moved the code checking for the IR distances to just before the Select statement as noted in the solutions section. I then added the PAUSE 4 after the GOSUB command as you suggested and it works as advertised.
Might this be a candidate for the Errata document?
Thanks for the help!
Bot Learner
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.