A difficult binary operation for me:(

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
memethemyn
Posts: 51
Joined: Fri Apr 27, 2012 12:33 pm

A difficult binary operation for me:(

Post by memethemyn »

Hi..

In a project I use 9 of Emotron VFX drives. But in modbus the emotron uses its own procedure like EInt.

That I want to read input registers I must take an 16 bit data and the value I need the first 11 bit and then convert it to decimal again..

For example I take a data as 61563

it is 1111000001111011

the blue bits its my real value.. when I convert the blue bits to decimal I took 123 the value what I want..

How can I do this :(

Help please..

Patrick Hall
Posts: 22
Joined: Fri May 25, 2012 7:44 am
Location: Charlotte, NC. USA

Re: A difficult binary operation for me:(

Post by Patrick Hall »

I may be mistaken, but I think what you want is something like this..
ModbusTag_BitMapped.png
ModbusTag_BitMapped.png (10.94 KiB) Viewed 6807 times
If your Emotron drive were actually using Modbus Register 40000 for your 61563 value, then by mapping a tag to 40000.0-10 (default controller register size is INT16 but you can change it to UINT16 if you prefer un-signed behavior). The result is that the Value of Tag1 is driven by just the 11 bits specified by the ".0-10" portion. If you were to write a value from the HMI back to this tag (assuming read/write) then the value written would be masked by the bits specified as well.
Best Regards,
Patrick Hall

memethemyn
Posts: 51
Joined: Fri Apr 27, 2012 12:33 pm

Re: A difficult binary operation for me:(

Post by memethemyn »

A question again:(

I tried to solve the problem as you described but I want a little cheat..

I planned to masking the bits and I wrote a sample code as you see below:

Code: Select all


			int deger1; 
			int deger2;
			int deger3;
			 
			deger1 = (Globals.Tags.deger1.Value);
			deger2 = (Globals.Tags.deger2.Value);
			deger3 = deger1&deger2;
			
but these codes didnt give me a result.

Where is the wrong :(

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: A difficult binary operation for me:(

Post by mark.monroe »

Maybe this post will help.

If you are using & both numbers will have to have a 1 in them for it to stay a one.

1111 1000 & 0011 1111 = 0011 1000

Are you sure your mask is correct? You may want to use uints so that you do not have to deal with the sign bit.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Post Reply