Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Mike@Forshock 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?
-
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.
-
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.
-
$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.