<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f806899d30/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f806899d30/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f806899d30/</id><updated>2020-02-27T20:43:22.888000Z</updated><subtitle>Recent posts to Help with simple FB</subtitle><entry><title>Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f806899d30/?limit=25#f7a4" rel="alternate"/><published>2020-02-27T20:43:22.888000Z</published><updated>2020-02-27T20:43:22.888000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com4507feb8aaf10c9767be32a92dadc3e0ab1f0456</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;mr lundahl does not explain what he does:&lt;/p&gt;
&lt;p&gt;You want to see each alarm, so each alarm has a unique code.&lt;br/&gt;
alarm1 is 1&lt;br/&gt;
alarm2 is 2&lt;br/&gt;
alarm3 is 4&lt;br/&gt;
alarm4 is 8 etc.&lt;br/&gt;
example&lt;br/&gt;
alarm2 and 3 are active.&lt;/p&gt;
&lt;p&gt;for a is alarm1 to alarmx&lt;br/&gt;
hmicode is hmicode +2 sqr(a);&lt;br/&gt;
this way you can put 16 alarms in one WORD.&lt;/p&gt;
&lt;p&gt;or &lt;br/&gt;
hmicode=0&lt;br/&gt;
if alarm1 then hmicode=hmicode+1;&lt;br/&gt;
if alarm2 then hmicode=hmicode+2;&lt;br/&gt;
etc.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f806899d30/?limit=25#0f2c" rel="alternate"/><published>2020-02-27T20:43:21.502000Z</published><updated>2020-02-27T20:43:21.502000Z</updated><author><name>t.lundahl</name><uri>https://forge.codesys.com/u/t-lundahl/</uri></author><id>https://forge.codesys.comed81206d6ec44e94d10831b19f050313c5815db3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Try this small change.&lt;/p&gt;
&lt;p&gt;IF IN1 AND NOT Alarm.1 THEN&lt;br/&gt;
  Alarm.1 := TRUE; (&lt;em&gt;Secondbit in AlarmRegister&lt;/em&gt;)&lt;br/&gt;
END_IF;&lt;/p&gt;
&lt;p&gt;Also make it as Functionblock to add to your ladder.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f806899d30/?limit=25#2827" rel="alternate"/><published>2020-02-27T20:43:20.101000Z</published><updated>2020-02-27T20:43:20.101000Z</updated><author><name>mehrab</name><uri>https://forge.codesys.com/u/mehrab/</uri></author><id>https://forge.codesys.com48223596cba3d822fd7a865b00245ac9a123d78f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;t.lundahl hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Hi!&lt;br/&gt;
What you can do, for each alarm:&lt;br/&gt;
IF IN1 AND NOT Alarm1 THEN&lt;br/&gt;
  Alarm1 := TRUE; &lt;br/&gt;
END_IF;&lt;br/&gt;
IF Reset THEN&lt;br/&gt;
   Alarm1:=FALSE;&lt;br/&gt;
END_IF;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;See if I do it this way, there will be values written to the word that might not get scanned&lt;/p&gt;
&lt;p&gt;let's say I have 4 inputs, IN1, IN2, IN3, IN4. &lt;br/&gt;
My output is Alarm = INT&lt;br/&gt;
Values are: 5000, 5001, 5002, 5003&lt;/p&gt;
&lt;p&gt;Here's what I'm afraid of.. say IN1, IN2, IN3 are on..&lt;br/&gt;
the block will push values, 5000, 5001 and 5002 to the Alarm output&lt;br/&gt;
during the scan, it'll only scan what's in the memory of that output.. in this case, the last value which is 5002.. so my HMI will only display the corresponding message.. and the user will not know that alarms 1 and 2 were even on..&lt;br/&gt;
They may proceed to repair the third alarm, hit reset, then of course it'll scan again displaying the 2nd alarm, repair that and then repair alarm 1.. it's inefficient.&lt;/p&gt;
&lt;p&gt;I have a ladder logic now with all alarms going to single bits.. and the HMI reading those.. individually. Looking for ways to not do it that way.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f806899d30/?limit=25#6280" rel="alternate"/><published>2020-02-27T20:43:16.156000Z</published><updated>2020-02-27T20:43:16.156000Z</updated><author><name>t.lundahl</name><uri>https://forge.codesys.com/u/t-lundahl/</uri></author><id>https://forge.codesys.comaa4cc75865d19bc89562cd88b445b18fde32898c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;What you can do, for each alarm:&lt;/p&gt;
&lt;p&gt;IF IN1 AND NOT Alarm1 THEN&lt;br/&gt;
  Alarm1 := TRUE; &lt;br/&gt;
