Autor Thema: User function block (UF) - in/out analog value  (Gelesen 726 mal)

Offline darek

  • Newbie
  • *
  • Beiträge: 2
User function block (UF) - in/out analog value
« am: März 17, 2024, 21:17:08 Nachmittag »
Hello.
I use ST language.
In main program when i write code like this:
Zitat
//MW1 - some counter;
 if I1 then
 MW1:= MW1 + 1;
 end_if;
The value of MW1 can be overwriten from Modbus TCP, or integrated display.

But how to do the same within UF?
If the UF code is:
if I1 then
QA1 := QA1 + 1;
end_if;
and call UF like this:
UF01 (
  NAME := "qt",
  VERSION := "V1.00",
  I1 := I1,
  QA1 => MW1
 );
I can't overwrite value of MW1 from Modbus, or Display.

Is there any way to make variable input and output at the same time? When I change UF to:
if I1 then
QA1 := IA1 + 1;
end_if;
and call as:
UF01 (
  NAME := "qt",
  VERSION := "V1.00",
  I1 := I1,
        IA1 => MW1,
  QA1 => MW1
 );
I still can't change value of MW1...

BTW. Why there isn't something like symbols definition in ST. For example:
#define I01 as pulse:

IF pulse THEN
...
END_IF;
That would be a huge help.

Offline radar17892

  • Sr. Member
  • ****
  • Beiträge: 712
  • Think easy!
    • mollgruppe
Antw:User function block (UF) - in/out analog value
« Antwort #1 am: März 18, 2024, 12:37:11 Nachmittag »
Hi darek,
all variables are predefined at easysoft. You can write comments to any variable.

Zitat
UF01 (
    NAME := "qt",
    VERSION := "V1.00",
    I1 := I1,
        IA1 => MW1,
    QA1 => MW1
 );
This is not logic!
It should look like this:
UF01 (
    NAME := "qt",
    VERSION := "V1.00",
    I1 := I1,
        IA1 := MW1,
    QA1 => MW1 );
Change IA1 to an UF-Input
The code into UF can be:
if I1 then
   QA1 := IA1 + 1;
end_if;

By the way, you should use MW from the high range in the main program. It's better to use the lower area only for bits.

Thomas
« Letzte Änderung: März 18, 2024, 12:43:53 Nachmittag von radar17892 »
Weil Einfach einfach Einfach ist!

Offline darek

  • Newbie
  • *
  • Beiträge: 2
Antw:User function block (UF) - in/out analog value
« Antwort #2 am: März 18, 2024, 17:51:29 Nachmittag »
Zitat
all variables are predefined at easysoft. You can write comments to any variable.
It's not enough because you cannot use comments variable in ST (or I don't know how to use it?). When you program is biger you have to think what the marker means. Of course you can comment all the lines of code, but when you change something you heave to change all the comments. That's terreble. Is it really big deal to introduce symbols?

Zitat
This is not logic!
What is not logic?
you wrote exactly the same code as me. Try in simulation change the MW1 value.

Zitat
By the way, you should use MW from the high range in the main program. It's better to use the lower area only for bits.
I know, it's only an example.



Offline radar17892

  • Sr. Member
  • ****
  • Beiträge: 712
  • Think easy!
    • mollgruppe
Antw:User function block (UF) - in/out analog value
« Antwort #3 am: März 19, 2024, 10:23:25 Vormittag »
your UF:
I1 := I1,
IA1 => MW1,
QA1 => MW1);

I wrote:
I1 := I1,
IA1 := MW1,
QA1 => MW1 );
Change IA1 to an UF-Input.

Do you see the difference?
Weil Einfach einfach Einfach ist!

Offline CiesleRa

  • Global Moderator
  • Full Member
  • *****
  • Beiträge: 323
  • easyE4 for President
Antw:User function block (UF) - in/out analog value
« Antwort #4 am: März 19, 2024, 19:37:44 Nachmittag »
Hi darek,

Zitat
It's not enough because you cannot use comments variable in ST (or I don't know how to use it?). When you program is biger you have to think what the marker means. Of course you can comment all the lines of code, but when you change something you heave to change all the comments. That's terreble.

Sorry that I have to say this, but what you want is an PLC at the price of a VW with the comfort and functions of a Mercedes.
If you want to program with symbols, there are also Eaton controllers that can do this, e.g. XC-100, XC-200 or XC-300, with Codesys as programming software.
But you have to pay a little more for this.
By the way, the easyE4 with easySoft is, as far as I know, the only small controller that even offers ST as a programming language. 
Neither Siemens LOGO!, Schneider Zelio or Crouzet Millenium offer this.

BR
Ralf
Alle von mir bereitgestellten Programme sind reine Beispielprojekte. Die Verwendung erfolgt auf eigene Gefahr. Jegliche Haftung ist ausgeschlossen.

Offline 190B

  • Full Member
  • ***
  • Beiträge: 102
Antw:User function block (UF) - in/out analog value
« Antwort #5 am: März 19, 2024, 19:43:04 Nachmittag »
Hi darek,

Zitat
It's not enough because you cannot use comments variable in ST (or I don't know how to use it?). When you program is biger you have to think what the marker means. Of course you can comment all the lines of code, but when you change something you heave to change all the comments. That's terreble.

Sorry that I have to say this, but what you want is an PLC at the price of a VW with the comfort and functions of a Mercedes.
If you want to program with symbols, there are also Eaton controllers that can do this, e.g. XC-100, XC-200 or XC-300, with Codesys as programming software.
But you have to pay a little more for this.
By the way, the easyE4 with easySoft is, as far as I know, the only small controller that even offers ST as a programming language. 
Neither Siemens LOGO!, Schneider Zelio or Crouzet Millenium offer this.

BR
Ralf

Thumbs up
Gruß
190B