newbie help-logic code

Discussion in 'General Discussion' started by micelisun, Dec 20, 2008.

  1. micelisun

    micelisun

    Joined:
    Aug 1, 2008
    Messages:
    11
    Likes Received:
    0
    I have zero experience in writing serial commands and have a problem. Need to simulate a button press in a Lutron processor from a DLT. Basically if anyone could save me some time and headache by posting an example it would be greatly appreciated.
     
    micelisun, Dec 20, 2008
    #1
  2. micelisun

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    I doubt many people here will have any experience with Lutron processors, given C-Bus is relatively new in the US market.

    If you can post some details about the Lutron serial protocol here we may be able to get you started.

    Nick
     
    NickD, Dec 21, 2008
    #2
  3. micelisun

    micelisun

    Joined:
    Aug 1, 2008
    Messages:
    11
    Likes Received:
    0
    here are the parameters: 9600 baud, 8 data bits, 1 stop bit, no parity, no xon/xoff. Lutron receives in hex or ascii. I am simply trying to simulate a button press in the lutron processor from a DLT. Might be dumb question but would I need a null modem? Lutron is a DCE. Any help would be greatly appreciated, I was talked into using clipsal on a rather large project and still need to control the lutron sivoia shades.
    Thanks
     
    micelisun, Dec 26, 2008
    #3
  4. micelisun

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    As in all cases go to the PICED Help files for info - I don't think I have seen a better help file.

    Before you get off and running you will have to get the basics right.

    If you are using a PAC unit you will have to power it via a 16-24V AC - the CTC is unit powered.

    No matter how much I tried (some time ago now) I could not tie down the DCE / DTE thing with PAC. Have a couple of serial cables (pins 2, 3 & 5) handy plus some changeovers. If you are testing using a PC and Hyper terminal to your Lutron unit don't be surprised if one cable works for the PC and another arrangement works with the PAC.

    Once you have the electrical connections sorted you need to write logic code to get the serial comms happening.

    Initialise the serial port with the parameters from your post above. Once you have a serial port open you should read it into a string constantly (small buffer)

    Search the forums for serial - some time ago Phil.H posted a training programs that dealt with serial for a starter like yourself. Don't forget the PICED help files ;)

    Found it = http://www.cbusforums.com/forums/showthread.php?t=1845&highlight=serial+logic
     
    Last edited by a moderator: Dec 26, 2008
    Lucky555, Dec 26, 2008
    #4
  5. micelisun

    PSC

    Joined:
    Aug 3, 2004
    Messages:
    626
    Likes Received:
    0
    Location:
    Brisbane, Australia
    Where is Phil.H these days...
     
    PSC, Dec 27, 2008
    #5
  6. micelisun

    micelisun

    Joined:
    Aug 1, 2008
    Messages:
    11
    Likes Received:
    0
    Thanks for the help, I think at this point simply connecting to the unit would be a great accomplishment. I am using a Mark II b&w but am trying to connect via a pc interface through c-bus. Will it work that way?
     
    micelisun, Dec 28, 2008
    #6
  7. micelisun

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Yes, indeed. He was such a great bloke. I miss him terribly :( (sniff)
     
    Darren, Dec 31, 2008
    #7
  8. micelisun

    micelisun

    Joined:
    Aug 1, 2008
    Messages:
    11
    Likes Received:
    0
    so I can connect to the Lutron processor through hyper term and make the shade respond to commands. There is a logic error when I try to do it through c-bus (opening the com port) Is there something I'm missing here
    Thanks in advance
     
    micelisun, Jan 2, 2009
    #8
  9. micelisun

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    I checked the Member List - Phil.H had 482 posts up until September 2007. From reading his posts he seemed to have a healthy sense of humor and tried to help people often.

    The contents of this post are a bit worrying though, http://www.cbusforums.com/forums/showthread.php?p=18366#post18366
    I hope nothing untoward happened to him ???

    He did seem like a good bloke - but I can't vouch for that personally. ;)
     
    Lucky555, Jan 2, 2009
    #9
  10. micelisun

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    If you have a logic error - then that has to be fixed before you get anywhere. What sort of logic error is it.
    Drop your code into a post - you will need to provide a little more information if anyone is going to have a chance to help you out.

    Don't forget the cable you use between the PC (hyperterminal) and Lutron unit may end up different to the cable pin out between the C-Bus embedded device and the Lutron unit.

    Have you told us what C-Bus unit you are using ??? - need to read all the posts above - just got back from a lovely holiday on the Coast :):):)
     
    Lucky555, Jan 2, 2009
    #10
  11. micelisun

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    You connect to the MkII to program it - when it reboots and if you have written the logic code properly it will communicate with the Lutron unit via its serial port.

    Put a test page on the screen with some buttons that send known messages to the Lutron unit etc....
     
    Lucky555, Jan 2, 2009
    #11
  12. micelisun

    micelisun

    Joined:
    Aug 1, 2008
    Messages:
    11
    Likes Received:
    0
    I am using a pc interface and a Mark II. I am assuming that since both the Lutron and Clipsal PC INT are female db9 connections that I should be swapping pin 2 and pin 3. I did that and the logic error I have isn't happening when I compile in Piced. ..........

    Logic Run-time Error R100 at line 17:0 - Other error (Unable to open com port (win error code: 2))
     
    micelisun, Jan 4, 2009
    #12
  13. micelisun

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    You say you have it working to some extent from Hyperterminal.... this would suggest that you have a suitable cable for connecting to the PC.

    You can run the logic engine in PICED on the PC that you are working on.. it might be better to get it all working in PICED on the PC, debug the logic code there, and then tackle any issues with cables once we know the logic code is right.

    With your problem with the run time error... can you post the line of code where you are trying to open the com port?

    Nick
     
    NickD, Jan 4, 2009
    #13
  14. micelisun

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    For PICED the valid com port is the serial port of the machine / PC you are using. It might be that for PICED / PC the correct com port is com 2 or com 3 where your C-Bus MKII will be com 1. If this is the case you will have to change all references to the correct com port number when you are ready to drop the code into the unit.
     
    Lucky555, Jan 6, 2009
    #14
  15. micelisun

    PSC

    Joined:
    Aug 3, 2004
    Messages:
    626
    Likes Received:
    0
    Location:
    Brisbane, Australia
    Personally I never liked the guy, he kept going on about his past "I used to be an integrator you know!".

    Quite frankly I'm glad he's not around, he wasn't funny nor helpful. He had one of those I'm from "The Shire" attitudes, you know someone is born in "The Shire", went to school in "The Shire", married someone from "The Shire", bought a house in "The Shire" and never leaves "The Shire"!

    Anyway this forum is a far better place now that he's not around... :eek:
     
    PSC, Jan 7, 2009
    #15
  16. micelisun

    ICS-GS

    Joined:
    Nov 1, 2004
    Messages:
    347
    Likes Received:
    0
    Location:
    SE Melbourne
    There's no need to be nasty....:rolleyes:
     
    ICS-GS, Jan 7, 2009
    #16
  17. micelisun

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    PSC - you are taking a pretty hard line there. This poor bloke must have done something against you to warrant that blast ??? Maybe you're just getting old and cranky, maybe you were envious of Phil.H and just need to admit it.

    That "Shire" place doesn't sound too bad. :)
     
    Lucky555, Jan 7, 2009
    #17
  18. micelisun

    ICS-GS

    Joined:
    Nov 1, 2004
    Messages:
    347
    Likes Received:
    0
    Location:
    SE Melbourne
    Do people from "the shire" have 2 heads, 17 toes or some other misfigurement?:p. I think i may know some people from there!
     
    ICS-GS, Jan 8, 2009
    #18
  19. micelisun

    PSC

    Joined:
    Aug 3, 2004
    Messages:
    626
    Likes Received:
    0
    Location:
    Brisbane, Australia
    Lucky, if you knew Phil.H you would know exactly what I'm talking about! :rolleyes:
     
    PSC, Jan 9, 2009
    #19
  20. micelisun

    micelisun

    Joined:
    Aug 1, 2008
    Messages:
    11
    Likes Received:
    0
    I am using this code in the initialisation section.... OpenSerial(1, 1, 9600, 8, 1, 0, 0); is that correct?
     
    micelisun, Feb 1, 2009
    #20
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.