LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I talk to 1-Wire devices with LabVIEW Real-Time?

Hello, I'm trying to use LabVIEW Real-Time to talk to some older 1-Wire devices that my company has previously communicated with using C code.  We are currently developing on a cRIO and are trying to use a Dallas Semiconductor 2480 serial port device to talk to some iButtons and a secure SHA 1-Wire device.  I have run into a few problems where the 1-Wire device stops communicating and just repeats the data sent to it.  I was wondering if anyone has successfully created any VI's to talk with 1-Wire devices via the serial port that do NOT use any kind of Java or .NET or Windows based device drivers supplied by Dallas Semi.  A last resort would be that we keep the C code and place it in a block in LabVIEW and run it as is but I would prefer to have some LabVIEW-native code.  Any help would be greatly appreciated.  Thanks.
0 Kudos
Message 1 of 10
(5,204 Views)
AndyP,

I have not been able to find any existing examples that use LabVIEW to communicate with 1-wire devices, but there are other customers who have done so using C or .NET:

Communicating through 1-Wire

labview routines to read dallas semi 1 wire devices

Is there any reason you would not want to compile your C code into a DLL and then call it from LabVIEW with the Call Library Function Node?  I will keep my eyes open for any LabVIEW examples and make sure to post them when I find them.  

Regards,

Brian T
Applications Engineer
0 Kudos
Message 2 of 10
(5,186 Views)
I've written code to communicate with iButtons in the past.  I used the IBFS32 DLL from Dallas Semi, calling its functions using the Call Library function in Labview.  It worked great.  But this is windows based.  Does this DLL not work for real time OS?
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 10
(5,178 Views)
Brian_T,

    I believe we considered doing that but I think we ran into some confusion when it came time to talk to the serial port.  The C code requires foreknowledge of the operating system so you can call the correct routines used to talk to the serial port (or at least the C code examples provided by Dalls Semi require it and we based our own code off of that).  The cRIO doesn't run Dos or Windows so calling the right routines becomes a very big question at that point.  Not to mention that, to my knowledge, we cannot compile a DLL native to the cRIO and then place it on the cRIO and then call it there in a program running on the cRIO.  I don't believe that is an option that NI provides to their customers just yet.  Otherwise, yes that should work and might even be faster than native LabVIEW code.
0 Kudos
Message 4 of 10
(5,167 Views)
AndyP,

You can put shared libraries on a cRIO and then call them from a VI running on the cRIO.  The one limitation is that these libraries need to be a *.out file, as opposed to a *.dll.  You can find information explaining how to do this here.

You are also able to communicate with the serial port using the VISA driver and native LabVIEW code.  When the VI is run on the controller, you can access the serial port by referencing COM1.  Here are some discussion forum posts in which another customer does just this.  Let me know if this works for you. 

Regards,

Brian T

0 Kudos
Message 5 of 10
(5,147 Views)
the second link (Labview routines to read ...) requires a password ...
Who would I call at what number in order to obtain the password?
Thanks!

0 Kudos
Message 6 of 10
(5,089 Views)
johnstosh,

Here is a link that should work for you:

looking for LabVIEW routines to read dallas semi 1 wire devices


Brian T
0 Kudos
Message 7 of 10
(5,052 Views)
Brian_T,

    Thanks for that link about compiling a shared library for use on a VxWorks cRIO.  The only thing they mention that I don't understand is this bit:
"GNU toolchain distributed with Wind River VxWorks"
I have been unable to locate a compiler for VxWorks so I am assuming that is located in this GNU toolchain thing?  Does that come with the cRIO?  I think I noticed a VxWorks C compiler somewhere else online but we're talking a totally different product I would have to purchase, assuming it would even work.  I guess once the stub and the shared library are all good to go, I just call the C functions in the shared library and when it comes time to talk to the serial port, just slap a VISA Read/Write VI on the block diagram.  I've been using a cRIO and COM1 access for some time now so I do understand at least that much.  Let me know how to get ahold of this "toolchain" thing.  Thanks.

0 Kudos
Message 8 of 10
(5,044 Views)
AndyP123,

You can find more detailed information about creating shared libraries to use with VxWorks, as well as links to download a redistributable GNU tool chain for VxWorks here:

Developing Shared Libraries for the cRIO-901x and Other VxWorks Targets

Hope this helps!

Brian T
Applications Engineer
0 Kudos
Message 9 of 10
(5,022 Views)
Ah, cool.  One of the other guys here at the office mentioned this, with the command line compiler and all that.  I think I will be holding off on that adventure until I know for sure I can't make it work in native Labview.  I have most of it working but my timing appears to be off.  I also fried an iButton (software-wise) to the point where I have no idea what the write password is so I hope we have a way to restore a default of some sort.  That was pretty much why I went looking for alternatives.  I am also trying to work the code into the new Statechart module so if any of you guys have been considering using it I can let you know how it turns out for me.
0 Kudos
Message 10 of 10
(5,013 Views)