LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating through 1-Wire

Hi.  I'm new to 1-Wire, and not totally familiar with CVI/LabWindows.  I am using LabWindows 7.0, and I want to communicate with the DS1920 device (http://www.hobby-boards.com) through the DS1982 serial device.  I have downloaded the iButton SDK (http://www.maxim-ic.com/products/ibutton/software/1wire/wirekit.cfm), and have also installed the OneWireAPI.NET_Setup.msi application program. 

In short, I've downloaded various utilities, and I have example programs that I've found on these websites, but I simply want to be able to compile an example program with LabWindows/CVI. 

I don't know much about working with drivers through LabWindows, but if I can simply get some kind of session with the DS1920 device (i.e. communicate with it in some fashion), then I can progress much more easily.  Currently, if I try to run any example programs that I've found on the websites for the 1-Wire product, I get many linking errors.

Please provide me with basic instructions on how to set up some kind of working code to communicate through these devices through LabWindows.

Thanks.
0 Kudos
Message 1 of 11
(7,680 Views)
Hi Kirbata,
  I have built a CVI7 app that talks to a DS2480.  Obviously you are after temperature capabilities.  I'll be straight with you, you must be persistent to get the first successful compile.  If my memory serves me correctly the iButton SDK will link in with CVI without having to change any source or header files.  You simply have to get the order correct.  You will be using the ow...( ) functions to talk 1-wire if you don't use .NET.  I just used the 'C' files myself.
  The SDK does all of the hard work for you and that leaves you to concentrate on calling the functions in the proper order.  I will need to dig up my example source code and then I can try to post it by tomorrow morning for you.  My function calls might be slightly different, but at least you can get connected to your device and start tinkering from there.
 
Good luck,
Orlan
0 Kudos
Message 2 of 11
(7,671 Views)
Thanks a lot for the suggestion.  I am still getting link errors, but if you had some example of some code that will communicate with one of these devices without having compilation/link errors, it would be super helpful!

I really appreciate your help.
0 Kudos
Message 3 of 11
(7,663 Views)
OK,
  I couldn't find that sample project so I had to make another quick one.  I should first point out exactly what hardware I am using: DS9097U-E25, aka DS9097E (EEPROM-capable COM port adapter), DS1994 (iButton, 4K NVRAM + time), and the DS1402 (touch and hold probe, serial).  The DS 198x and DS199x devices all require the externally powered DS9097 that I have--unless Maxim/Dallas has some new toy on the market that I am not aware of.  Part of the silliness is that your CVI project should use the DS2480B 1-wire source files because the DS2480 acts similarly to the DS9097.  Anyway, after you at least get the project to compile, then it is just a matter of dropping/adding things that apply to your specific iButton.  I didn't do any read/write stuff since your iButton will likely be different.
 
  Just create a new source file, similar to foo.c shown below.  Sometimes I just prefer to do things the hard way, so I like to leave the iButton SDK files in their own folder and I manually add them to my CVI project.  There are more efficient ways to do this.  Nonetheless, attached is a graphic showing what I had to include to get my quick project to build properly.  I do get two warnings, but they don't hurt how the project builds or executes.  You may see the same warnings.  If you run through f_proto( ) with the CVI debugger, you should see that it finds your iButton.  So, there you go!
 
foo.c:
-----------------------------------
#include <ansi_c.h>
#include "ownet.h"
#include "findtype.h"
#include "time04.h"

#define MAXDEVICES 4
void f_proto(void) {
 int COMport, DS1994count;
 uchar TimeSN[MAXDEVICES][8]; // array to hold the serial numbers for the devices found
 int j, i=0;
 
 //if a DS2480B on the serial port, stop the program
 if((COMport = owAcquireEx("COM1")) < 0) {
  printf("Failed to acquire port.\n");
  return;
 }
 
 //get list of 1-Wire Clock devices
 DS1994count = FindDevices(COMport, &TimeSN[0], TIME_FAM, MAXDEVICES);
 //check if not present or more than 1 present
 if (0 == DS1994count) return;
 if (1 < DS1994count) {
  printf("\nMore than 1 1-Wire clock discovered, picking ");
  printf("\nthe first device found.\n");
 }
 
 //print out the 1-Wire net address of clock; only one pass at the read
 printf("\n1-Wire Address of clock found:  ");
 for (j = 7; j >= 0; j--) {
  printf("%02X",TimeSN[i][j]);
 }
 printf("\n\n");
 
 // release the port
 owRelease(COMport);
 
 return;
}
------------------
Good luck,
Orlan
Message 4 of 11
(7,659 Views)
Cosmo,
Your advice seems very clear to me, and in theory, it is very helpful.  However, being somewhat of a novice, I am making some kind of silly mistake.  I was able to find many of the source files that you've included for the iButton software with the "owpd300.zip" file found at the top of the following website: http://www.maxim-ic.com/products/ibutton/software/1wire/wirekit.cfm

Be that as it may, I am still having difficulties.  Here is what I've done so far:
1.) Created a new CVI project.  Saved this project.
2.) Created three new files: "iButton Include Files", "iButton Source Files", and "Source Files".
3.) Copied the contents of "owpd300.zip" to my project directory.
4.) Added the files that I had seen in your graphic to my project.  Most of these were in owpd300\common, but the ds2480 files were in \owpd300\lib\userial
5.) I tried to compile just this, but had two link errors.  I assumed that I might need the source files that you had listed.
6.) I assumed that you created your own main.c and proto.c files.  I created these files in the project directory, and then made an empty main function.
7.) I copied the code that you had entered for foo.c precisely, and pasted it into my newly created proto.c (Is there an actual proto.c that needs to be included?)
8.) I tried to debug the project again, but I receive a link error that says the following:

 "Inconsistent type declarations for external symbol '_USpeed' in modules 'c:\Documents and Settings\bakirby\Desktop\1Wire\cvibuild.1Wire\ownetu.nidobj' and 'c:\Documents and Settings\bakirby\Desktop\1Wire\cvibuild.1Wire\ds2480ut.nidobj'."

