Mas01
Member
Many thanks for this - I will need some time to digest it. There's a lot in there.you need to show a bit more code, it is difficult to see what you are trying to do but to start with it is not usual to write the code in OB1, you create a program block FC (or is it an FB) so long I cannot remember, there you write the code & call it in OB1, you split the program into manageable sections like:
FC1 Analogues
FC2 Digital input map
FC3 Digital output map.
FC4 Laser Data manipulation
FC5 Motor calls
FC6 Valve calls
FC7 Main sequence program
& so on
Then call those blocks in OB1 either unconditionally or conditionally if they only need to run when certain logic is required.
TIA like Mitsi (GXWorks), AB, etc. are designed for structured programming so rather than have one big block of code you split it into different programs.
It also makes sense that if you have motors or valves etc. to create functions like motor or valve control, these are only written once then you call them many times passing information to them the block will have input & output parameters so everytime you call the block you populate it with the relevant signals for that valve, this way you only write the code once but call it many times.
See pic of a structured program
As for my code...it's all in OB1 at the moment.
Networks 2 to 10 are a repeat of Network 1, for each laser.
Then Network 11 does a SAVE of the values to retained tags defined in a DB.
That's all the code I've done so far.
See the 2 pics.