Saturday, 4 August 2018

iC-Haus SSI Data Parity Check

Summary
This blog provides one solution for calculating the parity of a data stream which has been obtained using an SSI interface from an iC-Haus magnetic encoder.

Reason for SSI
Magnetic encoders from iC-Haus perform well for position sensing and are ideally suited for battery backup installations because of their low current consumption. One constraint with these encoders is that the data output of the SPI and SSI communications interfaces is different. It should be pointed out that the hardware solution required with the encoder will largely dictate the communications interface used in the design.


iC-Haus Communication Modes
iC-Haus Communication Modes
From the communications interface, information such as the angle offset 'synchronization bits' is available using the SSI but not the SPI communication. The angle offset can be useful if the offset needs to be manually changed or set to a specific setting depending on external conditions.


iC-Haus Angle Offset
iC-Haus Angle Offset
While obtaining SSI data from the encoder, data integrity can be achieved using an optional parity bit.


iC-Haus Parity Options
iC-Haus Parity Options
The parity bit is located at the end of the SSI data packet. It should be noted that the MT - Multiturn bit width shown at the beginning of the packet below, is user programmable between 9 and 40 bits.


iC-Haus SSI Data
iC-Haus SSI Data
SSI Data Parity Check
For a SSI data payload of 32 bits, calculating the parity could be achieved using a number of methods. One option for performing this calculation, which may not come to mind immediately, is calculating the parity in five steps. 

Such an example is shown in the code below. Courtesy of Sean Eron Anderson at Stanford University and the associated Bit Twiddling Hacks page for the implementation below.


unsigned int v;  // word value to compute the parity of
v ^= v >> 16;
v ^= v >> 8;
v ^= v >> 4;
v &= 0xf;
return (0x6996 >> v) & 1;
There is a lengthy explanation of the 32 bit parity check and an explanation of a 64 bit implementation by Hraban on his blog http://br0g.0brg.net, credit for helping wrap my head around the 0x6996!


No comments:

Post a Comment