ASCII string

Discussion in 'C-Bus Serial Protocols' started by grssll, May 23, 2018.

  1. grssll

    grssll

    Joined:
    Jun 13, 2014
    Messages:
    47
    Likes Received:
    0
    Location:
    Sydney
    Trying to send RS232 sting from PACA.
    9600 Baud, 8 Data Bits, 1 Stop Bit, No Parity
    Initialisation
    OpenSerial(2, 2, 9600, 8, 1, 0, 1);
    Code
    once (GetLightingState("70_Master door close") = ON) then
    begin
    WriteSerial(2, '0101U');
    end;
    I can send this code from Ness M1 without any problems.
    What am I doing wrong here?
    Thanks
    George
     
    Last edited: May 23, 2018
    grssll, May 23, 2018
    #1
    1. Advertisements

  2. grssll

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,305
    Likes Received:
    17
    Location:
    Adelaide
    Looks like it should work... assuming you are trying to send ascii "0" "1" "0" etc..

    Have you checked the wiring/pinout?

    Nick
     
    NickD, May 23, 2018
    #2
    1. Advertisements

  3. grssll

    grssll

    Joined:
    Jun 13, 2014
    Messages:
    47
    Likes Received:
    0
    Location:
    Sydney
    Hi Nick,
    What I'm trying to send is 01 controller address, 01 motor address and U up.
    Thanks
     
    grssll, May 23, 2018
    #3
  4. grssll

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    299
    Likes Received:
    1
    Location:
    FNQ
    Do you need "carriage return" and/or "new line", something like #13#10?
     
    Mr Mark, May 23, 2018
    #4
  5. grssll

    grssll

    Joined:
    Jun 13, 2014
    Messages:
    47
    Likes Received:
    0
    Location:
    Sydney
    I’ve tried 0101U^M and it doesn’t work.
    Thanks
     
    grssll, May 23, 2018
    #5
  6. grssll

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,305
    Likes Received:
    17
    Location:
    Adelaide
    Putting ^M at the end of your string won't sent a CR.. it will send the ascii "^" and an ascii "M".

    If you want to send "0101U" as ascii, followed by a carriage return, you need to send

    WriteSerial(2, '0101U'#13);
     
    NickD, May 23, 2018
    #6
    Mr Mark likes this.
  7. grssll

    grssll

    Joined:
    Jun 13, 2014
    Messages:
    47
    Likes Received:
    0
    Location:
    Sydney
    Hi Nick,
    Thanks for that but still unable to control the motor.
    Will have a look into wiring again.
    Thanks
     
    grssll, May 23, 2018
    #7
  8. grssll

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    768
    Likes Received:
    28
    Location:
    Adelaide, Australia
    Have you connected a 24VAC supply to the PAC?

    Also some device need either a LF or both CR LF so try

    WriteSerial(2, '0101U'#10);

    and

    WriteSerial(2, '0101U'#13#10);
     
    Ashley, May 23, 2018
    #8
  9. grssll

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    358
    Likes Received:
    8
    Location:
    Sydney
    Hey, Not wanting to be too 'suck eggy' but just because it has caught me out before, but you do have your cable plugged into the RS232 port 2 as per your initialisation?


    Just noticed.. you have said you wanted no Parity, but your code is written for Odd by the looks?
    I think you may want:
    OpenSerial(2, 2, 9600, 8, 1, 0, 0);

    From the help file:
    For use with the Pascal Automation Controller, there are the following limitations :
    ·SerialPortIndex is the User Port number (1 or 2)
    ·COMPortNo is the User Port number (1 or 2)
    ·BaudRate is limited to 600, 1200, 2400, 4800, 9600, 19200, 38400
    ·DataBits is limited to 7 or 8
    ·StopBits is limited to 1 (= one stop bit) or 2 (= two stop bits)
    ·FlowControl is not used
    ·Parity options are limited to 0 (= none), 1 (= odd) or 2 (= even)

    To open serial port number 1, with COM Port 4, 9600 baud, 8 data bits, 1 stop bit, no flow control, no parity :
    OpenSerial(1, 4, 9600, 8, 1, 0, 0);
    OR
    OpenSerial(1, 4, 9600, 8, scOneStopBit, scNoFlowControl, scNoParity);
     
    jboer, May 24, 2018
    #9
  10. grssll

    grssll

    Joined:
    Jun 13, 2014
    Messages:
    47
    Likes Received:
    0
    Location:
    Sydney
    Yes, my mistake with initialisation as it should be no Parity.
    I've changed it and...........no luck but then,
    Changed all to port 1 and its working.
    Just wondering if its possible that port 2 on PACA is fried or am I making a mistake
    when cable plugged in PACA port 2 and initialisation is OpenSerial(2,2)?

    OpenSerial(1, 1, 4800, 8, 1, 0, 1);
    OpenSerial(2, 2, 9600, 8, 1, 0, 0);

    once (GetLightingState("70_Master door close") = ON) then
    begin
    WriteSerial(2, '0101U'#10);
    end;
    once (GetLightingState("72_Master door open") = ON) then
    begin
    WriteSerial(2, '0101D'#13#10);
    end;
    once (GetLightingState("71_Master door stop") = ON) then
    begin
    WriteSerial(2, '0101S');
    end;

    Thanks
    George
     
    Last edited: May 24, 2018
    grssll, May 24, 2018
    #10
  11. grssll

    grssll

    Joined:
    Jun 13, 2014
    Messages:
    47
    Likes Received:
    0
    Location:
    Sydney
    Faulty second serial port on PACA.
    Does anyone know if its possible to repair?
    Don't want to throw out almost new module.
    Thanks
     
    grssll, May 27, 2018
    #11
  12. grssll

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    358
    Likes Received:
    8
    Location:
    Sydney
    Well, you should be able to send back on warranty if new? If not, if you are ok with soldering and in particular surface mount you should be able to replace the RS232 transceiver. It will most likely be the transceiver, may have had a static shock or ect or just DOA.
     
    jboer, Jun 9, 2018
    #12
    1. Advertisements

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.