Jump to content


Photo
- - - - -

Reading One wire via Visual Basic


  • Please log in to reply
8 replies to this topic

#1 EL34

EL34

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 137 posts

Posted 06 April 2008 - 03:03 PM

Does anyone have a simple Visual basic working example of how to read a one wire network DS1820 temp sensor?
Or any one wire weather device would do, just as long as the code actually works.

Everything I come across on the web or the SDK file does not work for one reason or another.
Either it's VB6.0 or this or that shows as an error, and I'm not savy enough in Vb to figure out why or what references are missing, etc.

I'm messing around with Visual basic 2008 express, creating windows apps.
I am also using a HB 6 channel master hub 9097U via serial port com 1

Thanks
appreciate any help I can get

Edited by EL34, 06 April 2008 - 03:04 PM.


#2 ericvic

ericvic

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 754 posts
  • Location:Birmingham, AL

Posted 06 April 2008 - 08:49 PM

I'm not going to be any help there because I don't use Visual Basic. I do all my coding in Java or C/C++.

Eric

#3 EL34

EL34

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 137 posts

Posted 07 April 2008 - 06:14 AM

Yeah, I do all mine in perl.

It's just way easier to do windows apps with VB

I found a VB forms example on the web last night that may be of some help.
Still, would love to see some simple, stripped down examples that just read a specific sensor by calling it's long number.

Thanks Eric

Edited by EL34, 07 April 2008 - 06:15 AM.


#4 EL34

EL34

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 137 posts

Posted 07 April 2008 - 02:56 PM

Yo Eric, maybe you can answer this.

I can read the DS18s20 sensors with the VB program example I found, but only if I go into the one wire viewer and click on the correct channel of the 6 channel master hub and then I have to click the switch in the one wire viewer to get to the aux port of that particular 2409 on the hub.

How do you get past the 3-2409's on the hub and get to the proper main or aux port to read the sensors.
I'm going to start reading docs, which usually ends in me looking at things for hours and not getting anywhere. :)

Basically, I guess the whole chain is
9097U com1
......... 2409's on the hub
.................devices on main or aux port on each 2409

#5 EL34

EL34

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 137 posts

Posted 07 April 2008 - 05:29 PM

Made some progress in reading my Ds18S20 temp sensors via Visual basic.

Now the problem is that Wserver is using the one wire network via my 6 channel master hub 9097U com1 one port

Looks to me like you cannot access the one wire network if an application is already tied to it, correct?
My Vb app works fine until I start up Wserver.
Each one wire software app wants exclusive access to the one wire network.

I want to read my temp senors that are going in my greenhouse and so I think I need to install another one wire adapter.
I am already using my only serial port and so I think I need one of Eric's usb adapters to get a second one wire network going?

Wserver is handling my weather station and my VB app will Handle the greenhouse Ds18s20 temp sensors via a usb adapter.

Does that all make sense and have I got it right? :)

Edited by EL34, 07 April 2008 - 05:30 PM.


#6 ericvic

ericvic

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 754 posts
  • Location:Birmingham, AL

Posted 07 April 2008 - 06:22 PM

You are correct that only one application can have access to the 1-Wire network at a time so you would need to add another adapter and 1-Wire network if you want two applications running at the same time.

As for using the Hub you need to turn on the channel of the DS2409 that your device is attached to before you will see it on the network. I have some Java code that does that if you would like to take a look at it.

Eric

Made some progress in reading my Ds18S20 temp sensors via Visual basic.

Now the problem is that Wserver is using the one wire network via my 6 channel master hub 9097U com1 one port

Looks to me like you cannot access the one wire network if an application is already tied to it, correct?
My Vb app works fine until I start up Wserver.
Each one wire software app wants exclusive access to the one wire network.

I want to read my temp senors that are going in my greenhouse and so I think I need to install another one wire adapter.
I am already using my only serial port and so I think I need one of Eric's usb adapters to get a second one wire network going?

Wserver is handling my weather station and my VB app will Handle the greenhouse Ds18s20 temp sensors via a usb adapter.

Does that all make sense and have I got it right? :)



#7 EL34

EL34

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 137 posts

Posted 07 April 2008 - 08:44 PM

I figured it out just a bit ago.
Like you said, I had to turn on the appropriate channel in the 2409 switch to be able to see the Ds18S20's that were attached to that channel.

It's wierd though.
Wserver runs 24/7 here, but I am able to sneak in, get my readings and get out without any problems?

The whole problem I was having, was just based on the fact that I did not have the 2409 switched properly to be able to read the exact temp sensors I was trying to read.

I am not sure if this breaks any rules, but wserver and my app are both sharing my master hub and both are able to get readings.

My app checks temps every 60 seconds and then bails out.
Not sure what would hwppen if Wserver and my app were both trying to check the one wire network at the same time.

Probably best to get that USB adapter and keep my app away from the master hub and wserver.

#8 sda

sda

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 358 posts
  • Location:California & Oregon, USA

Posted 08 April 2008 - 09:53 AM

My app checks temps every 60 seconds and then bails out.
Not sure what would happen if Wserver and my app were both trying to check the one wire network at the same time.

One of them would fail to acquire the 1wire network. If you are using the TMEX routines, then if an app opens the 1wire network (TMExtendedStartSession) but doesn't close it (TMEndSession), there are rules for determining when the next 1wire session can start. See the docs for TMExtendedStartSession.

Probably best to get that USB adapter and keep my app away from the master hub and wserver.

Good answer! There's only one "default" port so you'll need to manage the port numbers and types (usb,serial) on that yourself. Hopefully wserver can be configured to use a specific 1wire port/type.

Technically you could share the 1wire network between two apps. Both apps would need to be aware of the sharing and would need to recover gradefully from access collisions.

#9 EL34

EL34

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 137 posts

Posted 08 April 2008 - 11:08 AM

I am using the OWCOM API and I believes that Wserver uses TMEX?

I believe the last version of Wserverv came with the TMEX drivers as part of the install.
Arne's latest Wserver version may now use the OWCOM API, don't know.

Anywho, both pieces of software seem to be sharing nicely at this point.
I looked at serveral of the Wserver text files for serveral of the sensors and it doesn't seem to be missing any data.
Haven't seen any error messages pop up either.

Wserver reads all it's sensors every 60 seconds and so does my app.
I'll just keep an eye on things and see how it goes.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users