Both ds2480ut.c and ownetu.c were included from the userial directory.  Am I making some obvious mistake here?  The only thing that I am not sure about in regard to the files that I included from the iButton directory is that, in your graphic, it appears that you have included the file "owtmu.c", but I can only seem to find a file called "owtrnu.c".  I assumed that the picture may have been blurred.  If this is the wrong file, then maybe that is the mistake.  But, I do not know where to find a file called "owtmu.c".

Please let me know if I am making any obvious mistakes.  I have attached a graphic of my current workspace.

Thanks,
Brian



0 Kudos
Message 5 of 11
(7,607 Views)
Cosmo,
I was able to get rid of this error my simply changing one of the types to an integer...  However, since this is iButton code, I don't know if it's alright or not.  I'll try to work with it.  Thanks a lot for your help, though!

Brian


0 Kudos
Message 6 of 11
(7,603 Views)

Hi Brian,

  Actually I have a revised snippet of code that should allow you to read from the DS1920.  Sorry, I don't have a DS1920 to confirm that the code is correct, but I took it from the sample file time.c in the SDK source directory.  Since I wrote my originally posted code to work with the DS1994, you should take that project and drop time04.h from the iButton include files.  Then replace it with temp10.h.  Also, you will need to add ioutil.c and temp10.c to the iButton source files for the subsequent code snippet to compile properly.  You were right about the OWTRNU.c file.  The JPEG compression made it look like OWTMU.c.  So give this a whirl:

---------------------------------------------------

#include <ansi_c.h>

#include "ownet.h"
#include "findtype.h"
#include "temp10.h"

#define MAXDEVICES 4

void f_proto(void) {
  int COMport, DS1920count;
  uchar FamilySN[MAXDEVICES][8]; // array to hold the serial numbers for the devices found
  int j, i=0;
  float currentTemp;
 
  //if a DS2480B on the serial port, stop the program
  if((COMport = owAcquireEx("COM1")) < 0) {
    printf("Failed to acquire port.\n");
    return;
  }

  // success
  printf("Port opened\n");
  // Find the device(s)
  DS1920count = FindDevices(COMport, &FamilySN[0], 0x10, MAXDEVICES);
  if (DS1920count>0) {
    printf("\n");
    printf("Device(s) Found: \n");
    for (i = 0; i < DS1920count; i++) {
      PrintSerialNum(FamilySN[i]);
      printf("\n");
    }
    printf("\n\n");
    // (stops on CTRL-C)
    do {
      // read the temperature and print serial number and temperature
      for (i = 0; i < DS1920count; i++) {
        if (ReadTemperature(COMport, FamilySN[i],&currentTemp)) {
          PrintSerialNum(FamilySN[i]);
          printf("     %5.1f \n", currentTemp * 9 / 5 + 32);
        // converting temperature from Celsius to Fahrenheit
        } else {
          printf("     Error reading temperature, verify device present:%d\n", (int)owVerify(COMport, FALSE));
        }
        printf("\n");
      }
    } while (!key_abort());
  } else {
    printf("\n\n\nERROR, device DS1920/DS1820 not found!\n");
  }

  // release the port
  owRelease(COMport);
 
  return;
}

0 Kudos
Message 7 of 11
(7,589 Views)
Cosmo,
Sorry for the late reply.  I appreciate your help.  Actually, though, I was able to communicate with the device on my own, using some different include files.  Anyway, I really do appreciate your help.

Thanks a lot,
Brian


0 Kudos
Message 8 of 11
(7,520 Views)
As an FYI.  We are also just started using the 1-Wire hardware/software.  Here a re some pointers to watch out for.  ( I'm now doing hardware development and less software so please be patient.) 
 
1) We purchased a lot of items from both Hobby boards. com  - sensors, cases, cables and adapters. -
2) Be aware that there are two styles of adapaters. 
    a) version -s09 which does not provide a serial number
    b) version -009 which does provide a serial number.
3) Each temperature sensor chip belongs to a "Family" make sure you always get the same "Family"
4) The software guy wrote a layer of functions to "get temp", "get test sation id".  etc and placed them in a DLL so the functions
     could be shared  on other projects with minimal changes.
5) We purchased bare boards from Hobby boards.com
6) We buy our serial number ID chips from Digi key.
7) Dallas - was great at providing samples for our initial testing but we have accounts with the other vendors is why we
    purchaed from them.
😎 Our next attempt is use the memory chip.  Any help would be appreciated.
0 Kudos
Message 9 of 11
(7,466 Views)

Sorry for resurrecting a very old post, everone.  But I stumbled upon this and found it to be very helpful.

 

How did you guys deal with all the many included headers?  In my case, I'm trying to talk to a temp sensor and a EEPROM.  So at first I kept the number of attached headers and c files in my project as small as possible.  But these in turn all include other headers, and so on.  It becomes a nightmare trying to get it all sorted.

0 Kudos
Message 10 of 11
(4,049 Views)