Interfacing MLX90614 with AT90CAN128 AVR...
CastonjoFfF
Posts: 3
Hello to all,
I am trying to figure out how to interface MLX90614 with the AVR microcontroller and I am a bit confused.
What I want to achieve is (using 4 MLX90614 and 2 AVRs):
i. put 2 of these sensors on the same I2C bus, set them to continuous data reading (the default command on power up) at 50ms (also, the default value) and read the values of sensor's RAM address $07 whenever it's possible (meaning that the AVR will run several codes for other sensors/functions and there will be no constant period of reading), AND
ii. put 2 of these sensors on two general I/O pins, set them to continuous data reading and output at 1ms and read every value of them.
About configuration i
First of all, it's not really clear to me if an I2C communication is possible. Besides the communication protocol described in mlx90614 datasheet (and using the commands of the form "!TEM...") I read in the datasheet that "The READ and WRITE commands conform to those indicated in the MLX90614 datasheet for writing to the SMBus, an I2C style format.". Does that mean that we can avoid using Parallax's communication protocol (using "!TEM...") and instead of that asking through standard I2C protocol the values of RAM address $07? If yes, is the procedure the following one?
1. send the START condition,
2. send the slave address ($5A) + WRITE,
3. send the register to read ($07),
4. send RESTART condition,
5. send the slave address ($5A) + READ,
6. read low byte and send ACK,
7. read high byte and send ACK,
8. read PEC and send NACK, and
9. send STOP condition.
About configuration ii
Firstly, I have to program the sensor to send continuously tha data every 1ms. Is this done in the following way?
create the array [noparse][[/noparse]0,"!TEMc",$5A,$07] and send it to SIG pin of MLX90614. Are the characters ',', '"' and '$' needed to be sent? Assuming that ',' and '"' don't have to be sent, what I understand is that I have to send the following bits (ASCII values of the array's characters): [noparse][[/noparse]0x30 0x21 0x54 0x45 0x4D 0x63 0x24 0x35 0x41 0x24 0x30 0x37] (which equals to [noparse][[/noparse]0!TEMc$5A$07]). Is that right? So, let's say I choose 38.4K BaudRate I have to write sequentially 0 or 1, for 1/38400s, forming the above ascii values' array.
Secondly, I change the pin from output to input and wait for the sequence "TEM", which indicates the start of the transmitting data, then read $5A, low byte's value, high byte's value and pec's value. And all the transmitting bits will change in the same 1/38400s period. Every 1 ms I will receive the updated values.
I would really appreciate it if anyone could reply to any of the above questions, or commenting on anything related to MLX90614 and the way I'm thinking to use them.
With Respect,
Giorgos
I am trying to figure out how to interface MLX90614 with the AVR microcontroller and I am a bit confused.
What I want to achieve is (using 4 MLX90614 and 2 AVRs):
i. put 2 of these sensors on the same I2C bus, set them to continuous data reading (the default command on power up) at 50ms (also, the default value) and read the values of sensor's RAM address $07 whenever it's possible (meaning that the AVR will run several codes for other sensors/functions and there will be no constant period of reading), AND
ii. put 2 of these sensors on two general I/O pins, set them to continuous data reading and output at 1ms and read every value of them.
About configuration i
First of all, it's not really clear to me if an I2C communication is possible. Besides the communication protocol described in mlx90614 datasheet (and using the commands of the form "!TEM...") I read in the datasheet that "The READ and WRITE commands conform to those indicated in the MLX90614 datasheet for writing to the SMBus, an I2C style format.". Does that mean that we can avoid using Parallax's communication protocol (using "!TEM...") and instead of that asking through standard I2C protocol the values of RAM address $07? If yes, is the procedure the following one?
1. send the START condition,
2. send the slave address ($5A) + WRITE,
3. send the register to read ($07),
4. send RESTART condition,
5. send the slave address ($5A) + READ,
6. read low byte and send ACK,
7. read high byte and send ACK,
8. read PEC and send NACK, and
9. send STOP condition.
About configuration ii
Firstly, I have to program the sensor to send continuously tha data every 1ms. Is this done in the following way?
create the array [noparse][[/noparse]0,"!TEMc",$5A,$07] and send it to SIG pin of MLX90614. Are the characters ',', '"' and '$' needed to be sent? Assuming that ',' and '"' don't have to be sent, what I understand is that I have to send the following bits (ASCII values of the array's characters): [noparse][[/noparse]0x30 0x21 0x54 0x45 0x4D 0x63 0x24 0x35 0x41 0x24 0x30 0x37] (which equals to [noparse][[/noparse]0!TEMc$5A$07]). Is that right? So, let's say I choose 38.4K BaudRate I have to write sequentially 0 or 1, for 1/38400s, forming the above ascii values' array.
Secondly, I change the pin from output to input and wait for the sequence "TEM", which indicates the start of the transmitting data, then read $5A, low byte's value, high byte's value and pec's value. And all the transmitting bits will change in the same 1/38400s period. Every 1 ms I will receive the updated values.
I would really appreciate it if anyone could reply to any of the above questions, or commenting on anything related to MLX90614 and the way I'm thinking to use them.
With Respect,
Giorgos
Comments
Parallax's examples are for their Stamp controllers. The text inside the quotes is sent literally. The numbers separated by commas are the values of individual bytes. The '$' is the introducer for a hexadecimal constant like '0x'.
let's make it clear, to see if I got it right.
The command "SEROUT pin, baudrate,[noparse][[/noparse]0,"!TEMc",$5A,$07]" that is used with STAMP controller is equal to sending serially the following bytes:
1. 0x0 --> for 0 (and not 0x30, which is the ASCII value for 0, that I wrote before),
2. 0x2C --> for the comma (as I understood from your reply the coprocessor on the module expects the comma, am I right?),
3-7. 0x21 0x54 0x45 0x4D 0x63 --> for !TEMc (as I understood from your reply '"' doesn't have to be sent),
8. 0x2C --> for the comma,
9. 0x5A -->for the byte that is expected as the module's address (and not 0x24 0x35 0x41, that I wrote before, which are the ASCII values of $5A),
10. 0x2C --> for the comma,
11. 0x07 --> for the byte that is expected as the RAM address.
Am I right or not?
Also, what, also, confuses me is the auto-BaudRate detection. I read in the datasheet that "The baud rate is always a variable or constant value for 2400, 4800, 9600, 19.2K or 38.4K baud." and also that the module is capable of auto-baud detection.
Does that mean that I can use any baud-rate that I want or only one of the 5 fixed given values? And if the last is true, what means "is always a variable OR constant value..."? If I can use whichever BaudRate which is the maximum value?
With Respect,
Giorgos
The comment about Baud relates to the Stamp I/O statements. The paragraph on the top of page 4 of the Parallax documentation indicates that you should hold the serial line low for a short time (roughly a character time at the Baud to be used), then the exclaimation point character that begins the command will specify the Baud to be used until the next "hold the serial line low" is done (by sending the zero byte). I don't know whether the Baud has to be a power of 2 of the base Baud (2400) or can be any Baud in that range. Some auto-Baud routines use the start bit of the first character as the time standard, others pick the closest Baud from a list. You're safe if you assume that it's a power of 2 multiple of 2400 Baud.
i am also interfacing this module with PIC18f4550.
i implemented uart on GPIO of PIC18 at the baud rate of 4800...
but the problem is that how should i send the command read to MLX module from PIC.."""SEROUT pin, baudrate,[noparse][[/noparse]0,"!TEMR",$5A,$07]""
what would be the orientation of code..
first send 0 or ASCII of 0...
then transmit "!TEMR" as a string or the asciii code....
then $ as a character or the equilent hexal value of it...
then 5A as a character or 0x5A.......
then again $ and 07.....
thanx
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
so how much distance should i keep of the module from the object....
....
2nD::::: i got some reading from the module but some time it does't response to the command of "!TEMR".
so for this i have to reset the MLX96014 module by removing its power....
its the problem in the coding or its necessary to reset the module...