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..
A difficult binary operation for me:(
-
- Posts: 22
- Joined: Fri May 25, 2012 7:44 am
- Location: Charlotte, NC. USA
Re: A difficult binary operation for me:(
I may be mistaken, but I think what you want is something like this..
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
Patrick Hall
-
- Posts: 51
- Joined: Fri Apr 27, 2012 12:33 pm
Re: A difficult binary operation for me:(
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:
but these codes didnt give me a result.
Where is the wrong
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°er2;
Where is the wrong
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: A difficult binary operation for me:(
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.
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
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer