AMS AS5048 Eval-Kit Gebruikershandleiding - Pagina 10
Blader online of download pdf Gebruikershandleiding voor {categorie_naam} AMS AS5048 Eval-Kit. AMS AS5048 Eval-Kit 12 pagina's. 14-bit rotary position sensor with digital angle (interface) and pwm output
Ook voor AMS AS5048 Eval-Kit: Kit handleiding (16 pagina's), Bedieningshandleiding (10 pagina's)
User Manual – AS5048-AB
dat
= SPI_CMD_READ | SPI_REG_CLRERR;
dat |= spiCalcEvenParity(dat)<<15;
spiTransfer((u8*)&dat, sizeof(u16));
}
else
{
agc = agcreg & 0xff
value = dat & (16384 - 31 - 1);
angle = (value * 360) / 16384
(0..359.9°)
magnitude = magreg & (16384 - 31 - 1);
alarmLo = (agcreg >> 10) & 0x1;
alarmHi = (agcreg >> 11) & 0x1;
}
}
/*!
*****************************************************************************
*
Calculate even parity of a 16 bit unsigned integer
*
*
This function is used by the SPI interface to calculate the even parity
*
of the data which will be sent via SPI to the encoder.
*
*
\param[in] value : 16 bit unsigned integer whose parity shall be calculated
*
*
\return : Even parity
*
*****************************************************************************
*/
static
u8 spiCalcEvenParity(ushort value)
{
u8 cnt = 0;
u8 i;
for
(i = 0; i < 16; i++)
{
if
(value & 0x1)
{
cnt++;
}
value >>= 1;
}
return
cnt & 0x1;
}
/*!
*****************************************************************************
*
Calculate even parity of a 16 bit unsigned integer
*
*
This function is used by the SPI interface to calculate the even parity
*
of the data which will be sent via SPI to the encoder.
*
*
\param[in] value : 16 bit unsigned integer whose parity shall be calculated
*
*
\return : Even parity
*
*****************************************************************************
*/
static
u8 spiCalcEvenParity(ushort value)
{
u8 cnt = 0;
u8 i;
for
(i = 0; i < 16; i++)
{
if
(value & 0x1)
{
cnt++;
}
value >>= 1;
}
return
cnt & 0x1;
}
www.ams.com
// AGC value (0..255)
// Angle value (0.. 16384 steps)
Revision 1.2 / 14.01.2014
// Angle value in degree
page 10/12