volts.py output problem

The more technical aspects of Spirit, and carry-over discussion from Kickstarter updates.
Nickw58
Posts: 20
Joined: Sun Oct 15, 2017 11:13 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

volts.py output problem

Postby Nickw58 » Mon Feb 12, 2018 12:50 pm

Hi,

After some help. When I run the volts.py provided in the democode directory, it gives the following output

Battery Voltage: Wrong register replied
0
Wrong register replied
0
Wrong register replied
0

Can anyone suggest why this might be ?

Thanks in advance for any help provided ;-)

Bastian
Posts: 21
Joined: Sun Oct 22, 2017 5:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby Bastian » Mon Feb 12, 2018 3:41 pm

It's a known bug. You'll find some other posts on this at the forum.

The requested rgister isn't returned in the answer from Arduino. When the print statement in spirit_core.py is extended with , i2c_reply[0] and/or , i2c_reply, one can see a list of value 255 ([255,255,255,255]). So the register as well as the values are returned as 'FF'.

It has been suggested that loading the Spirit_Base_Sketch_PiControl.ino on the arduino should/would/could solve the problem. Unfortunely that didn't do the trick for me.

Several other users are working on this bug. So keep your eyes on the forum.

Kevin
Posts: 180
Joined: Tue Jul 28, 2015 12:56 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby Kevin » Tue Feb 13, 2018 4:06 pm

Is it just the volts.py? Does the rangefinder example return a result? (If the range is greater or less than about a meter, or the angle to the surface is off, it will return 0's). Mainly interested if you get the "wrong register" result again.

Bastian
Posts: 21
Joined: Sun Oct 22, 2017 5:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby Bastian » Wed Feb 14, 2018 10:41 am

With my spirit it's the same result for volts, rangefinder and lightsense

Nickw58
Posts: 20
Joined: Sun Oct 15, 2017 11:13 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby Nickw58 » Wed Feb 14, 2018 1:07 pm

Hi Kevin,

I can confirm I get same result running the rangefinder.py

Rangefinder: Wrong register replied
0
Wrong register replied
0
Wrong register replied
0

Kevin
Posts: 180
Joined: Tue Jul 28, 2015 12:56 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

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

Nickw58
Posts: 20
Joined: Sun Oct 15, 2017 11:13 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby Nickw58 » Thu Feb 15, 2018 8:32 pm

Hi Kevin,

I can confirm I do see the Com led blink.

I have tried altering the i2c delay to various values on both volts.py & rangefinder.py but the outcome is the same.
Sorry not able to help with items 3&4

Regards

Nick

Kevin
Posts: 180
Joined: Tue Jul 28, 2015 12:56 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby Kevin » Fri Feb 16, 2018 4:40 pm

I know the I2C bus can be run at different speeds. I wonder if somehow my unit is at a different speed. Does anyone know off hand how to configure this?

Also, some of you started setting up your Pi units before I gave my own setup instructions. I wonder if maybe I did something different when installing the smbus package or one of the related packages?

-Kevin

acojon
Posts: 6
Joined: Sat Feb 17, 2018 12:39 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby acojon » Sat Feb 17, 2018 12:43 am


acojon
Posts: 6
Joined: Sat Feb 17, 2018 12:39 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: volts.py output problem

Postby acojon » Sat Feb 17, 2018 1:01 am



[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 26 guests