CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account

July 14, 2009 by robert Leave a Comment

Delphi Interface Example

A customer was kind enough to share an example project for the U401/U421 centered around the 1-wire temperature device. The project was written in Delphi and is available for download (source and executable) here: https://www.circuitgizmos.com/files/u401delphi.zip

You can get the DS1822 from CircuitGizmos along with the U401 USB Interface and the U421 USB interface

2009-07-14_180854

Program and example features:
Port A is INPUTPort
A.7 is set for DS1822.
Port B is OUTPUT
Programmable scan rate
Programmable temperature threshold controls PortB.1
Option to log data to a local file
Optional choice of units
On-Demand temperature read

The example code is very readable, even if you don’t know object pascal. You can see just in this small part of code that reading a 1 wire device only takes resetting the bus and a few read and write commands. Easy-peasy.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<span style="color: #008000;">
    // Reset device
    USBm_Reset1Wire( dev, pin );
 
    // Write "SkipRom" and "Conversion"
    USBm_Write1Wire( dev, $CC);
    USBm_Write1Wire( dev, $44);
    sleep(100);
    pin := $7;
    USBm_Reset1Wire( dev, pin );
 
    // Write "SkipRom" and "Read Scratch Pad"
    USBm_Write1Wire( dev, $CC);
    USBm_Write1Wire( dev, $BE);
 
    // Process Family Code "22" (DS18B22)
    // Read two bytes of temperature
    result := USBm_Read1Wire( dev, data[0]);
    temp := inttostr(data[1]);
    val(inttostr(data[1]),T2,result);
    comb :=  T2;
</span>

This example code is provided AS-IS without warranty for distribution as example coding for the U4x1 in Delphi. It is easy enough to implement similar projects using Visual Basic, C, REALbasic, or the free RobotBASIC.

Enjoy!

Filed Under: Uncategorized Tagged With: 1-Wire, Delphi, programming, u401, u421

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in