I got to thinking about receivers today. In the bot that i am working on there are a few positions that the bot can be in where the receiver does not receive the signal from the transmitter. If i were to plug in two receivers with the same channel into the micro controller and write a code so that the same controls will apply no mater which receiver picks up the signal from the transmitter could i effectively have two receivers so that at all times at least one of them would pick up the signal? Would it work?
Yes, it would. You will need to put in place a little “protective programming” to keep you Robot sane.
If you are using EasyC, When using the “RC Control” functions, don’t set the RX# as ‘0’. You will need to set all your RX#'s to ‘1’ and ‘2’. Each “RC Control” function will need to be Read Twice, Once for RX #1 and Again for RX#2. Read both Receivers at the Same Time.
Now here is the Hard Part.
When a Receiver “Goes out of Range”, the Vex Controller seems to set the Motors to STOP (~127 for EasyC and MPLAB C). So if One Receiver is Reading Full Speed (255) and the Other is “Out of Range” (~127), you will get Conflicting Data. You could “Average Them” (255+127)/2 = 191, Half Way between 127 and 255, which would keep you motor moving the Same Direction it was started, but at approximately Half Speed.
I would suggest a Second Variable to Hold the previous Value from each Channel on each Receiver. This way you can detect a drastic change in the Values from the Receivers, and make your Control Decisions appropriately.
When the Values for a given Channel differ drastically between Receiver #1 and Receiver #2, you immediately check the previous values for Receiver #1 and Receiver #2, if they are close in Value, you know at this moment, that one of your Receivers is no longer receiving a Signal, and to ignore its data for the moment…
I will Code Up an Example and Post it here shortly…
I like MarkO’s algorithm - it allows for graceful failure.
One other thing to consider is directly checking which receiver(s) have a valid signal. EasyC Pro has a function called ReceivingData(port), which lets you check.
If you wanted to use that, you could do something like this:
*]Read Rx1 values into local variables
*]Read ReceivingData(1) again
*]If both the before and after ReceivingData readings are true, you can trust the data in your local variables.
*]Repeat for the Rx2
[/LIST]Average the values for Rx1 and Rx2 if both reported a valid signal, otherwise pick the one that is valid. If neither is valid, then shut the motors off and wait for a fresh signal.
The real issue here is that you are somehow losing signal. If your antenna is standing apart from metal structure and is fully extended you should not be losing signal. In 30 or so VEX competition robots our club has built, we have never lost signal when the antennae were mounted properly. Good luck.