Sign in to follow this  
Followers 0
hmwright

Citect Write of Variables to M340 PLC

2 posts in this topic

I am trying to write some citect variables back to the PLC. I have made a startup cicode script which is suppose to copy one variable to another which I found on the web. I am not sure if just using tag = tag is OK in citect 2018. Any help would be fantastic.

 

Cicode below:

***********************

FUNCTION StartUpFunction()
    INT hMyTask;
    // Start a new task that runs all the time and transfers values using writetag
    hMyTask = TaskNew("fnDoThis","",0);
END

FUNCTION fnDoThis;
    //Never Stop this Loop
    WHILE 1 DO
        //Update the first Tag
        TagWrite ("M340PLC_R02kW",Sub02Substation2PowerkWtot)
        M340PLC_R03kW = Sub03Substation3PowerkWtot
        M340PLC_R04kW = Sub04Substation4PowerkWtot
        M340PLC_R05kW = TerminalSubstation_5InstantaneousPowerkWtot
        M340PLC_R06kW = TerminalSubstation_6PowerkWtot
        M340PLC_R07kW = Sub07Substation7PowerkWtot
        M340PLC_R08kW = Sub08Substation8PowerkWtot
        M340PLC_R09kW = Sub09Substation9PowerkWtot
        M340PLC_R10kW = M340PLC_G1_GEN_FREQ_PV
        M340PLC_R11kW = Sub11Substation11PowerkWtot
        M340PLC_R12kW = Sub12Substation12PowerkWtot
        M340PLC_R13kW = Sub13Substation13PowerkWtot
        M340PLC_R14kW = Sub14Substation14PowerkWtot
        M340PLC_R15kW = Sub15Substation15PowerkWtot
        M340PLC_R16kW = Sub16Substation_16PowerkWtot
        M340PLC_R17kW = TerminalSubstation_17PowerkWtot
        M340PLC_R18kW = Sub18Substation18PowerkWtot
        M340PLC_R19kW = Sub19Substation19PowerkWtot
        M340PLC_R20kW = M340PLC_G1_GEN_FREQ_PV        
        M340PLC_R21kW = Sub21Substation21PowerkWtot
        M340PLC_R22kW = Sub22Substation_22PowerkWtot
        M340PLC_R23kW = Sub23Substation_23PowerkWtot
        M340PLC_R24kW = Sub24Substation_24PowerkWtot
        M340PLC_R25kW = Sub25Substation25PowerkWtot
        M340PLC_R26kW = Sub26Substation26PowerkWtot
        M340PLC_R27kW = Sub27Substation27PowerkWtot
        M340PLC_R28kW = Sub28Substation28PowerkWtot
        M340PLC_R29kW = Sub29Substation29PowerkWtot
        M340PLC_R30kW = M340PLC_G1_GEN_FREQ_PV
        M340PLC_R31kW = M340PLC_G1_GEN_FREQ_PV
        M340PLC_R32kW = PV2_SSB1PowerMeterPowerkWtot
        M340PLC_R33kW = PV2_SSB2PowerMeterPowerkWtot
        M340PLC_R34kW = M340PLC_G1_GEN_FREQ_PV
        M340PLC_R35kW = M340PLC_G1_GEN_FREQ_PV
        M340PLC_R36kW = M340PLC_G1_GEN_FREQ_PV
        M340PLC_PQM3_WATTS_PV = HV_MetersBunnings_Intake_StnPowerkWtot
        M340PLC_SOL01_SSB1_KW = SolarSSB1PowerMeterPowerkWtot
        M340PLC_SOL01_SSB2_KW = SolarSSB2PowerMeterPowerkWtot
        M340PLC_SOL01_SSB3_KW = SolarSSB3PowerMeterPowerkWtot
        M340PLC_SOL01_SSB4_KW = SolarSSB4PowerMeterPowerkWtot
        //Go to sleep for 1 second so as to not overload CPU
        Sleep(1)
    //Go back to start of Loop
    END
//End of Function
END
 

Share this post


Link to post
Share on other sites

Issue was a data type, THE variable to write was an INT and the read variable as a string from OPC

Lines Changed to:-

M340PLC_R03kW = strtoint (Sub03Substation3PowerkWtot);

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0