News:

  • June 08, 2026, 05:40:01 AM

Login with username, password and session length

Author Topic: REQUEST: Pointers within MRX/WRX (Comm) blocks  (Read 5959 times)

Mike@Forshock

  • Sr. Member
  • ****
  • Posts: 58
REQUEST: Pointers within MRX/WRX (Comm) blocks
« on: July 14, 2021, 02:29:10 PM »
Would like to be able to use pointers with the communications blocks (MRX/MWX, etc.) for Status Bits.

Added rough example.

Can make reusable, repeated code with only a pointer (not within loops  ;)).
I can see how this could pose a challenge as the instructions are multi-scan and if the index/pointer is changed it would need to be stored within the code behind the scenes and some users may not realize this.  Perhaps only on the enable/power flow the pointer is stored?




franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: REQUEST: Pointers within MRX/WRX (Comm) blocks
« Reply #1 on: July 14, 2021, 02:44:44 PM »
What you are trying to do is very do-able as-is.

I see you are not doing it on leading edge, but in power flow at a variable interval.

I would recommend sticking it in a Stage program by itself and exit on success or completion (after moving those bits using array based OUT coils).

Basically, from $Main, before every RUN, you set your V's appropriately in the rung where you RUN this code block.

Also, with serial comm, you can only do one at a time anyway, so this single code block could work for a bunch of slaves, with $Main pacing the RUN based on your desired poll interval.

Mike@Forshock

  • Sr. Member
  • ****
  • Posts: 58
Re: REQUEST: Pointers within MRX/WRX (Comm) blocks
« Reply #2 on: July 14, 2021, 02:57:06 PM »
Didnt think of the stages because there is other code that is within the program that needs to process whether waiting for Success/Fail or not.

Creating a stage for each Success/Fail and for each MRX/MWX (different registers, coils, etc.) could get quite messy. 
With a JMP within the MRX/MWX, would this disable the Power Flow/Enable for the additional instructions?

Will give that a shot to test regardless, thanks.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: REQUEST: Pointers within MRX/WRX (Comm) blocks
« Reply #3 on: July 14, 2021, 03:42:46 PM »
$Main intializes all the indirect array values.

Stick it in its own program code block that has a few stages in it.  RST both array-based Success/Error bits, does the MRX w/indirect addressing JMPing to the corresponding OnSuccess or OnError where it SETs the array-based Success XOR Error bit, EXIT

$Main tracks the .Done bit of that code block.  When it's done, adjust the V index accordingling, RUN again.  Even that could be in its own mid-level stage PROGRAM, keeping $Main nice and clean.