
adccommunitymod (AutomationDirect) asked a question.
Created Date: February 04,2009
Created By: bfitz
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
I have a couple of questions about using the ONPLC interrupt in the Basic CP. First some background: the CP will be attached to a pressure sensor on serial port 2. During normal operation, the CP will constantly poll the sensor for a couple of data points and update the PLC with those values. I also intend to use the CP's ONTIME interrupts to perform rate-of-change calculations on the values from the sensor. Those values will also be sent to the PLC. I am planning to use SHARED and BMOVE to transfer these data points to the PLC. I am investigating using the ONPLC interrupt to trigger infrequent tasks (sensor initialization, calibration, etc.) from the PLC. My first question is, can I use the S205_ comm method from within the ONPLC interrupt routine? Next, how will using this method affect my plans to use SHARED and BMOVE to copy data to the PLC during normal operations? I am wondering if this will cause trouble if the program interrupts when it is in the middle of compiling data to be sent to the PLC. If it makes any difference, the chip in the F2-CP128 is labeled V1.02 Brian
Created Date: February 04,2009
Created by: FACTSTech
See page 2.8 (22 of 52) of the F2-CP-M manual for a description of the ONPLC instruction:
http://www.facts-eng.com/manuals/f2cpm.pdf
>I am investigating using the ONPLC interrupt to trigger infrequent tasks (sensor initialization, calibration, etc.) from the PLC. My first question is, can I use the S205_ comm method from within the ONPLC interrupt routine?
You could, but that would defeat the purpose of a PLC initiated interrupt (ONPLC). The S205_ statement uses SHARED(0) memory so if the ONPLC interrupt occurred between a BMOVE read and the reading of SHARED memory then SHARED(0) would be overwritten with the S205_ data. It would be much simpler to poll C bits within your main loop for these infrequent task triggers (IF S205_C(0) THEN ..., IF S205_C(1) THEN ..., etc).
>Next, how will using this method affect my plans to use SHARED and BMOVE to copy data to the PLC during normal operations? I am wondering if this will cause trouble if the program interrupts when it is in the middle of compiling data to be sent to the PLC.
The ONPLC interrupt uses a different block of SHARED memory than BMOVE reads and writes uses so there should not be any effect. See page 2.5 (19 of 52).
Created Date: February 04,2009
Created by: bfitz
>You could, but that would defeat the purpose of a PLC initiated interrupt (ONPLC).
Not entirely. I understand that I can push data to the CP from the PLC with an ONPLC interrupt. The need for S205_ stems from the need to control bits (outputs) in the PLC at certain steps in the interrupt procedure. The S205_ statement would be the most logical way to do this. Also, the interrupt call wouldn't actually push any data to the CP other than a code that would end up in SHARED(384).
>The S205_ statement uses SHARED(0) memory so if the ONPLC interrupt occurred between a BMOVE read and the reading of SHARED memory then SHARED(0) would be overwritten with the S205_ data.
If I understand this correctly, I could reserve a memory location at the beginning of the memory block that is getting transferred to the PLC for S205_ space. This location would just be ignored on both the PLC and CP sides. Would this method work to avoid problems with an S205_ occuring between any BMOVE read and use of SHARED(xxx) memory? Does an S205_ write use SHARED(128)?
>The ONPLC interrupt uses a different block of SHARED memory than BMOVE reads and writes uses so there should not be any effect. See page 2.5 (19 of 52).
I did notice this; however, I am more concerned with writing (and reading) _during_ the interrupt. For my application, I can't transfer the data upfront (it wouldn't exist yet.)
Brian
Created Date: February 05,2009
Created by: FACTSTech
S205_ read (Ex. X=S205_VB(2000) ) will use SHARED(0). S205_ write (Ex. S205_VB(2000)=1234 ) will use SHARED(128).
If you do a BMOVE read the steps should be:
(1) Execute BMOVE read instruction
(2) Copy data from SHARED(0) to SHARED(127) (range depends on number of bytes read) to variables
If you do a BMOVE write the steps should be:
(1) Load SHARED(128) to SHARED(255) memory (range depends on number of bytes to write)
(2) Execute BMOVE write instruction
If an ONPLC interrupt is enabled and a valid WX instruction is executed then the F2-CP128 interpreter will go to the line number specified in the ONPLC instruction. The desired data should be copied from SHARED(256)-SHARED(387) in your interrupt routine before anything else is done. If you want to execute S205_ instruction(s) after this but before the RETI that should be OK.
Created Date: February 05,2009
Created by: bfitz
Ok, so SHARED(0) and SHARED(128) are used by the S205_ instructions.
In the scenario:
(1) Execute BMOVE read instruction for say 10 memory locations.
(2) Interrupt occurs in which S205_ transfers take place.
(3) Copy data to variables.
In this scenario, I understand that SHARED(0) will be overwritten with S205_ read data; what happens to the data in SHARED(1-10)? Is it left untouched provided the interrupt routine does not use a BMOVE?
I apologize if it seems like I am beating a dead horse, but I want to be sure I completely understand these functions before I start using them.
Thanks,
Brian
Created Date: February 05,2009
Created by: FACTSTech
>In this scenario, I understand that SHARED(0) will be overwritten with S205_ read data; what happens to the data in SHARED(1-10)? Is it left untouched provided the interrupt routine does not use a BMOVE?
SHARED(1 - 10) should remain unchanged in this scenario. Regardless, I would recommend disabling the ONPLC interrupt before the BMOVE read and re-enable it after the data has been copied from SHARED memory.
Unless the PLC trigger for infrequent tasks is very time sensitive (CoProcessor must do something within a PLC scan time or two) I would recommend polling C bits within your main loop and calling a GOSUB for these tasks.
Created Date: February 04,2009
Created by: bfitz
I have a couple of questions about using the ONPLC interrupt in the Basic CP. First some background: the CP will be attached to a pressure sensor on serial port 2. During normal operation, the CP will constantly poll the sensor for a couple of data points and update the PLC with those values. I also intend to use the CP's ONTIME interrupts to perform rate-of-change calculations on the values from the sensor. Those values will also be sent to the PLC. I am planning to use SHARED and BMOVE to transfer these data points to the PLC.
I am investigating using the ONPLC interrupt to trigger infrequent tasks (sensor initialization, calibration, etc.) from the PLC. My first question is, can I use the S205_ comm method from within the ONPLC interrupt routine? Next, how will using this method affect my plans to use SHARED and BMOVE to copy data to the PLC during normal operations? I am wondering if this will cause trouble if the program interrupts when it is in the middle of compiling data to be sent to the PLC.
If it makes any difference, the chip in the F2-CP128 is labeled V1.02
Brian