Making Raspberry Pi Gauges - The Blog

Non-repair car talk
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

billgiacheri wrote:It will be interesting to see if the pi can drive more than one display since most dashboards are much wider than tall and a normal rectangle will likely not be big enough width wise and still fit height wise. 2 7 inch displays side by side, on their side would probably work for the IROC, there is also a 10 inch single display that might work in the Monte.
The Pi can only drive one display at a time from either the HDMI or Composite video ports. You might be able to make a USB display work, though. You could get 2 Pis and connect them via ethernet. One would poll for data, and provide it to the other one while they both drove a display containing different gauges.
billgiacheri wrote:I want to do some research to determine how fast the OBD updates so I am not attempting to update the pi before the OBD has a new value because that will be a waste of resources, and the pi is pretty limited.
Can't find a good source of information about this, but Kevin makes a good point. Start at 10 Hz/FPS. This is way less than you should be able to get data out of a CAN-BUS system. See how the gauges perform, and adjust as necessary. 10 FPS is low for full motion video, but should be about adequate for gauges. It needs to be enough so the animation of your fastest moving gauge (tach) doesn't look choppy. Might need 15 or 20 FPS. It will probably be limited by Pi performance. You could get real fancy and only update the tach and speedo at a higher rate and just do the others at 1 Hz or even slower.
kevm14
Posts: 16021
Joined: Wed Oct 23, 2013 10:28 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by kevm14 »

10 is the max that the OBD-I GM '8051 PCM updates its stream. So I happen to familiar with the exact utility of that update rate. But yeah smooth gauge motion will probably require at least twice that, when you get to the point that gauge motion is the #1 system improvement/fix.
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

kevm14 wrote:10 is the max that the OBD-I GM '8051 PCM updates its stream. So I happen to familiar with the exact utility of that update rate. But yeah smooth gauge motion will probably require at least twice that, when you get to the point that gauge motion is the #1 system improvement/fix.
If 10 Hz works out to be the max the interface supplies, you could always introduce a 1/2 frame of data "lag" and run the gauge drawing at twice that speed. You would animate 1/2 of the data frame value delta every gauge frame. The tach would "lag" the engine, but the animation would look smoother.

Example:

Code: Select all

Engine (10 FPS)
100       200        300       400       500

Gauge (20 FPS)
100  100  150   200  250  300  350  400  450
I can provide some sample code if you run into this.

*Edit, the forum handles white space strangely, so I needed to use the code tag and get creative with spaces.
kevm14
Posts: 16021
Joined: Wed Oct 23, 2013 10:28 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by kevm14 »

I don't know if OBD-II does any better than 10...it may.
bill25
Posts: 2583
Joined: Thu Oct 31, 2013 2:20 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by bill25 »

I was able to do some testing today. I tried 10 fps, it looked broken, but when I paged through the gauges, they would get new data when paging back and forth. I thought I broke something because python is very whitespace sensitive.

The way the python wx.Timer works is you give the parameter in milliseconds to tell it how often to refresh, so the 10 fps was 100 ms.

It turned out that I didn't break the GUI script, I exceeded the refresh rate that is possible. I tried 800 ms next, that worked, 400 ms, worked, 200, broke. I tried 250 and that worked so I am currently getting 4 fps. I think that would be decent since some delay/smoothing can probably be done with the gauge needles.

I am not sure what is limiting the refresh rate yet. It could be the number of parameters being read on a refresh, it could be the pi/usb interface, or there may be something limiting the refresh in the interface script. This may be an ongoing investigation.

I am also researching how to integrate the gauges that I downloaded in QML with Python.

I have successfully downloaded and installed Python 3.4 and PyQt5 (You must do it in that order). These are compatible together, and I have verified that I can use Qt objects in my Python Module. I just don't have a clue as to how to create Qt objects in Python, or what IDE to use.
kevm14
Posts: 16021
Joined: Wed Oct 23, 2013 10:28 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by kevm14 »

Is there any way to use an interrupt-driven refresh? Perhaps use something on the OBD-II interface to trigger that (like a change in a parameter). I guess you'd still need to sample at some rate to know that the data changed. Needs more thought I guess.

Can it store stuff in a buffer and then let you compare a previous value to the buffer? I put my brain in PIC mode for this post so I am sure my thinking is antiquated.
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

kevm14 wrote:Is there any way to use an interrupt-driven refresh?
USB protocol doesn't support interrupts. The controller may have that as an added feature, but probably not, so you are stuck will polling.
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

billgiacheri wrote:I just don't have a clue as to how to create Qt objects in Python, or what IDE to use.
Qt Creator should have plugins for PyQt. See code sample here: https://en.wikipedia.org/wiki/PyQt for initializing a Qt object in python.
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

kevm14 wrote:I put my brain in PIC mode for this post so I am sure my thinking is antiquated.
Position Independent Code mode?
Last edited by Adam on Sat Jul 18, 2015 10:03 am, edited 1 time in total.
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

Adam wrote:
billgiacheri wrote:I just don't have a clue as to how to create Qt objects in Python, or what IDE to use.
Qt Creator should have plugins for PyQt. See code sample here: https://en.wikipedia.org/wiki/PyQt for initializing a Qt object in python.
You can also use Qt designer with Python. Its mode GUI-focused, but has code editing tools as well.
Post Reply