Schneider UnityPro S data type error

baselch0

Member
Join Date
Jul 2010
Location
Basel
Posts
27
Hi All,

I'm facing an error defining a data type as byte to realize a simple counter......

here the ST code:

IF rst THEN
cnt:= 0;
Q0 := 0;
Q1 := 0;
Q2 := 0;
Q3 := 0;
Q4 := 0;
Q5 := 0;
Q6 := 0;
Q7 := 0;
ELSIF clk THEN
cnt:= cnt +1;
Q0 := cnt.0;
Q1 := cnt.1;
Q2 := cnt.2;
Q3 := cnt.3;
Q4 := cnt.4;
Q5 := cnt.5;
Q6 := cnt.6;
Q7 := cnt.7;
END_IF;

Compiling the code , system give the follow error refer to tag call cnt

E1092 different data type ('cnt:BYTE'<->'cnt + 1:ANY_NUM')

If define the tag cnt as INT then no problem to code compile.

Question is how is possible realize a counter using just a byte and not a word???

Thanks in advance




 
I had to do this:

cnt:= DINT_TO_BYTE((BYTE_TO_DINT(cnt) + 1));

Which is pretty messy.

Why not just work with INT or DINT types? Then there's no need to cast data types.
 
I think you can't do this because Unity treats the Byte data type as a bit string, not as a numerical value. From the help file:

Reminder Concerning Bit String Format
The particularity of this format is that all of its component bits do not represent a numerical value, but a combination of separate bits.

You are trying to add a number to bit string, so you get an error.
 
Thanks a lot guys for the answers,

about error E1092 different data type ('cnt:BYTE'<->'cnt + 1:ANY_NUM')

probably could be possible specify the tag "cnt" as ANY data type..........

regards and thank again
 

Similar Topics

Hi friends I am unable to open a unity pro program which was done two years back for my client. the software version which i am using now is...
Replies
7
Views
2,555
Dear Friends, I am using Schneider UNITY Pro XL Version 3.1 software with MODICON 140 CPU 65150. Recently we are facing a problem while going...
Replies
7
Views
5,438
Everything was working fine, but suddenly CPU went into error mode, and the ERR and TER LEDs lit up. Now I can't download or connect with the PLC...
Replies
0
Views
39
Hello all, I am wanting to update the system clock via NTP in the M580/M340. I'm aware that we are able to connect to a NTP in the controller...
Replies
4
Views
129
I am using Schneider elau pack drive servo motor ISH-100. I am facing the problem that On the ISH -100 red light is blinking and pack drive C-600...
Replies
0
Views
61
Back
Top Bottom