Go Down

Topic: MEGA2560 and I2C with LM92 (Read 1 time) previous topic - next topic

PaulS

Quote
The lower 3 bits are status bits, unimportant for me, therefore ">>3".

And the upper 4 bits of the MSB (or at least the upper 3) don't mean anything, either.

So, << 3 the msb to get rid of them, then >> 3 the msb, to get the 5 useful bits back where they belong.

Quote
The LM92 is a digital temperature sensor and thermal window
comparator with an I2C™ Serial Bus interface and an accuracy of ±0.33°C.

I2C is meant for communication between chips ON THE SAME BOARD. 10" is a pretty larger board. 10' is a ridiculous size for a PCB.

On the same board, the components are connected by traces, not wire. The wire acts like an antenna, picking up noise.

If you need to have the sensor that far away from the Arduino, that sensor is not the one you want.

fs007

#6
Oct 11, 2012, 03:12 pm Last Edit: Oct 11, 2012, 03:16 pm by fs007 Reason: 1
Quote
And the upper 4 bits of the MSB (or at least the upper 3) don't mean anything, either.

The msb of the first byte is temperature sign, followed by 12 bits of temperature data. The last (lowest) 3 Bits are status bits (that i don't need). Look at the datasheet (-> temperature register).

I used the LM92 with another mcu over a distance of more than 30 feet absulotly reliable. (shielded cable of course)
Are there any experiences about the Mega2560 and it's I2C interface ? Is it possible to use I2C for longer distances ?; maybe with some additional hardware ?

I tried to reduce the wire library's bitrate by editing the line
#define TWI_FREQ 100000L  to
#define TWI_FREQ 25000L
in wire.h, but couldn't see any difference in data reliability. Are there other hacks necessary to reduce bitrate ?

There is another thing, that makes me wonder: transferred data is quite stable (at stable temperature), but a few degrees to high. Doesn't look like the influence of noise etc.

PaulS

Quote
The msb of the first byte is temperature sign, followed by 12 bits of temperature data.

How are you fitting 13 bits in one 8 bit byte?

Quote
I used the LM92 with another mcu over a distance of more than 30 feet absulotly reliable. (shielded cable of course)

Are you still using shielded cable? Are there any changes to the environment? More noise, more electrical activity? What did the code on the other mcu look like?

Quote
Are there other hacks necessary to reduce bitrate ?

Why do you think you need to?

fs007

#8
Oct 11, 2012, 03:29 pm Last Edit: Oct 11, 2012, 03:39 pm by fs007 Reason: 1
Quote
How are you fitting 13 bits in one 8 bit byte?

Not at all. My code:
int lmtemp=0;
lmtemp = ((msb << 8 | (lsb)) >> 3;

I did not program the other mcu, was no Atmel chip.

Quote
Are you still using shielded cable?

I tried shielded and unshielded cable. No difference over 10 inches.

Quote
Why do you think you need to?

I think, less bitrate makes bus-timing less critical. Furthermore there may be influence from SCL with 100khz to SDA when using longer cable.

There is another strange thing: You wrote, Wire.requestFrom would block. When a disconnet the LM92, there is no blocking but msb and lsb are read by Wire.read with 11111111 each.

Go Up