NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Meat thermometer project Live Graph to Display Points over a Larger time period
August 16, 2011 by kemil |
Hi all, I've been playing around with the meat thermometer project (specifically the python side of things). I want to be able to make the live graph show a longer time period. At the momenta data point streams on and leaves the GUI after about 20 seconds (i would like it to be about 10 mins), ive been playing with this code for a while now and ive found it pretty hard to make it do what i want. I think its because the data is assigned to a pixel number so a 600 pixel wide screen can only show the last 600 pieces of data. I guess the simplest thing to do would be to take the average of the last say 100 pixels and assign that to one pixel.......but i dont know how to do this if anyone has and ideas on how to go about increasing the time range and the accompanying python code i would be very thankful. Thanks kemil |
---|---|
August 16, 2011 by hevans (NerdKits Staff) |
Hi Kemil, Ultimately you are definitely going to have to average over a large time period if you want to get more data onto the screen. The live scale graph program already does that, I think you will just want to adjust how many samples it averages over. I would suggest looking over the FeederThread class, specifically the getReading() and averageReading() functions. Humberto |
August 17, 2011 by kemil |
Hi Humberto, thanks for the help. I tried implementing the averageReadings() function into my Feeder.Thread class as follows: class FeederThread(threading.Thread): running = True addPoint = None average = 100
But i get the following error: TypeError: unsupported operand types(s) for +=: 'float' and 'tuple' this error is referring to the line:
so i changed this line to:
but i got then error: TypeError: int() argument must be a string or a number, not 'tuple' I initially though it was because in my c code im using
whilst in the weight scale code you're using
but when i use %d py python code doesnt work Any thoughts on what i should do.... im thinking of only sending over ADC values and doing the manipulation of them on the python side of things which would make my source code similar to the weightscale code which obviously works... Thanks Kemil |
August 17, 2011 by kemil |
been playing with the code for a while and as far as i can gather the problem is that i can not transfer the technique used in averageReadings() which in the python code for weightscale only has one input.... but i have three which means the function run() in the Feeder thread class is no working. So How do i made the averageReading() function average all three inputs? kemil |
August 17, 2011 by bretm |
Since it returns three values, you need three sums. Something like
|
August 18, 2011 by kemil |
Hi bretm, Thanks for your reply, the problem is that sum is an python function so i cant so what you said. However, i did something similar - I made three different averageReadings() functions like this: def averageReadings1(self, average):
and then i added this line to the run function in the python code from the weight scale turorial:
which i though would put the three values into list form BUT now i get an error in the addPoint function (taken from python code for meat thermometer tutorial - because it handles multiple values send from MCU). the error says the line
Any Ideas on what i should do? Thanks Kemil |
August 18, 2011 by kemil |
Figured it out.... My mistake i just changed the line
to
And it works perfectly kemil |
Please log in to post a reply.
Did you know that one NerdKits customer controlled a laser pointer with his computer using a microcontroller? Learn more...
|