Friday, 12 May 2017

Delay(2592000000);

Now I've placed the orders for all the stuff on my shopping list, I have to wait roughly a month for it all to be delivered from China - for those of you that already know a little C++ Arduino coding, you will recognise the significance of the title above - for the rest of you, it is the command to tell the Arduino to sit around and do nothing... for a MONTH! Ok, ok... if you wanted to get real technical, it probably wouldn't work because the millisecond counter that is used to control delays, runs out of digits after around 9 hours, and resets back to zero, so it would never reach 2.6 billion (or 2.6 thousand million, depending on where you grew up).
edit :  since writing this, I have discovered that the millis count doesn't reset every 9 hours or so as I originally thought - apparently that figure was a throwback to an old version from around 2007!!  The current millis counter will run a little short of 50 DAYS before wrapping around to 0 again - so I COULD create a delay for a month, after all!!
So, being the imaptient soul that I am, I decided to start work on developing my first sketch (that's what an Arduino computer program is called) so I have some practice with the code structure and also using the development interface (IDE).  Here is the inspiration behind it...
One of the things in my scavenger box is a temperature sensor that I recovered from an old piece of computer equipment that died in rather spectacular fashion - it caught fire!  The sensor itself was a remote plug in device used to monitor temperature in another area - so it was not damaged by the fire.
I've dismantled the unit and after some time trying to figure out how the components were connected together, I found the circuit board inside to be relatively simple (at least conceptually).  The key component is an LM35 temperature sensor, and this is sandwiched between a voltage regulator and an op-amp chip.  "Whoa!!" I hear you say... what language is this?  OK, let me explain what I know - which isn't everything.
LM35 sensor annotated_lowres
LM35 Temperature Sensor - this is a device which needs to be fed on a diet of anything from 4 to 30 volts DC, but ideally 5 volts - which is the commonly used voltage for most electronics devices .  It will operate over a range from -55C to +150C.  The device reacts to temperature, and outputs a voltage that is directly proportional to the temperature.  The specs say that the LM35 will put out 10mV (10/1000ths or 1/100th volt) PER degree centigrade.  So if it is 100C, then the LM35 will put out 1 volt.  If it is 25C, then the LM35 will put out 0.25 volts.  How does it measure temperatures below freezing?  This is where the waters get a bit muddy for me, and remember - this is currently all theory with no physical observations or experiments to back it up.  Perhaps it puts out a 'negative' voltage? I am not sure, and for the moment, am not going to stress about it - the part of Australia I live in never experiences sub-zero temperatures, and I doubt I will be putting it in the freezer to test (ha ha, well actually, I almost certainly WILL at some point in the future, out of curiosity, but just not right now).
Voltage Regulator - This device acts a bit like a filter.  It allows you to throw almost any kind of DC voltage at it (within the design constraints of the chip itself), and outputs a nice clean fixed 5 volts DC that the rest of the circuit can use.  So for example, the whole sensor unit could be receiving an unconfirmed and wobbly voltage somewhere around 20-25 volts into the voltage regulator, but we can rely on the LM35 getting exactly 5 volts.
Operational Amplifier (Op-Amp) - I need to research just how these things work, but it is basically some kind of amplifier for the output from the LM35.  You will see from the datasheet, that the LM35 can only supply the output voltage to a maximum of 10mA which is a fairly tiny amount of power - enough to be monitored, but not enough to drive another device.  Since the voltage output of the LM35 is significant, I assume that this amplification step will just increase the available current of the output, as opposed to changing the voltage - but this needs to be confirmed.
Now I understand roughly how it works, I am going to attempt to use the whole sensor unit as it stands with my Arduino, but first, I will run some experiments with it connected to my breadboard, just to confirm it operates as I suspect.  Otherwise, I may just desolder the LM35 from the rest of the board, and use it on its own.
In the next post, I'll describe my first sketch - a Min/Max Thermometer, and how it has developed from my original concept, into something a little more sophisticated.

No comments:

Post a Comment