As the test iron will be used standard BLE400 with microcontroller nRF51822 on board. For programming I'll take JLink. Well and for debugging the logical analyzer is useful.
To create a full-fledged driver, we need to isolate from the specification what options and options are available from our device to render them in the driver option. So it is necessary to determine the protocol of data exchange. In general, we look at the specification.
So there are different variations of this sensor. The concrete variant is set by the marking on the body. Type MLX90614ESF-BAA-000-TU. We are interested in the first letter after the sensor name - in this case E, as well as the first two letters of the three-letter code in the middle (BAA), since they affect the characteristics of the device (supply voltage and number of thermocouples). Apparently they will have to take out the settings. But not fact - just put it in memory.
My copy by the way some kind of anything - the mark is completely incomprehensible B89736X16E. The only information on it was found in the Chinese forum, and even then it is a discussion of the type "does anyone know what the marking is?". Tried to find where I bought it, but in vain - this information has already sunk into oblivion. But on it there is a letter Bfrom which I can conclude that this is a sensor with 3 volt power. Although judging by the specification and 5 volts for it are not fatal. In the end, this assumption was correct.
Data is transmitted either via SMBus or via PWM. There is a thermal relay mode, when the temperature range is set, and the sensor only signals when the temperature exceeds the specified limits. The operating mode of the measurement / relay, as well as the data transfer mode, we also take in the driver settings.
Aha! We read the specification further and see that the device is controlled by writing data to the EEPROM using SMbus. We have 32 2-byte words available. But most of them are not used. Also there is RAM with read-only access to 32 17-bit words.
Well - we will understand. In general, SMBus is mandatory, but the PWM mode is optional. Support SMBus by the way truncated - only 2 commands are supported - to write down a word and read a word. The frequency of the bus from 10 to 100 kHz.
So we have the following settings:
SMBUS / PWM / RELAY operation mode
Number of sensors 1 or 2
The supply voltage is 5V or 3V (some functions depend on this)
But in the end, running ahead, I will say that while for the demonstration I decided to limit myself to the minimum set - reading the temperature through SMBus. For demonstration and for my purposes this is still enough, but there will be a mood to add functionality is never too late.
What is the next plan?
Obviously, the sensor work is strongly tied to the SMBus. But as we know SMBus and I 2 C twins, take, so try to use the I 2 C capabilities for communication with the sensor , especially since the controller selected for development has hardware support for this protocol.
Well, the next step is assembling a test layout, creating a driver blank, and writing a test application to read and display the temperature from the sensor. In general, everything is simple.
We collect the stand
In general, for experiments, I chose the BLE400 board, to which I connected a bradbord with a sensor, and I was hooked up to them by JLink and the SaleaLogic analyzer (I have it without a case for the Chinese body collapsed on the first day - what a shame). Well, to save on the wires (so as not to pull this bundle of wires to the laptop), all this is connected via a USB hub by specially bought stubs of USB cables. It turned out something like this:
Working layout for debugging the sensor
Pinout of the sensor - in the specification the diagram is not quite clear, therefore I will give here a more understandable photo:
The sensor itself stuck into the connectors of the connecting wires bluntly, having previously soldered on it thicker legs from the combs (it was previously in the board, was taped through the converter of the level, since the previous article was powered by 5V, and the sensor was a 3-volt well, shortish).
Connecting the MLX90614 The result
While I decided to finish this article and go on to programming in the next one - somehow I get a lot of stuff and do not want to shove everything in one heap - and so the article turned out to be somewhat chaotic. In general, in the end, decided what to do and how, collected all the iron - then go nearer to the point.
Sources of information