codesys

Prevent local variable retention

我怕爱的太早我们不能终老 提交于 2020-07-30 14:46:34
问题 Suppose I have a function block POU1 which has local variables val1: INT and val2: INT , e.g. FUNCTION_BLOCK POU1 VAR val1: INT := 1; val2: INT := 1; END_VAR Now suppose the user of the FB declares it as RETAIN , e.g. VAR RETAIN p1: POU1; END_VAR p1.val1 := 2; p1.val2 := 2; This will result in both val1 and val2 retaining the value of 2 in case of a warm reset, but what if I don't want that to happen to say val2 i.e. I want val1 to retain it's current value, but val2 to be reset in case of a

Prevent local variable retention

只谈情不闲聊 提交于 2020-07-30 14:44:41
问题 Suppose I have a function block POU1 which has local variables val1: INT and val2: INT , e.g. FUNCTION_BLOCK POU1 VAR val1: INT := 1; val2: INT := 1; END_VAR Now suppose the user of the FB declares it as RETAIN , e.g. VAR RETAIN p1: POU1; END_VAR p1.val1 := 2; p1.val2 := 2; This will result in both val1 and val2 retaining the value of 2 in case of a warm reset, but what if I don't want that to happen to say val2 i.e. I want val1 to retain it's current value, but val2 to be reset in case of a

Prevent local variable retention

允我心安 提交于 2020-07-30 14:44:31
问题 Suppose I have a function block POU1 which has local variables val1: INT and val2: INT , e.g. FUNCTION_BLOCK POU1 VAR val1: INT := 1; val2: INT := 1; END_VAR Now suppose the user of the FB declares it as RETAIN , e.g. VAR RETAIN p1: POU1; END_VAR p1.val1 := 2; p1.val2 := 2; This will result in both val1 and val2 retaining the value of 2 in case of a warm reset, but what if I don't want that to happen to say val2 i.e. I want val1 to retain it's current value, but val2 to be reset in case of a

How do I use system time as a trigger in codesys ladder?

强颜欢笑 提交于 2020-07-20 04:18:11
问题 Programming a raspberry pi with codesys, using mostly ladder, basically I need to write all data that is currently in a couple arrays to a csv file at midnight, so i'd like to be able to use a dt value as a trigger. I can't figure out how to use that value in ladder, however. I can display the local time on visualizer, but if i wanted something like "if localTime=#value" then coil 'Write' turns on, where is the actual variable for system time? 回答1: As far as I know, you need to read the clock

Exporting Array to CSV in CODESYS

喜夏-厌秋 提交于 2020-06-29 03:54:05
问题 I am taking over a project with code from another person. I have a PLC that currently has inputs in from pressure sensors and thermocouples. It then scales that data to PSI and temperature in fahrenheit. The way the data is set up from each of those sensors is to be formatted into an array. So, once the data is scaled it is in an array that is also in the Network Variable List of the program. I am trying to take each of these values from the array, record the value every certain amount of

Codesys中关于字符串的处理

柔情痞子 提交于 2020-03-09 04:42:28
最近在Codesys中编程中遇到了字符串的处理问题,学习了一些前辈方法,顺便记录一下: readdataMid:="[shake:A1;]"; 1.查找字符串是否存在对应的字符串(单独使用需要指定字符串位置,即协议定死) verifyStr: STRING(5); verifyStr:=(MID(readdataMid,5,1)); bverifyStrOk:=(verifyStr='shake'); PS:获取字符串中1的的位置后面5个字符的位置,形成字符串,赋值给verifystr ,同时通过一个布尔值判断是否为指定字符串 MID方法:MID(STR(string),LEN(int),POS(int))的意思是:从STR字符串中以位置POS处的字符开始检索长度为LEN字符。 2.查找指定字符位置位置 find1,find2:int; find1:=FIND(readdataMid,'['); PS:查询readdatamid字符串中,"["的位置,返回给find1 FIND方法:FIND(STR1(string),STR2(string))的意思是:查找STR2首次出现在STR1中的第一个字符的位置。如果在STR1中找不到STR2,则返回0。 3.拼接字符串 readdataMid2:string(99); readdataMid2:=INSERT(STR1:=

Communicate with CoDeSys program on a Linux-based WAGO PFC200 PLC

心不动则不痛 提交于 2019-12-21 05:56:24
问题 I'm currently getting familiar with PLC's, the WAGO 750-8206 PLC in particular. It offers a linux OS and can run CoDeSys programs. There are some I/O modules attached to the controller: 750-530, 750-430 and 750-600. What I would like to know is this: Is it possible to write a C++ linux application that runs on the PLC and gets/sets the digital inputs and outputs? Even better: can I write a CoDeSys program that "talks to the I/O's" and handles all the logic and at the same time can be accessed

Converting 32-Bit Real to 2x 16-Bit Bytes

不打扰是莪最后的温柔 提交于 2019-12-11 19:33:09
问题 I'm trying to send a 32-Bit Real across a CAN communications (IFM) but the CAN comms only accepts a 16-Bit value. If the value I'm trying to send goes above 255, it resets back to 0 and continues in that pattern. I therefore need to split the 32-Bit Real value in to two 16-Bit values and then reassemble on the other side of the comms. I just can't seem to get my head around how to do it in structured text. Any help would be appreciated 回答1: I know I am a little late to the party but wanted to

Communicate with CoDeSys program on a Linux-based WAGO PFC200 PLC

冷暖自知 提交于 2019-12-03 21:20:38
I'm currently getting familiar with PLC's, the WAGO 750-8206 PLC in particular. It offers a linux OS and can run CoDeSys programs. There are some I/O modules attached to the controller: 750-530, 750-430 and 750-600. What I would like to know is this: Is it possible to write a C++ linux application that runs on the PLC and gets/sets the digital inputs and outputs? Even better: can I write a CoDeSys program that "talks to the I/O's" and handles all the logic and at the same time can be accessed by a C++ linux program? THe idea is this: I would like the CoDeSys program to check for let's say two

Communicate with CoDeSys program on a Linux-based WAGO PFC200 PLC

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm currently getting familiar with PLC's, the WAGO 750-8206 PLC in particular. It offers a linux OS and can run CoDeSys programs. There are some I/O modules attached to the controller: 750-530, 750-430 and 750-600. What I would like to know is this: Is it possible to write a C++ linux application that runs on the PLC and gets/sets the digital inputs and outputs? Even better: can I write a CoDeSys program that "talks to the I/O's" and handles all the logic and at the same time can be accessed by a C++ linux program? THe idea is this: I would