Error in DS1620.java?
I've been trying out the DS1620 class and seem to be getting 1/2 the temperature I'm expecting. DS1620.getTempRaw uses
tempIn = (CPU.shiftIn(dataPin,clockPin,9,CPU.POST_CLOCK_LSB) >> 7);
which uses POST clock data sampling, but all BS2 programs use
SHIFTIN DQ, Clk, LSBPRE, [noparse][[/noparse]tmpIn\9]
which uses PRE clock data sampling.
I think that the DS1620 class is failing to read the least significant bit and the line should read
tempIn = (CPU.shiftIn(dataPin,clockPin,9,CPU.PRE_CLOCK_LSB) >> 7);
which then seems to return the correct value.
Anyone want to verify this?
Dave.
tempIn = (CPU.shiftIn(dataPin,clockPin,9,CPU.POST_CLOCK_LSB) >> 7);
which uses POST clock data sampling, but all BS2 programs use
SHIFTIN DQ, Clk, LSBPRE, [noparse][[/noparse]tmpIn\9]
which uses PRE clock data sampling.
I think that the DS1620 class is failing to read the least significant bit and the line should read
tempIn = (CPU.shiftIn(dataPin,clockPin,9,CPU.PRE_CLOCK_LSB) >> 7);
which then seems to return the correct value.
Anyone want to verify this?
Dave.
Comments
I am getting the wrong values too?
my code
JM
I did the update, but I just figure that I still have, sometime, the issue. It's sometime working fine, and sometime not.
I did a graph with the values I retreive over the night ( https://ssl.spaggiari.org/eau.html ). As you can see, the value is usually between 50 and 52. But at one point, I retreived 25.5... Right the half of the expected temperature.
So if you "play" with PRE and POST, sometime you will get the half, or sometime you will get the double. But it's never 100% accurate.
Has someone any idea what's wrong with the DS1620 class?
I think it's more than just this PRE/POST issue.
Thanks,
JMS
Notice the marked lines.
It shifts right tempIn.
But using >> keeps b15, so if tempIn is negative,
the red line will not make sign 1.
Try this:
Optimizing:
·regards peter
Post Edited (Peter Verkaik) : 4/18/2009 6:40:32 PM GMT
Thanks for your reply.
I tried the optimized version but Jide don't like it because, I think, 0xFF00 is to big. It's saying something about a constant beeing to big. The non-optimized version compile well, but the received value is still 2 times bigger than expected. Even after I shut the power off then on. So I tried back with the POST instead of the PRE, and it'S working, but I'm not sure if it'S really what need to be done and how long it's going to work.
Thanks,
JM
That should do it.
And it probably must·be POST_CLOCK.
regards peter
Post Edited (Peter Verkaik) : 4/18/2009 8:20:13 PM GMT
I will keep the POST and monitor over the comming hours to see if there is any issue.
Thanks,
JM
should already keep the sign, so no need to add it afterwards.
So this should work also:
regards peter
I just tried with what you send above, and it's ready twice the real temperature. I switched the power off, tried to reset the Javelin, and I'm still getting the temperature twice. So I putted back PRE, and it's now fine.
But seems that I need to switch between PRE and POST each time I update the Javeline content. Are we not missing some initialisation somewhere?
I did'nt get a chance to test to negative temperatures so far.
Thanks,
JM
(eg. LSB stands for 0.5)
So divide the signed result by 2 to get 1degC units.
That's what getTempC() does.
regards peter
Post Edited (Peter Verkaik) : 4/19/2009 1:12:48 AM GMT
he sensor is on my water tank. Temperature should be close to 52C. But sometime, the sensor is giving me 26C, sometime 104C, and more often 54.
When it's giving me the wrong number, I do a couple of reset, sometime remove the power suply, and then I finally get the right number. But when I will add another DS1620, if they don't work well at the same time, I will be in trouble.
That's why I'm little mixed up [noparse]:([/noparse]
Do you have any suggestion to troubleshot that?
Thanks,
JM
So far, seems that things are working fine. I did not received a wrong temperature for the last 24h. Will continue to monitor.
Regards,
JM