Interfacing with an MLX90614

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
everest
Posts: 96
Joined: 31 May 2010, 9:01 AM

Interfacing with an MLX90614

Post by everest »

Hi,

My application is going to require me to interface with an MLX90614 sensor from Melexis. The data sheet for this units is here if it's needed:

http://www.melexis.com/Assets/IR_sensor ... _5152.aspx

I'm not an engineer by any stretch, so I'm trying to understand the two options for getting data from the sensor, which are SMBus and PWM. Apparently the unit provides PWM by default on Pin2.

I don't really know what PWM is or how it would interface with my Z24 microcontroller. . .is it a regular frequency that I can read in and measure using the CountTransitions function?

Normally I would experiment first and then post a question, but in this case I need to order some sensors and I'd like to know if this is feasible before I put in my order, and what else (if anything) I might need to order to interface this unit with my Z24.

By the way, I have several Parallax versions of this sensor, but I really need to directly read the MLX90614 because of how I need to mount the actual sensor.

Thanks in advance for any guidance/advice!

-Jeff
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Interfacing with an MLX90614

Post by dkinzer »

everest wrote:I don't really know what PWM is or how it would interface with my Z24 microcontroller.
PWM is a commonly used acronym for Pulse Width Modulation. This is a technique for representing a value using the duty cycle of a square wave, i.e. the amount of time that the waveform is at its "high" level relative to the period of the square wave. For example, if the period is 200mS a 25% duty cycle would be when the signal is high for 50mS and low for 150mS.

One convenient aspect of a PWM signal is that you can pass the signal through a simple low pass filter (series resistor, capacitor to ground) and get an analog signal proportional to the duty cycle. Assuming that you could get sufficient resolution, this may be the simplest way to interface the device to the ZX by way of the ADC.

The datasheet indicates that the SMBus interface is non-standard. From what I gather, SMBus was derived from I2C but differs in some respects. It may be possible to communicate with the device using the ZBasic System Library I2C routines.
- Don Kinzer
everest
Posts: 96
Joined: 31 May 2010, 9:01 AM

Post by everest »

Thank you! Feel free to tell me to pound sand if this is too trivial of a question. . .but could you provide any information on how I might decipher the SMBus protocol? Is there an example of another device communicating with the SMBus protocol to a Zbasic device?

I've found several low pass filter schematics, and that might be the easiest solution here. . .any insight on how to size the resistor/cap would be great.

Again, if these questions demonstrate that this is hopeless for me, just ignore me :)

-Jeff
everest
Posts: 96
Joined: 31 May 2010, 9:01 AM

Post by everest »

Actually, I think I may have answered the question on the reistors/cap values.

http://www.melexis.com/Asset/Analog_vol ... _5176.aspx

That said, it looks like i still have to program the MLX90614 with SMBus to get it configured properly.

-Jeff
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

Here is a device that uses a Melexis sensor in PWM mode: http://www.zbasic.net/forum/about1250.html If you find one of these small IR thermometers, you might crack it open and poke around with a scope to see what PWM looks like.

Having worked with SMBus with LiIon smart batteries, I'd advise you to consider PWM if the sensor can provide what you need with its default options. SMBus should perhaps not be your first comm protocol, IMO.
Tom
everest
Posts: 96
Joined: 31 May 2010, 9:01 AM

Post by everest »

Thanks! That's an interesting project. It doesn't look like he's pulling the PWM data directly from the thermopile, I guess that's not possible without converting it to a voltage.

My problem now is that it seems like the most practical way for me to properly program these little guys is to buy a development board, and I was hoping to avoid shelling out $200+ to program a handful of sensors.

It's quite possible that I'm just in well over my head here :)

I can see why the folks at Parallax took care of all this and build such a nice little package.

-Jeff
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

everest wrote:It doesn't look like he's pulling the PWM data directly from the thermopile, I guess that's not possible without converting it to a voltage.
Well, you could. For example, using InputCapture() you can collect information for a number of cycles and then compute the average duty cycle. There are other ways to "decode" PWM signals using interrupts but the main question is whether any would give better resolution than the ADC method considering the additional resources needed.
everest wrote:My problem now is that it seems like the most practical way for me to properly program these little guys is to buy a development board.
If you have an MLX90614 and would send it to me for a week or so I may be able to figure out how to use the ZBasic I2C routines to talk to it.
- Don Kinzer
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

everest wrote:... pulling the PWM data directly from the thermopile...
No, the data from that project is produced by a processor on the thermometer circuit board; it is a serial bit stream, not PWM, but it is derived from the sensor's PWM signal which is also available as a test point, visible in the photos.

The thermopile itself generates a very small voltage that must be amplified, conditioned and converted (within the sensor body) before it is useful to most of us.
Tom
everest
Posts: 96
Joined: 31 May 2010, 9:01 AM

Post by everest »

Hi Don,

I'm ordering two of these little guys, and I'd be MORE than happy to send you one if you're willing to take a crack at helping me out.

Let me know where to send it and I'll ship it as soon as I get my hands on them.

-Jeff
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

everest wrote:Let me know where to send it and I'll ship it as soon as I get my hands on them.
The mailing address is on the Contact Us page.
- Don Kinzer
Post Reply