END_IF;&lt;/p&gt;
&lt;p&gt;IF Reset THEN&lt;br/&gt;
   Alarm1:=FALSE;&lt;br/&gt;
END_IF;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f806899d30/?limit=25#8da7" rel="alternate"/><published>2020-02-27T20:43:14.687000Z</published><updated>2020-02-27T20:43:14.687000Z</updated><author><name>mehrab</name><uri>https://forge.codesys.com/u/mehrab/</uri></author><id>https://forge.codesys.com6ae13dea0da0cfd3ef7e24e59fc60ca7e0772fb7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hey&lt;br/&gt;
Thanks for the reply,&lt;/p&gt;
&lt;p&gt;I'm realizing this might not be the best way to do this.&lt;/p&gt;
&lt;p&gt;What I'm trying to do is create fault messages.&lt;br/&gt;
If an alarm is triggered it'll display a fault on the screen.&lt;/p&gt;
&lt;p&gt;All of my faults right now are grouped in 10's.. I was going to send a value to a word and have the HMI read the values and display its corresponding message.&lt;/p&gt;
&lt;p&gt;I'm realizing that's not working very well because if more then one fault from one group is generated, by the time the scan is complete, the word only has one value in it.. so the HMI misses the other faults.&lt;/p&gt;
&lt;p&gt;Is there a better way to do this?&lt;br/&gt;
As of now I'm going to create a ladder program with individual alarms coiled to individual bits.. &lt;/p&gt;
&lt;p&gt;I'm hoping to find a more effective way to do this.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f806899d30/?limit=25#aa3a" rel="alternate"/><published>2020-02-27T20:43:10.760000Z</published><updated>2020-02-27T20:43:10.760000Z</updated><author><name>t.lundahl</name><uri>https://forge.codesys.com/u/t-lundahl/</uri></author><id>https://forge.codesys.comaff7784012b1dadba6f1eb511ce7cc4907d333af</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;If you want the OUT:=5001 only if IN2 is TRUE and not everytime the IN1 in FALSE then&lt;br/&gt;
use:&lt;/p&gt;
&lt;p&gt;Remove the (;) after THEN&lt;/p&gt;
&lt;p&gt;ELSIF IN2 THEN (:= TRUE, not needed)&lt;/p&gt;
&lt;p&gt;/Torbjörn&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Help with simple FB</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f806899d30/?limit=25#09e9" rel="alternate"/><published>2020-02-27T20:43:09.345000Z</published><updated>2020-02-27T20:43:09.345000Z</updated><author><name>mehrab</name><uri>https://forge.codesys.com/u/mehrab/</uri></author><id>https://forge.codesys.comc4a1af0333415970ca52f45d53e32cb9fd91f8c7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This I'm thinking is supposed to be a simple Function Block but I can't seem to get it&lt;/p&gt;
&lt;p&gt;What I'm trying to do.&lt;/p&gt;
&lt;p&gt;If Input 1 = high then output = 5000&lt;br/&gt;
if Input 2 = high then output = 5001&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #0000FF;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;VAR_INPUT&lt;br/&gt;
    IN1:BOOL;&lt;br/&gt;
    IN2:BOOL;&lt;br/&gt;
END_VAR&lt;br/&gt;
VAR_OUTPUT&lt;br/&gt;
    OUT: INT;&lt;br/&gt;
END_VAR&lt;br/&gt;
VAR&lt;/p&gt;
&lt;p&gt;The code I've written:&lt;/p&gt;
&lt;p&gt;==============&lt;br/&gt;
IF IN1 THEN;&lt;br/&gt;
OUT := 5000;&lt;br/&gt;
ELSE&lt;br/&gt;
&lt;span style="color: #FF0000;"&gt;IN2 := TRUE THEN;&lt;/span&gt;&lt;br/&gt;
OUT:= 5001;&lt;br/&gt;
END_IF&lt;br/&gt;
==============&lt;/p&gt;
&lt;p&gt;I keep getting a Error 4024: Error1 (5) Expecting";" or ":=" before 'THEN' &lt;/p&gt;
&lt;p&gt;(I've highlighted the affected line in red)&lt;/p&gt;
&lt;p&gt;I've tried a few different things but it's still not compiling&lt;br/&gt;
I know I'm writing it wrong, just need some help please.&lt;/p&gt;
&lt;p&gt;What I'm ultimately trying to do is write a value from 5000 to 5200 to a memory word (%QW441)&lt;br/&gt;
My HMI then will read those codes and depending on what the value is will display a different fault on the screen.&lt;/p&gt;
&lt;p&gt;This is my first time using codesys so any help would be greatly appreciated.&lt;br/&gt;
Thanks in advance&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>