Talk Serial to me..

Discussion in 'C-Bus Serial Protocols' started by Roosta, Nov 25, 2014.

  1. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Hi all,

    I am currently enjoying some sick leave from work and thus finding myself rather bored.. I have been tinkering on a little project for a while now, but it has now gotten beyond my current skillset..

    Situation is I have a small cbus installation, basically an 8ch dimmer, a Spectrum with logic and a pc interface.. What I am wishing to to is control the lighting from software on my pc, called Vixen 2, which is a lighting sequence freeware.. It has the ability to output 'generic serial' which I am not sure i can use yet but am willing to try.. Basically i have setup a 8ch sequence in Vixen and wish to communicate this across to cbus via serial of the 5500PC, however I have not really ever dabbled in serial comms.. I have been reading up for a few days and trialling all sorts of things, however I am having no joy.. Basically i need to somehow map ch1 from vixen to GA001 of cbus.. I have used the port monitor to work out that vixen basically sends out in a single write command the level of each channel in order at each event.. ie for 8 channels with channel 1 and 5 on and the rest off it sends 'FF 00 00 00 FF 00 00 00'.. So basically I know I need to read that into logic and then shoot it out onto cbus land.. This is where the fun begins..

    And yes i have read the serial protocol docs..

    It appears people have had lots of success using arduino and Vixen, and I have found various codes to achieve this, if that helps..

    Anyone want a challenge? ;-)
     
    Last edited by a moderator: Nov 25, 2014
    Roosta, Nov 25, 2014
    #1
  2. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Ok so this is where I am at..

    ------------------------------------
    Vixen = String
    ChLevel = Integer

    Module:
    OpenSerial(1,1,9600,8,1,0,0);

    if (GetLightingState("Trig1") = ON) then

    begin
    ReadSerial(1, Vixen, ' ');
    ChLevel:=HexStringToInt(Vixen);
    SetLightingLevel("Dimmer Ch 1", ChLevel, "0s");
    CloseSerial(1);
    end;
    ------------------------------------

    I have vixen set to only broadcast one channel, on / off in 1 second intervals..

    5500PC Unit led starts flashing once 'Trig1' turns on, so figure the 5500PC is ready to receive the serial command..

    I have port monitor showing Vixen sending the signal out..

    But no go.. :-(
     
    Roosta, Nov 25, 2014
    #2
  3. Roosta

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Are you sure that example is Ch1 and 4 on? It looks like it might be 1 and 5 ( or 0 and 4)

    I've never done much PAC programming, but you've got your work cut out for you.

    Is it going to be 2 way?

    Given the single command that holds multiple channels, you don't know which one has changed just by processing the message. Your going to have to keep your own status table that you compare the inbound command against so you know what command to send out to C-Bus.

    Then there is generating the checksum on the fly.

    I would think its all technically doable in a PAC, but.......

    Best of luck.

    Cheers

    Rohan
     
    rhamer, Nov 25, 2014
    #3
  4. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Well picked up.. That was indeed 1 and 5 on.. Doesnt need to be 2 way just one way from pc to cbus.. At every interval each channels level is re-broadcast, even if there has been no change to it.. I can configure the Vixen software to include begining and end bits which i can set..

    Hoping that i will be able to get a single channel going, and then use the copy command in logic, and the constant string length out of vixen to isolate the bytes i require for each channel...

    Quick one for anyone in the know.. I am writing the logic into my spectrum but have the pc connected to the 5500pc via serial.. Can this work in this manor or do i need to use the rs232 port on the touchscreen?
     
    Roosta, Nov 25, 2014
    #4
  5. Roosta

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    I don't quite understand your connectivity, and where the 5500 PCI fits in.

    Can you explain how you have it hooked up.

    Rohan
     
    rhamer, Nov 25, 2014
    #5
  6. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Yep, sure can..

    I have the cbus from the dimmer to the cbus of the 5500pc, and then the spectrum into the other cbus connector.. I have the db9 serial ontop of the 5500pc going to a serial port on my pc.. I also have the spectrum connected to my pc via usb for updating the program, which i have done about 20 times already trying different code..

    When i open the vixen software on my pc, it closes all other connections on the serial comms port, and prepares for operation, which when i turn on port monitor i can see it sending the commands out when i run the sequence.. I assume this means it is transmitting the serial command via the db9 connection/lead to the 5500pc as when i start the sequence the unit light starts flashing..
     
    Last edited by a moderator: Nov 25, 2014
    Roosta, Nov 25, 2014
    #6
  7. Roosta

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Sorry mate, I still don't understand, so perhaps I'm not familiar enough with the spectrum etc for it to sink in.

    What I would have expected is;

    PC running vixen outputting commands on serial port
    PC connected to serial port of spectrum.
    Logic in spectrum reading vixen commands from its own serial port and translating them into C-Bus commands.

    I THINK when you are simulating logic in Piced it uses the PC serial port in Liu of the devices own serial port.

    So I don't think you need the 5500 PCI.

    Certainly you can't take the standard output from vixen on the PC serial port and plug it directly into a PCI.

    Does that make sense?

    Rohan
     
    rhamer, Nov 25, 2014
    #7
  8. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Sure does, but in my head I was trying to work out how the likes of RTI, Elan, Push Controls, etc, work by sending rs232 to a 5500pc, when the only way of actually firing up the 232 comms is via logic..

    Hmm.. Ah well I will may up a 3.5mm to serial lead and try that out..
     
    Roosta, Nov 25, 2014
    #8
  9. Roosta

    rhamer

    Joined:
    Aug 3, 2004
    Messages:
    673
    Likes Received:
    3
    Location:
    Melbourne, Australia
    Those other systems work by having a driver of some sort acting as the translator between their internal protocol and the PCI C-Bus protocol.

    This is really what you are trying to do, except the spectrum logic already knows how to send C-Bus commands, it just has to be programmed to open its own serial port, read in the Vixen command and process it.

    Cheers

    Rohan
     
    rhamer, Nov 25, 2014
    #9
  10. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Haha indeed it is.. You make it sound so easy..

    Haha thanks for the advice along the way mate.. Just putting together a lead now.. Could be a long night.. Just aswell i still have a few days off sick to play around..
     
    Roosta, Nov 25, 2014
    #10
  11. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Bam.. We have a go! Had to tweak the logic aswell.. I will clean it up and do some testing and then put the code up here for all to enjoy..
     
    Roosta, Nov 25, 2014
    #11
  12. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Solution to driving CBUS loads, from Vixen 2 Software:

    Piced Logic Code:
    -------------------------
    Variables:
    Vixen = String
    Ch1Level = Integer
    Ch2Level = Integer
    Ch3Level = Integer
    Ch4Level = Integer
    Ch5Level = Integer
    Ch6Level = Integer


    if (GetLightingState("Trig1") = ON) then
    begin
    OpenSerial(1,1,9600,8,1,0,0);
    ReadSerial(1, Vixen, 'F'); {Reads in the string on Com port 1, and places it into variable 'Vixen', and knows that the end of the message is when 'F' comes through}
    if (Vixen[1]='H') THEN {Looks at the first byte in the string and confirms it is the text header}
    BEGIN
    Ch1Level:=ord(Vixen[2]); {Reads 2nd byte and stores it into variable Ch1Level}
    Ch2Level:=ord(Vixen[3]); {Reads 3rd byte and stores it into variable Ch2Level}
    Ch3Level:=ord(Vixen[4]); {Reads 4th byte and stores it into variable Ch3Level}
    Ch4Level:=ord(Vixen[5]); {Reads 5th byte and stores it into variable Ch4Level}
    Ch5Level:=ord(Vixen[6]); {Reads 6th byte and stores it into variable Ch5Level}
    Ch6Level:=ord(Vixen[7]); {Reads 7th byte and stores it into variable Ch6Level}
    SetLightingLevel("Dimmer Ch 1", Ch1Level, "0s"); {Sets CBUS Group to Variable level}
    SetLightingLevel("Dimmer Ch 2", Ch2Level, "0s");
    SetLightingLevel("Dimmer Ch 3", Ch3Level, "0s");
    SetLightingLevel("Dimmer Ch 4", Ch4Level, "0s");
    SetLightingLevel("Dimmer Ch 5", Ch5Level, "0s");
    SetLightingLevel("Dimmer Ch 6", Ch6Level, "0s");
    CloseSerial(1);
    end;
    end;
    -------------------------

    Vixen 2 Software:

    Setup to use the 'Generic Serial' plugin, configure the generic serial to 9660 baud, and set it to transmit both a text header, in this example I have used 'H' and a text footer 'F'..
    I settle on a event period of 250ms, which after various testings was about as fast as the touchscreen could reliably pickup the serial messages and do something with them..

    Have a play with the sequencer.. Its a pretty cool piece of software..

    ----------------------------


    I found issues when the sequence was too complicated and eventually settled for less channels and to have CBUS do a bit of the work.. Still plenty of tinkering to do..

    Oh and I will post up a video of the results once I finalise my setup for the silly season.. ;-D Should be by the end of the weekend..
     
    Roosta, Nov 26, 2014
    #12
  13. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Link to video showing the results..



    Ended up refining the logic code a little more.. Would like to have it do more than 6 channels however lots of testing and any more than that cbus seems to struggle with processing the commands..

    I know its not what the system was designed for however it serves my application quite ok, until next year.. :)
     
    Roosta, Dec 8, 2014
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.