Magazines:  Real Estate Shopping: Adult Costumes  |  Kids Costumes  |  Car Books  |  Guitars |  Electronics
This Issue Archived Articles Blog About Us Contact Us
SEARCH


eLabtronics EZ System, Part 3

Building a programmable temperature alarm

by Julian Edgar

Click on pics to view larger images

At a glance...

  • Revolutionary new electronics system
  • Assumes starting point of zero electronic and programming knowledge
  • Make your own electronics for automotive, model railways, renewable energy, alternative powered vehicles and lots more!
  • Off-the-shelf programmable electronic modules and easy to learn software
  • Very low cost
  • This week: building a programmable temperature alarm - the software
Email a friend     Print article

Click for larger image

Last week in Part 2 we used ezCircuit Designer software to do the on-screen wiring of our temperature alarm....

Click for larger image

..and then we physically wired-in the battery pack, temperature sensor and buzzer. (All the components are available in the eLab6 EZ Starter Kit that with the eLab6 module, costs AUD$44.50 + GST.)

Now it’s time to write the software that runs the temp alarm. Don’t worry – you don’t need any existing computer programming skills!

Note: this story assumes that you have read and understood the previous parts in this series. If you haven’t done this, it’s unlikely you will achieve success with the following project!

Flow Chart

Before we get into the software writing, let’s think again about what we want the temp alarm to do.

Click for larger image

This flowchart shows the approach. We need to:

(1) Monitor the temperature sensor

(2) Compare the measured temperature with the internal set-point (the set-point is the temp we want the module to remember)

(3) Turn on the buzzer if the temp is above the set-point

That’s the flowchart that will underpin the ezCoreChart software that we’ll now build.

EzCoreChart

Click for larger image

The first step is to open ezCircuit Designer and then, if our Temp Alarm doesn’t appear on-screen, to open our saved file.

Click for larger image

Press the button shown here by the arrow, and ezCoreChart will open. (If it doesn’t open, you may not have downloaded and installed ezCoreChart. Go to eLabtronics for this software.) By opening ezCoreChart from ezCircuit Designer, all the information you’ve put into ezCircuit Designer is transferred across to the new program.

Click for larger image

The beginning of the flowchart (the software program that will run our Temp Alarm) is shown here highlighted within the red oval. As you can see, a test program for the buzzer comes up automatically. However, because we’re so confident, we don’t need to take this step. To get rid of the ‘BuzzerTest’ box, click on it once and then press the ‘Delete’ button at the top right. ‘OK’ the pop-up box and then the buzzer test box will be gone.

Click for larger image

The screen will now look like this.

Click for larger image

You might remember that when we thought of how a temp alarm would work, we said that the first step was that the module would need to monitor the temperature sensor, and how this was an input. Click on the Input box ...

Click for larger image

...and down below in the Icon properties box will appear AnalogConv, as highlighted here in red. ‘AnalogConv’ means ‘analog conversion’ and what that means is that this software box allows the ‘brains’ to understand any variable voltage signal within the range of 0-5 Volts. (Voltage is like electrical pressure.)

So by using this icon, the electronic module will recognise the output of an appropriate temperature sensor, light sensor, pressure sensor (etc), or in fact any signal that varies within the range of 0-5V (eg in a car, an airflow meter or MAP sensor).

Click for larger image

Click on AnalogConv and then move your cursor across to directly underneath ‘Start Main’ oval. By then clicking at that spot, an AnalogConv icon will be inserted in the software flowchart – as shown here.

Click for larger image

Now we need to configure the AnalogConv icon. Double click on it and a box pops up. There are two user-definable elements – the Source and the Destination.

‘Source’ means: what input is the AnalogConv supposed to be looking at? By accessing the drop-down menu at Source, TempSensor comes up – so select that. (This label is available because you already wrote it in ezCircuit Designer!)

The default Destination is ‘Result’ – you can leave this as it is. Incidentally, you can at any time check the settings of AnalogConv icon by double clicking it.

So in this step we have configured the microcontroller to look for TempSensor on the pin to which we’ve already connected it, and then to call this reading the ‘Result’. The next step is to compare the Result with an internally set value.

Click for larger image

Click on Numbers, then select Compare. Place the Compare box directly beneath AnalogConv, as shown here.

