HOME - - - - - Lazarus Tutorials TOC - - - - - - Other material for programmers
Delicious Save this on Delicious

Another really, really crude page...

PART 3: Using Lazarus to write software for Dallas 1-Wire MicroLans

This page follows on from my earlier essays telling you how to use the Dallas 1-Wire chips (via the TMEX support SDK) WITH LAZARUS.

It follows on from dstl2hello_ds18b20-pt2.htm

It is BETTER in that the program is more "polished", more "complete", "better written".... But it is WORSE because the BASICS of using the 1-Wire chip are less obvious.

The earlier essays give more help with "What *IS* 1-Wire?" "What is it good for?".. and how does the programs I have provided work. This installment gives you almost no help... other than to say that THIS version of the software doesn't actually do much DIFFERENT... it just does it differentLY. The 1-Wire stuff has been "taken away", and "hidden" in a support unit. Not perfectly! Any you do need to understand Units and User Defined Records. (They are a bit headache inducing at first, but WELL WORTH the effort. They make creating a program in "layers", and make passing stuff back and forth from routines easy... a bit like VAR parameters, but more capable.) But the earlier versions of the software were only fit for getting your head around how interacting with the 1-Wire chips WORKS. This version begins to move towards something usable.

And again... Lazarus SOURCECODE provided...

There is a free zip archive with the sourcecode! (You may find many sections of the code "folded"... just click the little +/- indicator in the left margin. Collapsing "stuff" helps you focus on the parts which are currently of interest.)

FIXED since LDN031, the code supplied with part 2 in this series: If the values for PortNum or PortAdapter in the ini file do not match the hardware you are using, you can now fix that easily, with the application's normal flow.

This WEBPAGE, so far, is a pretty poor dog's dinner. Download the sourcecode. Play with that.

I used 1-Wire with Delphi for many years, so was disappointed when Borland/ Embarcardo/ whatever they are called this week shut the hobbyist out of Delphi... and proportionately delighted when Lazarus came along. I've been using it for some time now, no regrets.

So the day came when I wanted to "do" 1-Wire... from Lazarus!

1-Wire isn't for the faint hearted... but it WILL reward you, if you make the effort.

But you DO depend on some code supplied (free) by Dallas. (Dalsemi/ Maxim... whatever THEY are called this week.

In particular something that started as a unit for Delphi, but WHICH WORKS WITH LAZARUS... if you poke one simple little line into it.

The code is in iBTMEXPW.pas.

To use it with Lazarus, the simple (if clumsy and inefficient) way is to put a copy of it in each project's main folder. The folder with the app's main unit's .pas file.


{$mode delphi}//Added by ((insert your name))

... right at the top, just after the "Unit iBTMEXPW;" line.

(You don't... why would you? (But given that I wondered, maybe you will)... need to put the {$mode delphi} into anything else needed by this.)

Jumbled info, to be hammered into a proper web page in due course...

LDN032... the software that comes with this (see above for download link... the link gives you .exe AND all the sourcecode... is an evolution of LDN031.

If what is in LDN032 baffles you, and you have some experience of 1-Wire and Lazarus, start with the read DS18B20 with 1-Wire tutorial for LDN031.

If you are just getting started with 1-Wire or Lazarus, start with that and the tutorial for LDN030 which goes more slowly, explains more.

LDN031 is not greatly changed from LDN030 in terms of what it can do, or even, particularly, in how it does it. But it is, I hope....

More "user friendly" (at cost of some overheads)... in particular, the code doesn't have to be re-written to change chip ID, port number, adapter type... these are set in an ini file which is managed by the program.

It's been "tidied", and made "more elegant"... if less pedestrian/ obvious. "Stuff" has been parceled into SRs.

A start has been made towards using sub-units. Imperfect... but a start.

To pass complex results between main unit and sub-unit has involved using user defined records. Don't let them scare you... they aren't too bad. See my tutorial on user defined records.


Sorry there are so many rough edges... in the tutorial. THANK YOU for whatever effort you have put into reading it. Emails (see below) would encourage me that SOMEONE (besides me) wants to do 1-Wire with Lazarus, and I might put even more time into this. The code in the zip archive DOES WORK... as long as you put valid values for what is connected to your computer into the edit boxes for Adapter Type, Port Number and ChipID.

But... despite all of the above whining... WHEN YOU KNOW HOW... 1-Wire is a delight, and not TOO difficult! And it WORKS with Lazarus, hurrah! (Well, seems to so far. Early days.)

   Search this site or the web        powered by FreeFind
  Site search Web search
Site Map    What's New    Search   BEWARE: There is stuff at my other two sites that this search won't reveal. Go to either site (see links below) and use that site's FreeFind search button.

In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful.....

Sheepdog Software homepage.
My Arunet homepage.
... and some links to specific pages within them you might want....

Main index to MicroLan stuff.
Some pages for programmers.
Using the parallel port with programs written in Delphi.

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to Tutorials main page
Here is how you can contact this page's author, Tom Boyd.

Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....