Form freezes x secs when reading multiple sensors.

Forum about 1-Wire devices.
Post Reply
de.lesse
Starting Member
Starting Member
Posts: 24
Joined: Sat Mar 29, 2008 12:24 pm
Location: Belgium

Form freezes x secs when reading multiple sensors.

Post by de.lesse »

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...
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Form freezes x secs when reading multiple sensors.

Post by Digit »

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
Stevexyz
Member
Member
Posts: 87
Joined: Fri Dec 14, 2007 1:45 am
Location: United Kingdom
Contact:

Form freezes x secs when reading multiple sensors.

Post by Stevexyz »

<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
User avatar
DMB
Member
Member
Posts: 136
Joined: Tue Jun 27, 2006 7:11 pm
Location: Netherlands

Form freezes x secs when reading multiple sensors.

Post by DMB »

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> [img]images/icon_paperclip.gif[/img] code.txt<br />5.49KB

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

DMB
Post Reply

Return to “1-Wire Forum”