Announcement

Collapse
No announcement yet.

PxK : Use RS485 Port Ready bit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • kewakl
    replied
    Originally posted by kewakl View Post
    I do not see this working for the RS485 comms hang during a runtime transfer.
    Does the 485 PortReady bit go false during a runtime transfer?
    It seems not!
    I used this timestamping rung. I never see the SoloCommsTimestamp word change after a runtime transfer.
    Code:
    .
    .
    .         MST-0.0.0.35                | CPD
    .-------+-----]^[-----+---------------+
    .       |             |               | SysTimeStamp     SoloCommsTimestamp
    .       |             |               |
    .       | MST-0.0.0.35|               +----------------------------------
    .       +-----]v[-----+
    .
    .
    .
    SysTimeStamp S32 formatted MMDDYYHHMN So I see 607191222

    Leave a comment:


  • kewakl
    replied
    I do not see this working for the RS485 comms hang during a runtime transfer.
    Does the 485 PortReady bit go false during a runtime transfer?

    I am considering using the CPU Event Log String 01 entry - looking for a "NEW PROJ" entry instead of the 485 Port Ready bit.
    We use this concept on another project, so, I think it is doable.
    Last edited by kewakl; 06-03-2019, 11:15 AM.

    Leave a comment:


  • kewakl
    started a topic PxK : Use RS485 Port Ready bit

    PxK : Use RS485 Port Ready bit


    I am attempting to add the RS485 Port Ready status bit to 'existing' code.
    Does this code appear to have handled the bases for using the Port Ready status bit?


    The existing code (in black) cycles thru reading/writing from/to two Solo temperature controllers.
    The new code (in red) is to recover from comms locking up during a RUNTIME project transfer.

    The reads/writes are divided into 'modules' 1 - 9.
    Modules 1-6 are for normal operation.
    At the start of the heat cycle, I enable modules 7-9 to allow steam to be slowly introduced into the plumbing/heat exchanger to minimize any condensate's conversion to steam. (PurgeMode)
    The code below does the COMMS portion (correctly, it seems)
    Tag description:
    _ACTIVE is a bitfield WORD that tracks which comms module is currently active.
    _INIT is a bitfield WORD that tracks which comms modules that have been initialized in this round-robin cycle.

    _ACTIVE:x gets reset on Comms Success
    _INIT:x gets reset on Comms Failout on retry

    both get reset at end of round-robin cycle

    So far, this has cycled without error - except during the occasional project transfer to cpu - so I want to incorporate the Port Ready bit(RED).
    I have observed that clearing the _ACTIVE and _INIT words will get the comms going again after a project transfer.
    So I will use the Port Ready false state to ZERO those words, and will use the true state to allow the timer to elapse, triggering the MATH that counts/cycles thru the comms modules.

    The first code block is the supervisory section for the comms
    There may be other ENABLE logic for TMR (COMM_T) -- not shown
    Code:
    .
    .         PurgeMode                                   | CPD
    .-----+-------]/[-------------------------------------+ 6       Max_Comms
    .     |                                               |
    .     |                                               +--------------------------
    .     |
    .     |    PurgeMode                                  | CPD
    .     +------] [--------------------------------------+ 9       Max_Comms
    .                                                     |
    .                                                     +--------------------------
    .
    .
    .
    .
    .
    .                            RS485_
    .          _Active          PortReady                 | TMR         COMM_T
    .------------] [---------------] [--------------------+
    .          AlwaysOff                                  |
    .------------] [--------------------------------------+ (x) mSec
    .           _RST                                      |
    .------------] [--------------------------------------+
    .                                                     |
    .                                                     +-----------------
    .
    .        COMM_T.Done                                  | Math    COMM_TASK
    .------------] [--------------------------------------+ COMM_TASK + 1
    .                                                     |
    .                                                     +------------------------
    .
    .
    . ~~~
    .        COMM_TASK
    .             Max_Comms                                         | CPD
    .------+-----]>=[------+----------------------------------------+ 0       COMM_TASK
    .      |               |                                        | 0       _INIT
    .      |   RS485_      |                                        | 0       _ACTIVE
    .      |   PortReady   |                                        |
    .      +------]/[------+                                        +------------------------
    .
    .
    .
    .
    . ~~~
    .
    The next code block is the actual read or write handler and success/timeout detect.
    I had trouble with using a .Success rising edge, so I used N.O. and reset it.
    Idea:
    Trigger comms,
    set _ACTIVE:1
    set _INIT:1
    (_INIT:1 disallows a double-triggering of the comms instruction on success.)
    Check for success, wait ~50mS for success.
    On success, clear _Active word which will allow the COMM_T timer to elapse, triggering the next comms module.
    If NOT success and timeout, increment err count, set ErrFlag - left a following code block handle retry

    I will clear the comms error count differently when finished. Right now, is it cumulative - it needd to be reset on a success - currently it is a visual aid.
    Code:
    [EDIT this code block is revised in later posts]
    .         COMM_TASK
    .                 1     _INIT:1                                     | MWX            TC_SP
    .-------------]=[----------]/[-----+----------------+---------------+
    .                                  |                |               |
    .                                  |                |               +------------------------
    .                                  |                |    
    .                                  |                |               | CPD
    .                                  |                +---------------+ 1       _INIT:1
    .                                  |                                | 1       _ACTIVE:1
    .                                  |                                |
    .                                  |                                +-----------------------
    .                                  |                    
    .                                  |  TC_SP.Success                 | CPD    
    .                                  +-----] [------------------------+ 0       _ACTIVE:1
    .                                  |                                | 0       TC_SP.Success
    .                                  |                                +------------------------                                
    .                                  |                    
    .                                  |  TC_SP.Success                 | STMR            TC_SP_Err
    .                                  +-----]/[--------+---------------+ (Pre = 5)
    .                                                   |               +------------------------                                
    .                                                   |   TC_SP_Err            
    .                                                   |    .Done      | MATH    TC_SP_ErrCt
    .                                                   +----] [----+---+ TC_SP_ErrCt + 1
    .                                                               |   |
    .                                                               |   +------------------------
    .                                                               |
    .                                                               |   | CPD
    .                                                               +---+ 1       TC_SP_ErrFlag
    .                                                                   |
    .                                                                   +------------------------
    .
    The next code block is for retrying and retry max limit checking
    If the previous code block sets the TC_SP_ErrFlag because of a comms fail,
    the next code block will wait and then retrigger the 'previous' code block up to 5 retries

    Code:
    .
    .       TC_SP_ErrFlag                                              | STMR TC_SP_Retry
    .------------] [---------+-----------------------------------------+
    .                        |                                         |(Pre = 10)
    .                        |                                         +-------------------------
    .                        |
    .                        | TC_SP_Retry        TC_SP_ErrCt
    .                        | .Done                     5             | MATH G_TC_SP_ErrCt
    .                        +-------] [-----+-------]>=[-----+--------+ G_TC_SP_ErrCt + 1
    .                                        |                |        |
    .                                        |                |        +-------------------------
    .                                        |                |
    .                                        |                |        | CPD
    .                                        |                +--------+ 1 TC_FAIL_CTXT
    .                                        |                         | 1 TC_FAIL_FLAG
    .                                        |                         | 0 TC_SP_ErrCt
    .                                        |                         | 0 TC_SP_ErrFlag
    .                                        |                         |
    .                                        |                         +-------------------------
    .                                        |  TC_SP_ErrCt
    .                                        |          5              | CPD
    .                                        +-------]>[---------------+ 0 _INIT:1
    .                                                                  | 0 TC_SO_ErrFlag
    .                                                                  |
    .                                                                  +-------------------------
    I do not use automatic polling because I cannot determine which comms instruction will be active if I stop and then restart the comms procedure (or because of locked-up comms after project transfer) -- in short, I can start/stop/sync this procedure to anything I need.
    Last edited by kewakl; 06-10-2019, 08:32 AM.
Working...
X