Postby Kevin » Thu Feb 15, 2018 5:59 pm
Okay I did some work on this issue this morning. I can't see anything obviously wrong so this is really strange.
When you guys run the volts.py script, are you seeing the COM light on the rover blink? This light should blink any time the PIC sees I2C traffic with its address on it. If we get blinks that would confirm the PIC is at least seeing the traffic.
Before we ship the units, part of the test process is for a Pi on my test fixture to attempt to read voltage from the PIC as it boots up. It sends this data to the Ardunio via SPI and the Arduino sends it to the test program on my testing PC, which displays the data. I personally tested each board that went out so I could at least say for sure what test was carried out and I've never had that part fail (and the values do change from unit to unit, so I know it's actually reading something).
Today I took one of the production units and re-flashed the PIC processor with the same machine I use to flash the production boards to make sure it for sure has the most current version of firmware (the same as shipped to you guys) and I ran the test again and volts.py responds correctly each time. The Raspberry Pi on that unit started with a new memory card like we sent with the other units. So as far as I can tell, as long as the setup steps for the Pi were done the same as what I have here, we should have identical units at this time, so that's really strange that several of you would have this problem where I'm not seeing it at all.
The entire production test does a lot of I2C communications between the Arduino and PIC, so I'm certain that pathway is intact and working or nothing would be working on the robot so from a hardware standpoint I think we're good.
The only thing I can figure is there is something different in the configuration or code of the Pi as you guys are running it compared to what I have here and have on the test fixture since I think we've established the PIC code is identical.
A couple things I'd like to try.....
1) Can you guys confirm if your COM led blinks?
2) Try adjusting the value in the python script near the top: s.i2c_process_delay(15)
This is used to configure the PIC to introduce a short delay before it releases the I2C bus after receiving data. I had to do this to get around a hardware bug in the Pi processor, which we just have to live with. I believe the delay is in microseconds. Try some different values in there from 0 to maybe 50 or 100 or so and see if things magically work with a different value.
3) Does anyone have a scope that can see or even decode I2C? If so, you can sniff the I2C bus with 2 through hole pins - they are located just inward from the Bottom Left and Bottom Right plugs for the bottom sensors. They are labeled SDA and SCL and match the corresponding I2C data lines. It may be helpful to capture a long time duration picture of the entire transaction with volts.py runs, then zoom in on some of the packet enough to decode it and really see the signal.
4) I can't dig into it right now, but someone may want to dig into the spirit_core.py file for the power_voltage() function and figure out how exactly the I2C packet is constructed and how the response looks. I think the response is stored in an array or something (I wrote it but can't remember, it's been a long time) - have the script print that data to your screen and maybe post it back here along with whatever test script you made up. I can run the same on my end and maybe figure out where the data is going wrong.
So I feel pretty good that it's not a hardware problem which of course is always my worst worry.
Thanks for the help guys.
-Kevin