Hi all,
I need to convert binary to grey code but siemens requires a password from this page: http://support.automation.siemens.com/W ... n/25629271
Somebody have these blocks available?
Many thanks
[?]: Conversion blocks binary-gray (17 bits)
-
- Posts: 103
- Joined: Fri Aug 31, 2007 8:17 pm
- Location: Europe
[?]: Conversion blocks binary-gray (17 bits)
Last edited by Scarch on Fri Feb 17, 2012 4:05 pm, edited 2 times in total.
-
- Posts: 258
- Joined: Fri Apr 03, 2009 3:24 pm
- Location: Bosnia and Herzegovina
-
- Faq & Info
- Posts: 428
- Joined: Wed Oct 05, 2005 9:00 am
-
- Posts: 103
- Joined: Fri Aug 31, 2007 8:17 pm
- Location: Europe
[?]: Convert Gray code to decimal 16 bits
Hi...
I have used a program from Sania in order to convert from gray to decimal for 10 bits, but now I need it for 16 bits (1 word) and do not know how to modify it.
Please help. It is used for an absolute multiturns encoder, being able to read from zero to 65536 in gray code.
I can't manage it.
I have used a program from Sania in order to convert from gray to decimal for 10 bits, but now I need it for 16 bits (1 word) and do not know how to modify it.
Please help. It is used for an absolute multiturns encoder, being able to read from zero to 65536 in gray code.
I can't manage it.
-
- Posts: 2
- Joined: Mon Jun 21, 2010 2:16 pm
- Location: Kharkov, Ukraine
Re: [?]: Conversion blocks binary-gray (16 bits)
Wikipedia says there's another formula. STL implementation:
Variables #Gray, #Temp and #RET_VAL are of type WORD.
#Gray (IN) = Gray code
#Temp (TEMP) = temporary value
#RET_VAL (RETURN) = result of calculation, binary value
Works for 16-bit Gray code.
Code: Select all
//C formula:
// unsigned short temp = num ^ (num>>8);
// temp ^= (temp>>4);
// temp ^= (temp>>2);
// temp ^= (temp>>1);
// return temp;
//Taken from http://en.wikipedia.org/wiki/Gray_code#Converting_to_and_from_Gray_code
// temp = num ^ (num>>8);
L #Gray
SRW 8
L #Gray
XOW
T #Temp
// temp ^= (temp>>4);
L #Temp
SRW 4
L #Temp
XOW
T #Temp
// temp ^= (temp>>2);
L #Temp
SRW 2
L #Temp
XOW
T #Temp
// temp ^= (temp>>1);
L #Temp
SRW 1
L #Temp
XOW
//return temp;
T #RET_VAL
#Gray (IN) = Gray code
#Temp (TEMP) = temporary value
#RET_VAL (RETURN) = result of calculation, binary value
Works for 16-bit Gray code.