Form freezes x secs when reading multiple sensors.

Forum about 1-Wire devices.

Form freezes x secs when reading multiple sensors.

Postby de.lesse » Wed Nov 12, 2008 12:57 pm

Not really a 1-wire topic, more programming...

When reading 7 1-wire devices in a row, my main form freezes for 7 seconds.
I know that reading a device take 750ms. It doesn't take cpu usage to read a device.

How can i change my code to 'multithread' my application, so i can do something else while reading the devices?
What kind of threading should i use. I don't want to try all possibilities to spend time...

vb.net2005 owapi written app.

timer is running, sub starts after every x time
read all active enabled devices in a row
some checks (doesn't make a difference when disabling this line)
write after every read to sql
back to timer...
de.lesse
Starting Member
Starting Member
 
Posts: 24
Joined: March 2008
Location: Belgium

Form freezes x secs when reading multiple sensors.

Postby Digit » Fri Nov 14, 2008 12:55 am

Threading is not one of the most easy things to explain. I think you can write a complete book about it. All i can say is my knowledge about threading in VB is very very limited, but i do threading quite a lot in my own application using semaphore mailboxes. Before you start using threads, i think the best is to know what you're dealing with and know how they work before you begin using them. Although the following describes threading in another language, you might want to read it since it gives a good impression on how it all works 'under the hood'. It helped me a lot.
http://www.eonclash.com/Tutorials/Multi ... 1/ToC.html
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Form freezes x secs when reading multiple sensors.

Postby Stevexyz » Fri Nov 14, 2008 12:48 pm

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I know that reading a device take 750ms. It doesn't take cpu usage to read a device<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">Yes and yes! However, if the CPU is used for timing the 1-wire bus then it can get tied up and be unavailable for anything else. My devices also take about 1s second each to read (but I don't read them all at the same time). One solution would be to use an intelligent 1-wire controller (a PIC or something) to do the timing.
Cheers,Steve
Stevexyz
Member
Member
 
Posts: 87
Joined: December 2007
Location: United Kingdom

Form freezes x secs when reading multiple sensors.

Postby DMB » Sat Nov 15, 2008 12:28 am

Hello de.lesse,

I read 3 1 wiredevices with one timer tick and I've got the same problem. I use a separate vb task for reading and write the values in a mysql database and directly in a homeseer device.
Freezing of the form is a not a problem for me.
The interface is a DS9097U.

Here is the code I use.

<b>Download Attachment:</b> [url="http://www.domoticaforum.eu/uploaded/DMB/200811150264_code.txt"][img]images/icon_paperclip.gif[/img] code.txt[/url]<br />5.49KB

It's a .vb file (VB .net 2005), but I could not upload a .vb file.

DMB
User avatar
DMB
Member
Member
 
Posts: 136
Joined: June 2006
Location: Netherlands


Return to 1-Wire Forum

Who is online

Users browsing this forum: No registered users and 1 guest