Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Interfacing / Re: Melexis SMBus IR Thermometer - NFI on: November 20, 2010, 04:37:48 pm
The errors indicate that - for some reason - your compiler cannot find the library you are trying to use.


First, I suggest that you try to place the "#include <i2cmaster.h>" line before the other includes as sometimes small things have surprisingly big consequences..


Second, you should recheck (once more) that you have put the "twimaster.cpp" and "i2cmaster.h" files it in a right place (i.e., /{arduino root}/hardware/libraries for older Arduino sw, /{arduino root}/libraries for the newer ones).

Inside the correct library folder you should see other folders, for example, "Servo", "SorftwareSerial", "Wire", etc.. I named my folder as "I2Cmaster" and put the two files inside that.

After that YOU HAVE TO create a separate file called "keywords.txt" inside the very same folder. You can copy/paste the lines that I have in my keyword file at the end of this post. Without this file the Arduino software cannot automatically figure out what you've defined in your library.. A bit stupid, yes, but that's the way it's done. The Arduino environment has to be closed (if running) as it is documented to find the new stuff only when started.


Given just a quick glance the code otherwise seems valid although it does not really show neither the readMLXtemperature(int) function nor where you call it. Just to check the other part of the code you can comment the function and the library include to see if it otherwise compiles ok.


Code:
#######################################
# Syntax I2Cmaster
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

#######################################
# Methods and Functions (KEYWORD2)
#######################################
i2c_init            KEYWORD2
i2c_stop            KEYWORD2
i2c_start            KEYWORD2
i2c_rep_start      KEYWORD2
i2c_start_wait      KEYWORD2
i2c_write            KEYWORD2
i2c_readAck            KEYWORD2
i2c_readNak            KEYWORD2
i2c_read            KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################

2  Forum 2005-2010 (read only) / Interfacing / Re: Melexis SMBus IR Thermometer - NFI on: November 13, 2010, 05:26:42 am
My first post to this forum..
I just wanted to share my solution for the problem I and several others seem to have faced when trying to interface with the MLX90614.

I first tried everything suggested in this thread, then googled through a loads of other sites and forums, and also browsed through an extensive amount of documentation and other material provided by Melexis web site. I tried virtually everything without success and finally returned back here..

First of all, lots of thanks for Sensorjunkie, his(?) instructions really work if you just follow them (and adapt a bit if you are using newer version of Arduino software - mine is the Arduino 0021 which is the latest one at the moment).

Below are some comments/details/minor adaptations to Sensorjunkie's instructions..

1) Connect as instructed (if you haven't changed the pins, of course)
SCL --> Analog5
SDA --> Analog4
Vdd --> 3V3
Vss --> Gnd

_AND_ (this is really important!)

Use two 4K7 (4.7 KOhms) resistors to physically pull-up the SCL and SDA connecting them to Vdd on the breadboard. THIS was the reason why the connection to my sensor could not be properly started. So the analog-pull-up-PORTC-stuff on the code is definitely not enough to make things work.

2) Download Peter Fleury's nice library...

BUT place it under /{arduino root}/libraries/"what-ever-folder" where the current Arduino software looks for the libraries when started. You also have to rename the "twimaster.c" to "twimaster.cpp" as instructed so that Arduino can build it when launched. You also have to create a "keywords.txt" file inside the "what-ever-folder" where you define the library functions (function names and KEYWORD2 only). Without doing this Arduino cannot find and build the library. You can copy and edit the keyword file from some other library or see some help at Arduino's LibraryTutorial (Sorry, but it seems I cannot mail any links - just google for it..)

3) Modify the twimaster.cpp to reflect the Arduinos 16 MHz clock (I have Arduino UNO & Duemilanove with ATMEGA 328P). You can also scale down the speed of the SMBus to 50 KHz as instructed but mine works just fine using the 100 KHz as well. Generally, I think they suggest selecting anything b/w 10 to 100 KHz for SMBus rate.
 F_CPU 16000000UL
 SCL_CLOCK 50000L // or 100000L
Don't otherwise touch the code if you don't really know what you are doing..

4) Now just copy Dave Eaton's code (and remember to mention him in your file:) and it should work like a charm. I adapted the code by Martin Nawrath (Google for "Nawrath MLX90614"..) that gives you also the ambient temperature values (i.e., the temperature of the sensor itself). But you can also add that part to Dave's code as well.

Some other points:
 - you can use either the general device address 0x00 that works for all MLX90614 sensor models or the address of the specific sensor sub-model you have (0x5A in my case)
- remember to do the "<<1" operation for the address as its not done automatically by the twimaster library
- use 100nF capacitor (I use metallic film capacitor of type 104) between Vdd and Vss to minimize the power supply noise (keep the leads as short as possible between the pins)
- the addresses for object temperature (0x07) and ambient temp (0x06) are correct
- you cannot use the Wire library to interface with the SMBus protocol of the sensor, it just doesn't work

That's my two cents.. I hope this helps you to take most of the sensor.
Pages: [1]