Visual Basic Home Control

Forum regarding Windows Software and Home Automation Domotica.

Visual Basic Home Control

Postby Michiel145 » Tue Sep 18, 2012 9:11 am

Hi there!

I'm at the point of buying a new house, and would like to install a home automation system. I have seen the Bwired site and systems, ans would like to build something similar, but a tad smaller. :lol:

The idea is to mainly use X10 over powerline to do the switching, and use a ADC<>RS232 board for reading temperature sensors, and PIR motion sensors.

For the software I want to write my own application in, the age old, Visual Basic 6. I have already made most of the server application, but still would like to find a CM11 VB6 module that uses the MSCOMM. I think I can write it my self, but it will save me tons of work. Does anyone have a sample of code for controlling the CM11 without a ActiveX?!

A screendump of my server application.
Image


The task of the server is to constantly synchronize a INI file with the devices. If the 'change' flag is set for a device in the INI file, the server will notice, and update the state to the device over X10. With this modular system of having a central DB or INI file, I hope to make it easy to implement modules. The module will only have to read the INI for getting the state of the devices, and write a other state to update one.

Anny how, does anyone have some VB6 examples? :mrgreen:

Thanks!!
Michiel145
Starting Member
Starting Member
 
Posts: 3
Joined: September 2012

Re: Visual Basic Home Control

Postby Michiel145 » Tue Sep 18, 2012 1:49 pm

Ok, I have found some crappy code examples.... Not really something to use, but it shows some of the commands that need to be send.

The following was found in the code:

Code: Select all
        sTmp = Chr$(&H4)                     
        m_strInitCode = sTmp & Chr$(&H66)       
        m_strOnCode = Chr$(&H6) & Chr$(&H62) 
        m_strOffCode = Chr$(&H6) & Chr$(&H63) 
        m_strAckCode = Chr$(&H0)             
        m_strReadyCode = Chr$(&H55)


A table I made:
Code: Select all
'Function Binary Value All Units Off 0000 All Lights On 0001 On 0010 Off 0011 Dim 0100 Bright 0101 All Lights Off 0110 Extended Code 0111 Hail Request 1000 Hail Acknowledge 1001 Pre-set Dim (1) 1010 Pre-set Dim (2) 1011 Extended Data Transfer 1100 Status On 1101 Status Off 1110 Status Request 1111

'    Housecode   Device Code Binary Value   DEC HEX Binary      ASCII   KEY
'    A       1       0000 0110              6   06  0000 0110   ACK     Ctrl/F
'    B       2       0000 1110              14  0E  0000 1110   SOH     Ctrl/N
'    C       3       0000 0010              2   02  0000 0010   STX     Ctrl/B
'    D       4       0000 1010              10  0A  0000 1010   LF  Ctrl/J, Line Feed
'    E       5       0000 0001              1   01  0000 0001   SOH     Ctrl/A
'    F       6       0000 1001              9   09  0000 1001   HT  Ctrl/I, Tab
'    G       7       0000 0101              5   05  0000 0101   ENQ     Ctrl/E
'    H       8       0000 1101              13  0D  0000 1101   CR  Ctrl/M, Return
'    I       9       0000 0111              7   07  0000 0111   BEL     Ctrl/G
'    J       10      0000 1111              15  0F  0000 1111   SI  Ctrl/O
'    K       11      0000 0011              3   03  0000 0011   ETX     Ctrl/C
'    L       12      0000 1011              11  0B  0000 1011   VT  Ctrl/K
'    M       13      0000 0000              0   00  0000 0000   NUL     Ctrl/1
'    N       14      0000 1000              8   08  0000 1000   BS  Ctrl/H, Backspace
'    O       15      0000 0100              4   04  0000 0100   EOT     Ctrl/D
'    P       16      0000 1100              12  0C  0000 1100   FF  Ctrl/L


So the following code
Code: Select all
     m_strOnCode = Chr$(&H6) & Chr$(&H62) 
would translate into the following if I'm correct.

Chr$(&H6) = 0110 << Is 'A' and would be the house code I think
Chr$(&H62)= 0110 << Could be device '1' 0010 << and that would make this the 'on' command

I think I have cracked it! :mrgreen:

Question for you guys. If I for example want to send "House A" + "Device 1" + "ON", that would be:
Code: Select all
0110 0110 0010

Can I send Chr$(&H6) & Chr$(&H6) & Chr$(&H2) Or do I need to Chr$(&H662), or does is not work either way? :roll:

My X10 controller will arrive this week, so I can't test the code just jet. :D
Michiel145
Starting Member
Starting Member
 
Posts: 3
Joined: September 2012

Re: Visual Basic Home Control

Postby AshaiRey » Wed Sep 19, 2012 8:37 am

Chr$(&H662) could be something different then Chr$(&H6) & Chr$(&H6) & Chr$(&H2)
Although you use an AND operation to put the three value together i think there needs to be also a seperator between the binary sets to make them distinqued. However i am not sure of that either. Best guess is just wait for your controller and try
Bram
AshaiRey
Senior Member
Senior Member
 
Posts: 1297
Joined: February 2009
Location: Netherlands

Re: Visual Basic Home Control

Postby Digit » Wed Sep 19, 2012 2:50 pm

Chr$(&H662) does not exist. Character codes range from 0 to 255 (decimal) for this function so it will probably result in a syntax or runtime error or something else you do not want :wink:
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Re: Visual Basic Home Control

Postby Michiel145 » Wed Sep 19, 2012 3:44 pm

Aha, that explains the runtime-error I got. :D But I will just wait for the controller to arive. Thanks so far for you're help guys!
Michiel145
Starting Member
Starting Member
 
Posts: 3
Joined: September 2012


Return to Windows Forum

Who is online

Users browsing this forum: No registered users and 1 guest