RS232 control through Colour Touch screen

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by ltlbigchief, Jun 26, 2008.

  1. ltlbigchief

    ltlbigchief

    Joined:
    Jul 24, 2005
    Messages:
    32
    Likes Received:
    0
    Location:
    Gold Coast, Queensland, Australia
    Hi guys,

    I'm trying to control an Advantage Gen III AC system through their Home Automation module. I can do this fine via hyperterminal, but having no luck through the colour touch screen.

    What is the point of the serial index value that you use in the 'OpenSerial' command in the logic engine? And also, why 1-4, what does this relate to?

    I spoke to a couple of people today on the Clipsal help line and they didn't know? Reason I'm asking is, this is where I think I'm getting stuck, as I've used the log window to see what my code is sending out and it's showing me that it's sending the correct RS232 string, but it does nothing.

    I've controlled the AC via hyperterminal from my laptop, so I know cabling and the AC Home Auto module is working. When I connect to the Touch screen via hyperterminal I receive nothing, so that's why I think it maybe in my initialisation??

    This is what I have:
    OpenSerial(1, 1, 19200, 8, 1, 0, 0);

    Anyone know? Or has anyone controlled a Advantage Air Gen III air conditioner???

    Thanks for any help!!!
    :)
     
    ltlbigchief, Jun 26, 2008
    #1
  2. ltlbigchief

    znelbok

    Joined:
    Aug 3, 2004
    Messages:
    1,151
    Likes Received:
    17
    I have a GENIII with a HA and I use CQC to control it.

    Since you have confirmed that it is all working, are you sure the cable you have used between the touchscreen and the HA is OK?

    I cant help you though on the initialization side of things though as my system is all CQC.

    BTW - CQC has a great driver for the Gen III, it automatically detects the number of zones, allows you to rename zone (You can use lower case - AA use all uppercase on their touchscreen). You can also increment the temp in 0.1 deg increments. You may say you don't need that, but it allows me to set a room to 22.8 instead of 22.5 or 23 which does make a difference.

    Their protocol is not complete though - especially in the Fresh air module control. You will get replies indicating correct state, but you cant send the same commend to it because it wont understand it.

    They [AA] are supposed to be working on a C-Bus interface as well, but there has been delays in its development.

    Mick
     
    znelbok, Jun 27, 2008
    #2
  3. ltlbigchief

    Matty

    Joined:
    Oct 15, 2004
    Messages:
    131
    Likes Received:
    0
    Hi ltlbigchief,

    One thing to be careful of is the use of CR and LF. These are somewhat invisible to you in hyperterminal. I have been caught out many times with the incorrect use of CR in place of LF or CRLF where it should be LFCR. To actually see these 'invisible' characters have a look around for a serial emulator that has an option to show you all ascii characters.

    When you go back to PICED to implement these you can add a CR to the end of a string by putting in #13. For example:

    WriteSerial(1, 'HVACon'#13);

    A carriage return and line feed pair would be

    WriteSerial(1, 'HVACon'#13#10);

    Hope this has helped.

    regards,

    Matty
     
    Matty, Jun 27, 2008
    #3
  4. ltlbigchief

    ltlbigchief

    Joined:
    Jul 24, 2005
    Messages:
    32
    Likes Received:
    0
    Location:
    Gold Coast, Queensland, Australia
    Thanks for your replies guys.

    Going back to the project on Monday, so I'll try your suggestions.

    Just another question, Matty I noticed the way you've written the writeserial command.

    It's the same format as I have done, just wondering, I spoke to Colin from Clipsal help today (He's the Best to speak to) and mentioned that I should have +#13 , can anyone confirm this? That's not what it says in the Help file.

    Thanks again.
     
    ltlbigchief, Jun 27, 2008
    #4
  5. ltlbigchief

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    What characters you use and where they should be depends entirely on the device you are sending information to.

    Serial communication is just a stream of bytes (or characters), with gaps between of indeterminate length (of time).

    When you send commands to some other device, that device may or may not process those commands character by character. some device will do this, and some want to see a line structure.

    A line structure means a bunch of characters with a terminator of some kind, the common terminators are CARRIAGE-RETURN and LINE-FEED.

    The carriage return character is #13 (this is also the ENTER key on your keyboard), the line feed is #10.

    If you made the device work using hyperterminal, but the device did not actually do anything until you pressed ENTER on your keyboard, then it wants line-structured commands terminated by CARRIAGE-RETURN. So in that case you need to put the #13 on the end.

    Bear in mind, Clipsal technical support don't, and can't, know the ins- and outs- of every other product out there that takes serial control. So you have figure out how to control the device including magical structure, command form, terminators, etc, and then give the device exactly what it wants.
     
    ashleigh, Jun 27, 2008
    #5
  6. ltlbigchief

    Richo

    Joined:
    Jul 26, 2004
    Messages:
    1,257
    Likes Received:
    0
    Location:
    Adelaide
    In pascal a string literal can consist of unquote character literals (as ordinal values) prefixed by a hash.

    so this is a single string literal

    'my string'#13

    and this is 2 string literals being concatenated using the addition symbol.

    'my string' + #13

    this is a compile fail because you have 2 seperate string literals with no operator

    'my string' #13

    (notice the space between the 'my string' and the #13)

    these are examples of the same string literal

    'ABC'
    #65#66#67

    So Colins advise is essentially the same as saying:

    'A' + 'B' + 'C'

    instead of

    'ABC'

    the end result is for all practical purposes the same.
     
    Richo, Jun 27, 2008
    #6
  7. ltlbigchief

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    In PICED V4.3, the logic help file has a topic called "Serial IO Examples" which goes through the steps of understanding a serial protocol and getting it working.

    The log form now has an option to log all logic sent and received serial characters, including carriage returns and line feeds. This helps a lot when getting serial control to work.
     
    Darren, Jun 27, 2008
    #7
  8. ltlbigchief

    ltlbigchief

    Joined:
    Jul 24, 2005
    Messages:
    32
    Likes Received:
    0
    Location:
    Gold Coast, Queensland, Australia
    Thanks again guys for your feedback.

    Richo thanks, I had a feeling it would be something like that.

    Darren, I've already been watching the log and I think I may already have that feature on, as I can see the RS232 strings going out when I press my buttons, but they're not doing anything (ie; with the AC unit). I think it maybe my cable, I have to check. I'm using the same cable to the AC unit from my PC (that works), as I'm using to the AC from the Touch screen (that didn't work).

    Just thought I'd let you guys know, I have done a fair bit of RS232 control through AMX, RTI and Prontoscript, etc. I'm pretty familiar with how it all works, which is why I thought I might had something wrong with the OpenSerial command??? I'm sure I did try changing serial cables too, but I'll have to double check when I get back to site........ :confused:

    Does anyone know what the serial index is for and what choices of 1-4 of represent? :cool:

    Does the PICED touchscreen simulator also simulate sending RS232 commands? Was just thinking if it does, I can test RS232 control of something else at home from my laptop.

    Super Thanks!!!!
     
    ltlbigchief, Jun 27, 2008
    #8
  9. ltlbigchief

    Darpa

    Joined:
    Apr 30, 2006
    Messages:
    426
    Likes Received:
    0
    Location:
    Australia
    I'm only thinking out loud here, as I have no experience with either the C-Touch or the Advantage Air equipment you are trying to program for, but here goes:

    Firstly, does the equipment you are using require a Null Modem cable? or just a simple straight-through one. Because it may well be the case that your PC will communicate to the Advantage equipment fine with HyperTerminal because your PC's serial port will allow a little leighway with regards to hardware or software flow control. Depending on whether the C-Touch and Advantage air unit each use either software or hardware flow control, and to what degree they use that flow control, you may need to make your own Null Modem cable.

    Can anyone here answer whether the C-Touch is classed as a DTE or DCE device?

    Also, what about the Advantage Air unit?

    If you can find out the flow control used for each one, then you're a step in the right direction.

    Here's a website that I've always found really useful when trying to work out which way to wire a Null Modem Cable for different equipment:
    www.lammertbies.nl/comm/info/RS-232_null_modem.html

    I hope this helps solve your problem, if any of this is indeed your problem.

    If not, best of luck nutting out the issue :)

    Darpa
     
    Last edited by a moderator: Jun 27, 2008
    Darpa, Jun 27, 2008
    #9
  10. ltlbigchief

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    The CTC is the same type of equipment as a bog ordinary PC (whatever that is).

    The old DTE / DCE terms have become somewhat cloudy with mystery and ambiguity over the years :(

    Its possible thatthe magic "serial index" needs to be the right value, but WHAT that value is, I don't know. Suggest you poke around in the help a big more.
     
    ashleigh, Jun 28, 2008
    #10
  11. ltlbigchief

    Darpa

    Joined:
    Apr 30, 2006
    Messages:
    426
    Likes Received:
    0
    Location:
    Australia
    A computer's serial port is classed as a DTE device, and an old dial-up modem's serial port is classed as DCE.

    Null Modem cables are intended to directly connect 2 DTE devices together without any other hardware in between. Basically all a Null Modem cable has is its Tx and Rx lines swapped, like an ethernet crossover cable. However there are many different types of Null Modem cables depdning on what Flow control is used, and also a heap of custom ones made by manufacturers for their respective devices.

    So if the C-Touch's serial port is the same as a computers, (which would make alot of sense), then it will have a DTE port. IF you can then find out whether the Advantage's serial port is also DTE, or whether it is DCE, you'll know for sure what cable to use.
     
    Darpa, Jun 28, 2008
    #11
  12. ltlbigchief

    znelbok

    Joined:
    Aug 3, 2004
    Messages:
    1,151
    Likes Received:
    17
    AA claim that you use a straight through cable (does not mean that it is right though - they also claim other things that are wrong, like how you connect the HA module to the system)

    Mick
     
    znelbok, Jun 28, 2008
    #12
  13. ltlbigchief

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    I've always found the best way is to ignore all the terminology and get the manufacturers pin-outs for their connectors, and then make up my own cable to suit.

    In the case of the CTC, its a bog-ordinary PC. So whatever a PC does, it does.

    Some useful references:

    The connector.

    The definition of the PC serial port pinout.
     
    ashleigh, Jun 28, 2008
    #13
  14. ltlbigchief

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    From the help file topic "Serial IO" :

    Although the logic engine supports up to four serial ports, the colour C-Touch only has one serial port. Just use index 1.

    Yes it does.
     
    Darren, Jun 30, 2008
    #14
  15. ltlbigchief

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    Darpa is bang on the money.

    When we first got the PAC and serial capability I spent a thousand of hours playing with all sorts of devices. Some interesting tricks and traps.

    I found that cable connections between the PC and a device using hyperterminal or PICED programming environment, required one format of pins 2 & 3 in the serial cable however, once the code was dropped into a PAC (in this case) the opposite pin out was often required to get things going. After the thousand hours I still can't put my finger on the DTE/DCE thing with C-Bus embedded devices.

    Carrage return and line feed or pair of, is very important, including the order.

    Be careful that you have to also read serial back into the C-Bus device in the manner the unit sends packets. Eg the Integra amp requires you send messages to it finished with CR (#13) however, requires you to read messages back looking for EOF (#26) (now known as sub). This little beauty took up 980 of the 1000 hours I spent playing with serial. ;)
     
    Last edited by a moderator: Jul 2, 2008
    Lucky555, Jul 2, 2008
    #15
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.