Our team has been having a go at getting a Rev color sensor up and running despite the I2C issues. We are able to get it working intermittently, but it stops working after shortly after installation. We’ve been using @Thad_House Pi Pico solution, but since we use a NavX MXP, we’ve been plugging the Pico into that instead of the MXP port itself. (Thank you for making this Thad, we’re very grateful.)
The TLDR is that it seems to work well immediately after we connect a board to the color sensors, but becomes intermittent in odd ways shortly thereafter. We’d love to hear from anyone who has this stack working because, while my understanding is that the NavX breaks out the MXP port, I am not sure if the addition of the NavX changes anything or not. My theory is that the problem is either something electrical or perhaps there is something obvious we’re missing, but frankly, no one on our team is an electrical expert and I’d love any advice anyone can offer. A detailed explanation of what we’ve attempted is below.
–
As stated we’re running Thad House’s Pi Pico solution with two color sensors. We would be fine running just a single sensor but since the solution accepts two, we used two. We’ve tried it with three separate boards. The first board worked for a couple minutes and then the color sensor lights turned off and we never received a signal again. We believe the board somehow shorted, so we wired another board, and this one worked for a bit longer, but after a few minutes one sensor stopped returning values. At some point during debugging that, the other sensor also stopped returning values, so we may have shorted that board as well. We had to focus on other priorities for our event so we paused at that point.
Today we made a third board, being as careful as we could to avoid any shorts. We installed header pins on the board and 3D printed a nice case. (If anyone needs a 3d model for a Pico case let me know, I don’t have the file handy but I’d be happy to get it from our design team and share it. I imagine other public options may already exist.) We plugged into the board and once again, our color sensors worked. We then hot-glued the pins in place on the Pico. During our first test post-gluing, only one sensor worked. After stripping the hot glue off, swapping which sensor was plugged into which pins on the Pico changed which sensor worked, indicating an issue with the board (or possibly the header pins.) Connectivity checks with a voltmeter also support this as all of our wires pass the check.
At some point, after connectivity checking all our wires and plugging them back in, we noticed that the one sensor that had been working, was now working intermittently. It will sometimes read just fine for many seconds/minutes and sometimes it will simply not read at all. Additionally, sometimes even the non-working sensor will send a single value (we observe this as SmartDashboard will have changed to just showing 0 for all colors for that sensor, to showing a value.) Sometimes BOTH sensors will read values for a period of time, but will update values roughly once per second, instead of continuously.
All of this leads me to believe we have one or more loose/slightly broken wires, but over the course of multiple connectivity checks, we have not been able to find one. It’s also possible that the header soldered to the Pico is bad. Unfortunately we did not test this yet so if you’re reading this and think “it has to be that”, let me know - we can rip the board out of the case tomorrow and try checking connectivity from the header to the underside of the board. But I am wondering if there is something else that might be causing our problems.
Photos of our wiring setup will follow in the next post.
Other things we have tried:
- Switching the NavX MXP dip switch for TTL UART between off and on
- Checking voltage drop from the NavX power pin that goes to the Pico, vs the ground - it’s 5v. (We did run it at 3.3v at one point just to see what would happen - ironically this did make both sensors work for a short period of time, before the problem re-occurred.)
- Tried re-instantiating the PicoColorSensor class in code if all colors read 0 based on this thread, but that throws “resource already allocated” errors, which makes sense as the Readme says you can only have one instance of the class.
- In our code, we do wrap the PicoColorSensor class with our own that has a couple additional methods, and we tried running the base class instead. No change. We don’t think it’s a code error based on the symptoms but our code is public here: https://github.com/RoboRavens/RapidReact the relevant code is on lines 212-230 of Robot.java as of this posting, plus perhaps the RavenPicoColorSensor class which is in the ravenhardware folder.
Things we have NOT tried:
- Connectivity checks on the headers of the Pico, as described.
- Pulling the NavX out entirely and plugging the Pico directly into the MXP port. We have a NavX micro on hand but have never tried using it. This may be a possible solution for us.
- Running a single sensor on the NavX’s I2C port (I wasn’t sure whether or not this could possibly trigger the I2C crash issue - based on the WPI known issues page, it seems like it would be safe as it’s a breakout of the MXP I2C, but if someone knows for sure I’d also appreciate hearing from you.)
Things we’d love to hear from the community on:
- Is anyone running this same stack and/or is there any reason adding a NavX between the Pico and the MXP port would cause complications
- Is there anything relating to configuration we’re missing entirely
- Any ideas on what is going wrong or how to continue debugging
- Any suggestions for a change in stack that would simplify things/increase the reliability of the sensors. Again, we’d be OK with dropping down to a single color sensor.
- For anyone successfully using a Pico: any wiring/casing/mounting tricks to prevent shorts and ensure wire connectivity?
- Anything else worth mentioning. Again, custom circuits are not our team’s strong suit so we’ll accept any advice.
Overall, while our robot can’t do everything, we’ve been happy with how we’ve accomplished the goals we set for ourselves and getting this working is our last technical goal for the season (our season ends next weekend at Michigan State Champs regardless of whether we qualify for worlds.) If anyone can help us out we would be very grateful! Thank you in advance.