LV-168 temperature sensor and switch?

The new LV-168 is an admirable creation but I am puzzled by the mysterious temperature sensor. The schematic doesn’t identify the chip and I haven’t been able to find mention of its nature in the supplied demo code.

After powering up the LV-168, the display reads “tmp= 188”. After breathing on the board, the reading increases to about 200 then drops slowly back to 188. What might be the conversion factor and offset to arrive at a more familiar temperature scale?

Looking at the test code, the sensor output appears to be read by an ADC channel and 2048 successive readings are summed, followed by a right shift of 11 bits to average them. For a 16 bit integer, this leaves 5 bits for the average, allowing a maximum value of 32 for each reading (on average). Thus, it is hard to see how a value of 188 can result from the above manipulations. Why are so many ADC readings averaged? Hopefully, one of the Pololu engineers can enlighten us.

Finally, the on-board power switch IC (also unidentified on the schematic) has a shutdown pin, labeled “shut down”. Is this connected to the plated-through hole labeled “off” and if so, what are the electrical characteristics of the input and what signal should be used to implement an external shutdown of the LV-168?

Lovely LED indicators!

Regards, Jim

Hello, Jim,

The temperature sensor is Microchip’s MCP9701; I have added the datasheet to the resources tab. Ben made the sample programs, so he should be able to answer your other question tomorrow.

The “off” pin is the shut down pin, which will turn off the whole board if you connect a few volts to it. The pin is connected to the base of a transistor through a 10k resistor; the base also has a 10k pull-down on it. Typically, the pin would be connected to an I/O line that could be driven high to turn off the robot. This could be desirable in conjunction with battery level monitoring to prevent over-discharging batteries (such as Li-Poly units that might otherwise be damaged).

The power circuit is not shown in the schematic because it is a design that we were considering patenting. We’ve since filed for the patent, and we are debating revealing the design before we find out how that goes (which could be years). We should also have some stand-alone versions of the switches available next week.

- Jan

Hi, Jim.

The ADC sum is being stored in a four-byte unsigned long, so it has the capacity to store the sum of 2048 10-bit values without overflowing. I don’t remember exactly why I chose to average so many values, but I believe the motivation was to achieve a good LCD update rate (i.e. quick response but low flicker). When using an ADC clock of 20MHz/128, 2048 readings should take approximately 170ms. I probably was shooting for updating the LCD five times per second and figured I might as well be using the ADC the whole time. I could have accomplished the same thing by taking 10 readings followed by a delay_ms(200), but for some reason overkill seemed like the more interesting (and, unfortunately, probably more confusing) approach.

- Ben

Thanks, Ben:

I overlooked the “long” declaration for the variable “sum”.

I’ve never paid much attention to the ADC noise reduction techniques discussed in the atmega data sheets, but will do so. It would probably be more efficient to follow Atmel’s recommended procedures than to average 2000+ readings!

[Edit] This morning upon power-up the temp sensor read 170 for a room temperature of 22.6 C as measured by an accurate thermometer. From the data sheet, the sensor offset is 0.400 V and the calibration is 0.0195 V/degree C. Vcc on my board is 5.04 V. So, the temperature is ((5.04*170/1024 - 0.400)/0.0195) = 22.4 C. Fair enough!

Given that the MCP9701 sensor has a specified maximum error of +/- 2 C (typically +/- 1 C accuracy), with integer math the above equation simplifies to

temp_in_C = (ADC>>2) - 20;

which gives 22 for the above example. However, the ADC reading drifts up to 180 (25 C) after just a few minutes, indicating that the PCB heats up even with no motors connected.

Jim

Hmm, having the demo program display the temperature in C would probably be a lot more understandable and useful for people than simply displaying the raw sensor voltage. I’ll change the test demo to perform the Celcius conversion.

- Ben