Niko pure feedback leds

Show or discuss your existing Home automation project here, so a detailed explanation!.....

Niko pure feedback leds

Postby fabian » Thu Mar 27, 2014 10:10 pm

Recently i've stumbled upon Velleman's vmb6pbn module which is designed to be used with the Niko 4 fold of 6 fold momentary switch modules.

Image

It's a Velbus module which requires only 4 wires (12V and Canbus).

I've been using the Niko 6 fold modules for quite some time now (viewtopic.php?f=19&t=6823&p=52356#p52356). Additional eletrical piping has been installed during my newbuild so i'm able to install low voltage wiring to certain locations which are mostly used for switching lights.

Until now an Aruino Mega with Marmitek XM10E has been capturing (or trying to capure) X10 messages for a few preprogrammed DAIX12's modules. ON or DIM switched 24v to the leds. The arduino and all additional hardware takes quite a lot of space and is hasn't been very stable. Lots of messages stay unnoticed.

Using velbus would be far more flexible and requires less hardware and cabling (4 wires instead of 14 (7for leds / 7 for switches). But how to send Velbus messages from Homeseer.
About 5 years ago some forum mebers became quite enthusiastic about Velbus viewtopic.php?f=11&t=3334 but unfortunately noone mode a Velbus plugin for Homeseer

I'm certainly not a programmer, but after a day of googling and vb.net fiddling, homeseer is switchting some leds! And quite fast compared to X10. There are a lot of VB.Net / .Net / C# (still not sure what the difference is) examples and the VMB1USB makes it easy to send velbus messages via an emulated COM port.

[youtube]http://www.youtube.com/watch?v=RnbMRkLFI4U&feature=youtu.be[/youtube]

This is the vb code so far.
Code: Select all
'Niko paneel via VMB6PBN
'
'1   2      h01   H02      1   2
'5   6      H10   H20      16   32
'4   3      H08   H04      8   4
'
'A1 = 161
'A2 = 162
'A3 = 163
'A4 = 164
'A5 = 165
'

Sub VelbusUpdate(ByVal Parms As Object)
   Dim VelbusOpdracht(7) As Integer

   Dim Devices As String()() = New String(5)() {}
   Dim i,j As Integer

   ' create jagged two-dimensional array
   ' Meerdere Panelen + Leds mogelijk, {"G1", "161|1", "161|4", "165|16"}
   Devices(0) = New String() {"G1", "162|8"}
   Devices(1) = New String() {"G2", "162|16"}
   Devices(2) = New String() {"G3", "162|1"}
   Devices(3) = New String() {"G4", "162|4"}
   Devices(4) = New String() {"B1", "162|32"}
   Devices(5) = New String() {"B2", "162|2"}


   ' Parms(2)  2 = On, 3 = Off, 4 = Dim

   if Parms(2) = 2 Or Parms(2) = 4 Then
      VelbusOpdracht(4) = &HF6
   Else
      VelbusOpdracht(4) = &HF5
   End If   
            

   For i = 0 To Devices.GetUpperBound(0)
      if Devices(i)(0) = Parms(0) & Parms(1) Then
         hs.writelog("Velbus", "Device change "&Devices(i)(0))

         For j = 1 To Devices(i).GetUpperBound(0)
             dim iStr() as string = Devices(i)(j).split("|")
             Dim address, led as integer 
             If IsNumeric(iStr(0)) then
                 address = Cint(iStr(0))
             End if
             If IsNumeric(iStr(1)) then
                 led = Cint(iStr(1))
             End if
            VelbusOpdracht(0) = &H0F
            VelbusOpdracht(1) = &HFB
            VelbusOpdracht(2) = address
            VelbusOpdracht(3) = &H02
            VelbusOpdracht(5) = led
            VelbusOpdracht(7) = &H04
   
            Dim checksum As Byte
            Dim chkI As Integer = 0
   
            For c As Integer = 0 To 5
         '      hs.writelog("Velbus ","Byte "&velbusOpdracht(c))
               chkI += velbusOpdracht(c)
               chkI = chkI And 255
            Next

            chkI = 255 - chkI
            chkI += 1
            velbusOpdracht(6) = chkI
   
            Dim ComPort As Integer = 11
            For c As Integer = 0 To 7

               hs.SendToComPort(ComPort, Chr(velbusOpdracht(c)))
            Next

            hs.Writelog("Velbus", VelbusOpdracht(0) & " " & VelbusOpdracht(1) & " " & VelbusOpdracht(2) & " " & VelbusOpdracht(3) & " " & VelbusOpdracht(4) & " " & VelbusOpdracht(5) & " " & VelbusOpdracht(6) & " " & VelbusOpdracht(7))

         Next
      End if
   Next

End Sub


The length of a velbus message is variable, but for most operations the message is 8 bytes long where the 7th byte is checksum.

Next i'd like to be able to receive velbus message with Homeseer so my WTW Arduino doesn't need a LAN shield anymore. Not sure yet which homeseer mode to use. There isn't a CRLF. Just a start byte H0F and an end byte H04
fabian
Member
Member
 
Posts: 110
Joined: December 2010
Location: NL, Zuidhorn

Re: Niko pure feedback leds

Postby AshaiRey » Fri Mar 28, 2014 8:41 am

fabian wrote:(Snipped a large part).... to use. There isn't a CRLF. Just a start byte H0F and an end byte H04


When opening a com port in HS you can define which character will be the terminator

Here's more info about it
'the third hs.opencomport parameter you specify either a 1 or a 0 to
'return data either in raw or string mode

'0 = raw mode
'In this mode, each character that is received on the COM port causes
'the specified script and function to be called. It is up to the called
'function to callGetComPortData to actually get the characters.

'1 = strings mode
'This mode buffers up characters until a terminator is received.
'At this point the specified script and function are called with the data.
'This mode makes it easy to deal with devices that send text data terminated
'with known characters. To specify the terminator characters,
'see the term parameter description below.
'If you do not specify a terminator, the default terminator of
'carriage return and line-feed (CrLf) are used.

e = hs.OpenComPort(SERIALPORTNUMBER ,CONNECTIONSTRING,1,strActionScriptName,"Handle_Event", EOM)

Source : homeseer.com/support/homeseer/WebHelp2/ ... omport.htm
Bram
AshaiRey
Senior Member
Senior Member
 
Posts: 1295
Joined: February 2009
Location: Netherlands

Re: Niko pure feedback leds

Postby fabian » Fri Mar 28, 2014 10:32 am

AshaiRey wrote:
e = hs.OpenComPort(SERIALPORTNUMBER ,CONNECTIONSTRING,1,strActionScriptName,"Handle_Event", EOM)

Source : homeseer.com/support/homeseer/WebHelp2/ ... omport.htm


Thanks, but ther doesn't seem to a unique termination string.

The ETX is hex 04 but other bytes can also be hex 04. Looking at other scripts written in C and Python, they all seem to be buffering bytes like as follows:

- Wait for bytes, if byte is hex 0F , packet has started (buffer[0])
- lookup vaule in buffer[3] (byte which containts the expected number of bytes)
- loop trough buffer[] , if buffer[buffer[3]+5] == hex 04, ets ETX
- packet recieved, process..

For now i'm guessing Homeseer will only be able to do this is with Operation Mode 0 (raw) and a vb script which buffers and stores even when it's not running anymore. Or use a different piece of software which buffers the full packet and add a \n after each packet which is then send to a virtual com interface.
fabian
Member
Member
 
Posts: 110
Joined: December 2010
Location: NL, Zuidhorn


Return to Home Automation Projects

Who is online

Users browsing this forum: No registered users and 1 guest