Click for larger image

Double clicking on the inserted Compare box brings up these options. You can firstly select the Source (use the drop-down menu to select Result (which is what we just said the output of the AnalogConv was called), and then type in the number you want the temp switch to trigger at. So how do you work out that number?

The temp sensors supplied in the EZ Starter Kit have an output of 10 millivolts per degree C and work from minus 40 to plus 125 degrees C. (Note: there are 1000 millivolts in a volt.) However, rather than start at 0 volts at 0 degrees C (which means the sensor wouldn’t be able to work at freezing point as there’d be no signal output to measure!), the sensor at 0 degrees C has an output of 500 millivolts. (This is called a 500 millivolt offset.)

So if you want the temp alarm to trigger at 40 degrees C, you do this calculation for the set-point: 40 degrees C x 10mV = 400 mV, plus 500mV (the offset) = 900mV, or 0.9 volts. So for a 40 degree set-point, you type in 0.9.

If you wanted the sensor to trigger at 0 degrees C, the calculation would be 0 degrees C x 10mV = 0, plus 500mV = 500mV, or 0.5V.

If you wanted the sensor to trigger at minus 10 degrees C, the calculation would be minus 10 degrees C x 10mV = minus 100, plus 500mV = 400mV, or 0.4V.

If you’re sitting in a room at normal temperature, set the value at 0.7, which corresponds to 20 degrees C.

But there's one further tricky bit. The above calculations are correct if the module is being powered by 5V. If it's being powered by 4.5V (ie three 1.5V cells) then the temperature set-point will be lower than indicated.

OK, so we have the temperature trip point number written in the software – so what’s next?

Click for larger image

You can now select Above, Below or Equal, depending on whether you want the output to trigger above, below or equal to the selected value – in this case, tick ‘Above’. Leave the hysteresis slider as it is.

Click for larger image

After you’ve done the above step, you’ll see the software automatically adds a whole lot more boxes to the program, as shown here. But there’s no need to panic – just look at the box labels. Directly under Compare is ‘If above’. In this box is ‘Y’ for Yes and ‘N’ for No. If the value read from the temp sensor is above the value you’ve set, the program flow diagram moves in the ‘Yes’ direction. If the value read from the temp sensor is below the value you’ve set, the program flow diagram moves in the ‘No’ direction. Let’s do the Yes first.

Click for larger image

We know that if the temp is above the set-point, we want to turn on the buzzer. Click on Outputs at the top-right of the screen, and then select ‘OnOffPin’. Place OnOffPin under Y (for Yes). The screen should then look like this.

Click for larger image

Double click on OnOffPin and this box will pop up. It shows that the Destination is the Buzzer (great, that’s what we want!) and that the buzzer will be switched on. That’s all fine; we don’t need to make any changes so just press OK.

Click for larger image

So let’s take a step back. From the top of the program, we use AnalogConv to recognise and import the temperature sensor reading. In Compare we then compare that temp value with an internal set value (the value that is memorised). If the temp is above the internally set value, we turn on the buzzer through the use of OnOffPin.

Then the program finishes.

Hmmm. The fact that it finishes means that the program will work only once – not what is wanted! In fact, what we need to do is loop the running of the flowchart (ie the program) around to the beginning, so it keeps on going on and on and on (and...). We do this in two steps.

Click for larger image

Firstly we insert an ‘Address’ box immediately after Start Main...

Click for larger image

...and then we insert a GoTo just before the End Main box. The program then jumps back to Address whenever it reaches GoTo. Therefore, whenever power is switched on, the program goes round in an endless (and very fast!) loop.

Click for larger image

But there’s one final problem. Once the buzzer gets switched on, what switches it off? The program loop can keep on running but the buzzer, once it has triggered for the first time, will stay triggered. To overcome that problem, we insert an OnOffPin as shown here and then set its output to Off. That way, the buzzer will stay off until it is deliberately switched on.

Have a good look at the program, running through the functions of each box in your head. If you need to be reminded of what each box does, double click on it. It’s really important to ensure that the program makes sense to you. You don’t want to look at the screen and see just a bunch of coloured boxes; you want to see a logical flow diagram that switches on the buzzer when the temperature is above the set-point you’ve specified.

If all is OK, click on File and then save the program using an appropriate name.

Programming the Module

Transferring your newly written program to the eLab6 is done in this way. The module is left switched off during the programming procedure.

Click for larger image

Plug the programming cable into the Programmer and then the USB port. The Programmer’s yellow LED should light. Then plug the programmer into the eLab.

Click for larger image

Press the ‘Send Program to Chip’ button. The software will ask if you want to save the program (you do) and then a box will come up showing the programming status. At the end you’ll see a green bar and the words ‘write successful’.

Unplug the programmer and then the Temperature Alarm is ready to be tested.

Testing

When you turn on the eLab6, and if it’s above 20 degrees C, the buzzer should sound. (If you can hear the buzzer only very faintly, take off its paper seal.) By applying ice to the sensor, you should be able to make the buzzer turn off.

If the Temp Alarm doesn’t work, check:

  1. That the wiring of the module connections (the temp sensor and buzzer) are as shown in ezCircuit Designer.

  2. The software program, especially ensuring that the AnalogConv has TempSensor selected as the Source, and OnOffPin has Buzzer selected as the Destination. Also ensure that the selected temp trip-point corresponds to a temperature range that is appropriate for how you are testing.

  3. When programming the module you get the green bar at the end of the programming process.

Click for larger image

When the system is working correctly, try changing the selected trip-point temp value in the software. Reprogram the module and check that the change is effective.

Click for larger image

You can also alter the program so that the buzzer operates when the temp is below the set-point. Alter the tick box in the Compare icon...

Click for larger image

...and then insert an OnOffPin below ‘If below...Y’ as shown here. Then send the new program to the module.

To alter the output from being a buzzer to a LED, you don’t need to make any software changes. Just select a LED from the eLab6 EZ Starter Kit and wire it in place of the buzzer, with the white wire to Connector 2 and the black wire to (-).

Conclusion

ezCoreChart allows the very quick and simple assembly of programs that can achieve real outcomes. The Temperature Alarm shown here can be used for:

  • Frost alarm

  • Greenhouse temp alarm

  • Solar water heater monitoring

  • Intake air temperature alarm

  • Oil temp alarm

  • Coolant temp alarm

  • Amplifier or computer temp alarm

...and many other uses. The temp sensor can work in free air or be potted in epoxy for use in fluids. The wires to the temp sensor can also be extended as required.

Next week we’ll add an external pot that lets you easily adjust the trip-point, and do some very tricky things by using two temp sensors rather than just the one.

Contacts

Contact: www.elabtronics.com

ezCircuit Designer - http://www.elabtronics.com/products_cat_ezCircuit.htm

ezCoreChart - http://www.elabtronics.com/products_cat_CoreChart.htm

Download the ezCoreChart Temperature Alarm softare program below:

Go here for the next in this series.

Did you enjoy this article?

Please consider supporting AutoSpeed with a small contribution. More Info...


The following downloads are available for this article:

Share this Article: 

More of our most popular articles.
Looking at the future of hydrogen-fuelled cars

Special Features - 28 April, 2009

Will Hydrogen Happen?

The story behind the Datsun 240Z

Special Features - 16 July, 2008

The First Zed

Peak boost in one-third of a second!

Technical Features - 5 October, 2010

Is This Your Electric Supercharger?

How Chrysler developed a 2.4 litre turbo

Technical Features - 5 July, 2003

Designing a Factory Turbo Engine

Do-it-yourself aero testing of the Mazda RX7

Technical Features - 11 July, 2007

Aero Testing, Part 5

A breakthrough car that proved to be a step too far

Special Features - 6 August, 2008

The NSU Ro 80

How the air moves under a car

DIY Tech Features - 9 March, 2005

Modifying Under-Car Airflow, Part 1

Single-handedly erecting the framework for a home workshop

DIY Tech Features - 26 August, 2008

Building a Home Workshop, Part 3

Building a programmable temperature alarm

DIY Tech Features - 13 October, 2009

eLabtronics EZ System, Part 2

A very easy way of comparing spring stiffness between different cars

DIY Tech Features - 17 September, 2013

Measuring wheel suspension rates

Copyright © 1996-2017 Web Publications Pty Limited. All Rights ReservedRSS|Privacy policy|Advertise
Consulting Services: Magento Experts|Technologies : Magento Extensions|ReadytoShip