
adccommunitymod (AutomationDirect) asked a question.
Created Date: April 17,2007
Created By: AZRoger
**** 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 used the following sequence of instructions to get date and time sorts of information from PLC memory. I have highlighted two extra BMOVE instructions that were required to get a valid number for I3 in line 8700. Without the extra BMOVEs I3 wound up with a value (as printed) of =3? (equal3questionmark). Do the S205_ assignment statements alter the SHARED memory contents? It looks a lot like they do. I checked the manual and didn't find anything that mentioned how long the SHARED values would be valid. Has anyone done tests? Is is documented somewhere I haven't found? The program now works. But every BMOVE takes a scan-time to execute so I'd like NOT to add any more than I need. 8400 REM Do the Minutes stuff first 8500 BMOVE R,VH(7766),VH(7777) 8510 MINUTEOFDAY=PICK(SHARED(4),B)*60+PICK(SHARED(2),B) 8520 S205_VB(1443)=MINUTEOFDAY:rem show raw minutes 8525 BMOVE R,VH(7766),VH(7777): rem do this again 8530 HOURMIN=PICK(SHARED(4),B)*100+PICK(SHARED(2),B) 8540 S205_VB(1444)=HOURMIN:rem show as HHMM 8570 REM Now do the day of the year stuff for Sunrise, etc. calcs 8580 BMOVE R,VH(7766),VH(7777): rem do this again 8700 I3=PICK(SHARED(10),B):rem get the month Roger
Created Date: April 17,2007
Created by: FACTSTech
When using BMOVE Read, you need to get the data out SHARED memory before doing any other backplane interface instructions (BMOVE or S205_).
The S205_ statement does use SHARED memory but it is transparent to the programmer unlike BMOVE/SHARED.
I would recommend changing your code as follows if reducing the number of backplane interface instructions is important to your application:
8400 REM Do the Minutes stuff first
8500 BMOVE R,VH(7766),VH(7777)
8510 MINUTEOFDAY=PICK(SHARED(4),B)*60+PICK(SHARED(2),B)
8520 HOURMIN=PICK(SHARED(4),B)*100+PICK(SHARED(2),B)
8530 I3=PICK(SHARED(10),B):rem get the month
8540 S205_VB(1443)=MINUTEOFDAY:rem show raw minutes
8550 S205_VB(1444)=HOURMIN:rem show as HHMM
Created Date: April 18,2007
Created by: AZRoger
FACTSTech,
Thanks for the explanation. I made the change you suggested. I also discovered several other places in my code where I referenced the SHARED space after an S205_ operation. They are fixed now also.
Regarding performance: I know the changes I just made improve performace of the BASIC performace (fewer backplane accesses). I'm not too concerned about blinding speed in the BASIC program. However, I'd like to be as non-disruptive as possible to the PLC scans.
So I have a further question. Is time allocated on every scan for backplace access for the CoProcessor regardless of whether the CoProcessor uses it? I have a DELAY 2000 in the main loop to reduce impact on the PLC scans. Is this delay helpful at all? IF not, I'll take it out and get closer to real-time response from the BASIC fucntions.
Roger
Created Date: April 19,2007
Created by: FACTSTech
>Is time allocated on every scan for backplace access for the CoProcessor regardless of whether the CoProcessor uses it?
Yes. The PLC CPU grants the BASIC CoProcessor access to the backplance once every PLC scan. This happens during the 'CPU Bus Communication ' portion of the PLC scan. See page 3-18 to 3-31 of the D4-USER-M manual for detailed explanation of the PLC scan cycle.
>I have a DELAY 2000 in the main loop to reduce impact on the PLC scans. Is this delay helpful at all?
This will not affect the PLC scan time.
Created Date: April 19,2007
Created by: AZRoger
Thanks.
Created Date: April 17,2007
Created by: AZRoger
I used the following sequence of instructions to get date and time sorts of information from PLC memory. I have highlighted two extra BMOVE instructions that were required to get a valid number for I3 in line 8700. Without the extra BMOVEs I3 wound up with a value (as printed) of =3? (equal3questionmark).
Do the S205_ assignment statements alter the SHARED memory contents? It looks a lot like they do. I checked the manual and didn't find anything that mentioned how long the SHARED values would be valid. Has anyone done tests? Is is documented somewhere I haven't found?
The program now works. But every BMOVE takes a scan-time to execute so I'd like NOT to add any more than I need.
8400 REM Do the Minutes stuff first
8500 BMOVE R,VH(7766),VH(7777)
8510 MINUTEOFDAY=PICK(SHARED(4),B)*60+PICK(SHARED(2),B)
8520 S205_VB(1443)=MINUTEOFDAY:rem show raw minutes
8525 BMOVE R,VH(7766),VH(7777): rem do this again
8530 HOURMIN=PICK(SHARED(4),B)*100+PICK(SHARED(2),B)
8540 S205_VB(1444)=HOURMIN:rem show as HHMM
8570 REM Now do the day of the year stuff for Sunrise, etc. calcs
8580 BMOVE R,VH(7766),VH(7777): rem do this again
8700 I3=PICK(SHARED(10),B):rem get the month
Roger