This is a tough one, but I know people smarter than me are here to help!
Background and Configuration
I have integrated Opto22’s Modbus Integration Kit ( http://www.opto22.com/site/downloads/dl_drilldown.aspx?aid=4206 ) in the attached PAC Control Professional 9.6d project. For the modbus server, I am using “Modbus Server Pro” v3.3 for Mac, http://www.apphugs.com/modbus-server.html.
To make the project run in your environment, you will need to change the string variables sIPPORT_CYCLOTRON and sIPPORT_TMS initial value to the IP address and port of your modbus server. To get the dasCyclotronFastData chart to run, you will need to set the modbus input register 901 to 32.
Read from modbus many registers at different time intervals, and write those values to files. Some data needs to be read at a “fast” interval, every 5 seconds. Some data at a “slow” interval, every 60 seconds. I have created charts for fast and slow data reads.
Problem / Bug / Issue
This issue I am having is, in chart dasCyclotronFastData, function block 76 Tuner Position, is writing data multiple times (up to 10 times!), but I am only reading the data once.
All other blocks in that chart are working correctly, reading the data once and writing once. The dasCyclotronFastData chart writes to c:\Datastore\das_fast_data.txt. That is where the multiple values for “tuner position” are showing up. The dasCyclotronSlowData chart writes to c:\Datastore\das_slow_data.txt. There are no duplicates in that file. If any chart has an error in reading data, they all write to c:\Datastore\das_error_data.txt.
The dasCyclotronFastData chart reads once every 5 seconds. The dasCyclotronSlowData chart reads once every 60 seconds.
Request / Help / Guidance
First I am asking is why is function block 76 Tuner Position writing data multiple times, when the other blocks are not?
What I am also requesting is architecture and programming guidance. Is this the best way to structure the code to meet the goal?
This code is hard to maintain. If we add additional elements to capture, we have to add additional blocks. Is there a way to use tables to loop through the data? Could subroutines be created?
Do not worry about hurting my feelings or stepping on my toes! Honest and constructive feedback is what I am asking for to help me learn.
Thank you community.