Home
Embedded Firmware Library User Manual
Contents
1. 57600 VN100 Baud 115200 115200 VN100 Baud 128000 128000 VN100 Baud 230400 230400 VN100 Baud 460800 460800 VN100 Baud 921600 921600 VN1OO BaudType The baud rate register is described in more detail in Section 6 5 of the VN 100 User Manual 6 1 7 AccelGainType The accelerometer gain register is represented by the following data structure Accelerometer Gain Type typedef enum VN100 AccGainType KA Embedded Firmware Library 23 121 Embedded Firmware Library UM003 VN100 AccGain 2G U VN100 AccGain 6G VN100 AccGainType The accelerometer gain register is described in more detail in Section 6 28 of the VN 100 User Manual 6 1 8 SPI Response Packet The SPI response packet is a data structure that is used to organize the SPI response data packets Each time a command is sent to the VN 100 and a response is received it is placed in a response packet structure This allows for easy access to the various components of the response packet The data structure used is given below 32 bit Parameter Type typedef union unsigned long UINC7 float Float VN1OO Param SPI Response Packet typedef struct unsigned char ZeroByte unsigned char Cmca I Ds unsigned char RegID unsigned char Heri VN100 Param Data VN100 SPI BUFFER SIZE VN1OO SPI Packet The first four bytes of the packet are accessible via the CmdID RegID and ErrlD members of the above structure The actu
2. The VectorNav logo is a registered trademark of VectorNav Technologies All other names are the property of their respective owners 2009 VectorNav Technologies All rights reserved KA Embedded Firmware Library 121 121
3. unsigned long ret 0 for i 0 i lt 4 i Wait for SPI1 Tx buffer empty while SPI I2S GetFlagStatus SPI1 SPI I2S FLAG TXE RESET Send SPI1 requests SPI I2S SendData SPI1 VN BYTE data i Wait for response from VN 100 while SPI I2S GetFlagStatus SPI1 SPI I2S FLAG RXNE RESET Save received data in buffer ret unsigned long SPI I2S ReceiveData SPI1 lt lt 8 1 return ret KA Embedded Firmware Library 19 121 Embedded Firmware Library UM003 Bid VN Delay Table 7 describes the VN Delay function Table7 VN Delay Function prototype VN SPI Delay unsigned long delay US Behavior description Delay the processor for deltaT time in microseconds The user needs to place the hardware specific code here necessary to delay the processor for the time span given by delay us measured in micro seconds This function doesn t need to be ultra precise The only requirement on this function is that the processor is delayed a time NO LESS THAN 90 of the time given by the variable delay uS in microseconds The minimum time span that is used by the VectorNav library code is 100uS so the function call shouldn t affect the timing accuracy much If you decide to modify this library or wish to have more precision on this delay function then you can comment out this function and replace it with an optimized macro instead Many compilers have their own delay routines or macros so make sure
4. 3 accel body Remove gravity in body frame Now accel body is the actual acceleration measured in the body reference frame The acceleration measured by the accelerometers is the actual acceleration plus the measured acceleration due to gravity KA Embedded Firmware Library 119 121 Embedded Firmware Library UM003 8 Revision history Table 99 Revision history Pa ka Jun 16 2014 Updated document formatting KA Embedded Firmware Library 120 121 Embedded Firmware Library UM003 Please Read Carefully Information in this document is provided solely in connection with VectorNav products VectorNav Technologies VN reserves the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All VN products are sold pursuant of VN s terms and conditions of sale No license to any intellectual property expressed or implied is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by VN for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein Information in this document supersedes and replaces all information previously supplied
5. packet VN100 SPI GetAccGain 0 gain KA Embedded Firmware Library 66 121 Embedded Firmware Library UM003 6 2 40 VN100 SPI SetAccGain Table 48 describes the VN100 SPI SetAccGain function Table 48 VN100 SPI SetAccGain Function prototype VN100 SPI SetAccGain unsigned char sensorID VN100 AccGainType gain Behavior description Set the current accelerometer gain setting The accelerometer on the VN 100 can be set to either a 2g or 6g gain setting Example Set the accelerometer gain VN100 SPI Packet packet packet VNIOO SPI setAccGaim 0 VJNLOO ACccGain 6G KA Embedded Firmware Library 67 121 Embedded Firmware Library UM003 6 2 41 VN100 SPI RestoreFactorySettings Table 49 describes the VN100 SPI RestoreFactorySettings function Table 49 VN100 SPI RestoreFactorySettings Function prototype VN100 SPI RestoreFactorySettings unsigned char sensorlD Behavior description Restore the selected sensor to factory default state The values for factory default state for each register can be found in Section 7 of the User Manual Example Restore sensor to factory default settings VN100 SPI Packet packet packet VN100 SPI ResterePactoryoertings 0 KA Embedded Firmware Library 68 121 Embedded Firmware Library UM003 6 2 42 7 VN100 SPI Tare Table 50 describes the VN100 SPI Tare function Table 50 VN100 SPI Tare Function prototype VN100 SPI Tare unsigned char sensorlD B
6. unsigned char sensorID float Accl Behavior description Request the inertial acceleration from the VN 100 This function will internally request both the measured acceleration and attitude from the sensor then compute the inertial acceleration If you want to integrate your acceleration to find velocity or position then this is the acceleration that you want to measure It is measured in a fixed NED North East Down coordinate frame Called functions VN100 SPI ReadRegister Example Get the inertial acceleration measurement VN100 SPI Packet packet float accI 3 packet VNILOO SPI AccCinertial 0 accl 7 KA Embedded Firmware Library 71 121 Embedded Firmware Library UM003 6 2 45 VN100 SPI GetMaglnertial Table 53 describes the VN100 SPI GetMaglnertial function Table 53 VN100 SPI GetMaglnertial Function prototype VN100 SPI GetMaglnertial unsigned char sensorID float Magl Behavior description Request the inertial magnetic measurement from the VN 100 This function will internally request both the measured magnetic and attitude from the sensor then compute the inertial magnetic measurement It is measured in a fixed NED North East Down coordinate frame Called functions VN100 SPI ReadRegister Example Get the inertial magnetic measurement VN100 SPI Packet packet float magI 3 packet VN100 SPI MagInertial 0 magI KA Embedded Firmware Library 72 121 Embedded Firm
7. BaudType baudRate Behavior description Get the serial baud rate from the requested sensor Example Get the baud rate VN100 SPI Packet packet VN100 BaudType baud packet VN100 SPI GetBaudRate 0 amp baud KA Embedded Firmware Library 34 121 Embedded Firmware Library UM003 6 2 8 VN100 SPI SetBaudRate Table 16 describes the VN100 SPI SetBaudRate function Table 16 VN100 SPI SetBaudRate Function prototype VN100 SPI SetBaudRate unsigned char sensorID VN100 BaudType baudRate Behavior description Set the serial baud rate for the requested sensor Example Set the serial baud rate to 115200 VN100 SPI Packet packet packet VN100 SPI SetBaudRate 0 VN100 Baud 115200 KA Embedded Firmware Library 35 121 Embedded Firmware Library UM003 6 2 9 VN100 SPI GetADOR Table 17 describes the VN100 SPI GetADOR function Table 17 VN100 SPI GetADOR Function prototype VN100 SPI GetADOR unsigned char sensorID VN100 ADORType ADOR Behavior description Get the ADOR register value from the requested sensor Example Get the ADOR VN100 SPI Packet packet VN100 ADORType ador packet VN100 SPI GetADOR 0 kador KA Embedded Firmware Library 36 121 Embedded Firmware Library UM003 6 2 10 VN100 SPI SetADOR Table 18 describes the VN100 SPI SetADOR function Table 18 VN100 SPI SetADOR Function prototype VN100 SPI SetADOR unsigned char sensorID VN100 ADORType
8. Embedded Firmware Library 57 121 Embedded Firmware Library UM003 6 2 31 VN100 SPI GetHardSoftironComp Table 39 describes the VN100 SPI GetHardSoftIronComp function Table 39 VN100_ SPI_GetHardSoftlronComp VN100_SPI_GetHardSoftlronComp Function prototype VN100 SPI GetHardSoftIronComp unsigned char sensorID float HSI Behavior description Get the magnetic hard soft iron compensation parameters These values allow the magnetometer to compensate for distortions in the local magnetic field due to ferromagnetic materials in the vicinity of the sensor More information on the parameters can be found in the User Manual in Section 6 23 Example Get the magnetic hard soft iron compensation parameters VN100 SPI Packet packet float HSI 12 packet VN100 SPI GetHardSoftIronComp 0 HSI KA Embedded Firmware Library 58 121 Embedded Firmware Library UM003 6 2 32 7 VN100 SPI SetHardSoftlronComp Table 40 describes the VN100 SPI SetHardSoftIronComp function Table 40 VN100 SPI SetHardSoftironComp VN100 SPI SetHardSoftIronComp Function prototype VN100 SPI SetHardSoftIronComp unsigned char sensorID float HSI Behavior description Set the magnetic hard soft iron compensation parameters These values allow the magnetometer to compensate for distortions in the local magnetic field due to ferromagnetic materials in the vicinity of the sensor More information on the parameters can be found in the User Man
9. VN_Quat2Euler123 function Table 79 VN Quat2Euler123 Function prototype void VN_Quat2Euler123 float q float Euler123 Behavior description Convert a quaternion attitude representation to an Euler angle 1 2 3 set Matlab equation Euler123 quat2angle q XYZ Example Convert the quaternion into a Euler 123 angles float g 4 float Fuler123 3 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2Euler123 q Eulerl23 Compute the Euler 123 angles KA Embedded Firmware Library 100 121 Embedded Firmware Library UM003 7 2 26 VN MQuat2Euler131 Table 80 describes the VN_Quat2Euler131 function Table 80 VN Quat2Euler131 Function prototype void VN_Quat2Euler131 float q float Euler131 Behavior description Convert a quaternion attitude representation to an Euler angle 1 3 1 set Matlab equation Euler131 quat2angle q XZX Example Convert the quaternion into a Euler 131 angles float g 4 float Fuler131 3 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2Euler131 q Eulerl31 Compute the Euler 131 angles KA Embedded Firmware Library 101 121 Embedded Firmware Library UM003 7 2 27 VN Quat2Euler132 Table 81 describes the VN_Quat2Euler132 function Table 81 VN Quat2Euler132 Function prototype void VN Quat2Fuler132 float a float Euler132 Behavior description Convert a quaternion attitude representation to an
10. describes the VN Quat2Euler323 function Table 89 VN Quat2Euler323 Function prototype void VN_Quat2Euler323 float a float Euler323 Behavior description Convert a quaternion attitude representation to an Euler angle 3 2 3 set Matlab equation Euler323 quat2angle q ZYZ Example Convert the quaternion into a Euler 323 angles float 9 4 float Fuler323 3 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2Euler323 q Euler323 Compute the Euler 323 angles KA Embedded Firmware Library 110 121 Embedded Firmware Library UM003 7 2 36 VN Quat2Gibbs Table 90 describes the VN Quat2Gibbs function Table 90 VN Quat2Gibbs Function prototype void VN Quat2Gibbs float q float Gibb Behavior description Convert a quaternion attitude representation to the Gibbs angle representation Matlab equation N A Example Convert the quaternion into a Gibbs vector float 9 4 float Gibbs 3 VNIOO SPI GetQuat 0 q Get quaternion from device VNIOO Ouat2Gibbs q Gibbs Compute the Gibbs vector KA Embedded Firmware Library 111 121 Embedded Firmware Library UM003 7 2 37 VN Quat2MRP Table 91 describes the VN Quat2MRP function Table 91 VN Quat2MRP Function prototype void VN Quat2MRP float q float MRP Behavior description Convert a quaternion attitude representation to an Modified Rodrigues Parameters representation Example Conv
11. 2 2 VN SPI SendReceive 5 2 3 VN Delay 6 VN 100 Orientation Sensor 6 1 DATA STRUCTURES 6 1 1 Registers 6 12 Command IDs 6 1 3 Error IDs 6 14 ADOR Type 6 1 5 ADOF Type 6 1 6 Baud Type 6 1 7 AccelGainType 6 1 8 SPI Response Packet 6 2 VN 100 LIBRARY FUNCTIONS 6 2 1 VN100 SPI ReadRegister 6 2 2 VN100 SPI WriteRegister 6 2 3 VN100 SPI GetModel KJ Embedded Firmware Library UM003 10 11 11 11 Id 12 12 15 16 17 17 17 18 19 20 21 21 21 21 22 22 23 23 23 24 25 28 29 30 4 121 Embedded Firmware Library 6 2 4 VN100 SPI GetHWRev 6 2 5 VN100 SPI GetSerial 6 2 6 VN100 SPI GetFWVer 6 2 7 VN100 SPI GetBaudRate 6 2 8 VN100 SPI SetBaudRate 6 2 9 VN100 SPI GetADOR 6 2 10 VN100 SPI SetADOR 6 2 11 VN100 SPI GetADOF 6 2 12 VN100 SPI SetADOF 6 2 13 VN100 SPI GetYPR 6 2 14 VN100 SPI GetQuat 6 2 15 VN100 SPI GetQuatMag 6 2 16 VN100 SPI GetQuatAcc 6 2 17 VN100 SPI GetQuatRates 6 2 18 VN100 SPI GetQuatMagAcc 6 2 19 VN100 SPI GetQuatAccRates 6 2 20 VN100 SPI GetQuatMagAccRates 6 2 21 VN100 SPI GetYPRMagAccRates 6 2 22 VN100 SPI GetDCM 6 2 23 VN100 SPI GetMag 6 2 24 VN100 SPI GetAcc 6 2 25 VN100 SPI GetRates 6 2 26 VN100 SPI GetMagAccRates 6 2 27 VN100 SPI GetMagAccRef 6 2 28 VN100 SPI SetMagAccRef 6 2 29 VN100 SPI GetFiltMeasVar 6 2 30 VN100 SPI SetFiltMeasVar 6 2 31 VN100 SPI GetHardSoftlronComp 6 2 32 VN100 SPI SetHardSoftIronComp 6 2 33 VN100 SPI GetFiltActTuning 6 2 34 VN100 SPI SetFiltAct
12. 6 2 26 VN100 SPI GetMagAccRates Table 34 describes the VN100 SPI GetMagAccRates function Table 34 VN100 SPI GetMagAccRates Function prototype VN100 SPI GetMagAccRates unsigned char sensorID float mag float acc float rates Behavior description Get the measured magnetic acceleration and angular rates The measurements are taken in the body reference frame VN100 SPI ReadRegister Example Get the magnetic acceleration and angular rate measurements VN100 SPI Packet packet float mag 3 float acc 3 float rates 3 packet VN100 SPI GetMagAccRates 0 mag acc rates KA Embedded Firmware Library 53 121 Embedded Firmware Library UM003 6 2 27 VN100 SPI GetMagAccRef Table 35 describes the VN100 SPI GetMagAccRef function Table 35 VN100 SPI GetMagAccRef Function prototype VN100 SPI GetMagAccRef unsigned char sensorID float refMag float refAcc Behavior description Get the magnetic and acceleration reference vectors The reference vectors are the vectors measured by the magnetometer and accelerometer respectively in the inertial reference frame The inertial reference frame is NED North East Down Example Get the magnetic and acceleration reference vectors VN100 SPI Packet packet float magRef 3 float accRef 3 packet VNLOU SPI CecMagAccRer O magket accker KA Embedded Firmware Library 54 121 Embedded Firmware Library UM003 6 2 28 V
13. 7 2 20 VN Normalize Table 74 describes the VN Normalize function Table 74 VN Normalize Function prototype void VN Normalize float V1 unsigned long m float V2 Behavior description Compute the unit normal vector with the direction given by vector V1 Matlab equation V2 V1 norm V1 Example j4 Normalize vector A 7 float A 3 3 O O float B 3 VN Normalize A 3 B B 1 0 0 KA Embedded Firmware Library 95 121 Embedded Firmware Library UM003 7 2 21 VN Quat2DCM Table 75 describes the VN Quat2DCM function Table 75 VN Quat2DCM Function prototype void VN quat2DCM float q float A Behavior description Convert a quaternion into to a directional cosine matrix Matlab equation A quat2dcm q Example Convert the quaternion into a directional cosine matrix float q 4 VN CreateMatrix DCM 3 Sr 10 7 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2DCM g DCM Compute the DCM KA Embedded Firmware Library 96 121 Embedded Firmware Library UM003 7 2 22 VN YPR2DCM Table 76 describes the VN YPR2DCM function Table 76 VN YPR2DCM Function prototype void VN YPR2DCM float YPR float A Behavior description Convert the given yaw pitch and roll into a directional cosine matrix Matlab equation A ANGLE2DCM YPR O YPR 1 YPR 2 ZYX Example Convert the yaw pitch roll into a directional cosine matrix fl
14. ADOR Behavior description Set the ADOR register value from the requested sensor Example Set the ADOR to output angular rates VN100 SPI Packet packet packet VN100 SPI SetADOR 0 VN100 ADOR GYR KA Embedded Firmware Library 37 121 Embedded Firmware Library UM003 6 2 11 VN100 SPI GetADOF Table 19 describes the VN100 SPI GetADOF function Table 19 VN100 SPI GetADOF Function prototype VN100 SPI GetADOF unsigned char sensorID VN100 ADOFType ADOF Behavior description Get the async data output frequency Example Get the ADOF VN100 SPI Packet packet VN100 ADOFType adof packet VN100 SPI GetADOF 0 amp adof KA Embedded Firmware Library 38 121 Embedded Firmware Library UM003 6 2 12 7 VN100 SPI SetADOF Table 20 describes the VN100 SPI SetADOF function Table 20 VN100 SPI SetADOF Function prototype VN100 SPI SetADOF unsigned char sensorID VN100 ADOFType ADOF Behavior description Set the async data output frequency Example Set the ADOF to 200 Hz VN100 SPI Packet packet packet VN100 SPI SetADOF 0 VN1O0O ADOF 200HZ KA Embedded Firmware Library 39 121 Embedded Firmware Library UM003 6 2 13 VN100 SPI GetYPR Table 21 Table 13describes the VN100 SPI GetYPR function Table 21 VN100 SPI GetYPR Function prototype VN100 SPI GetYPR unsigned char sensorID float yaw float pitch float roll Behavior description Get the measured y
15. Behavior description Get the hardware revision for the sensor Example Get the hardware revision VN100 SPI Packet packet unsigned long revision packet VN100 SPI GetHWRev 0 grevision KA Embedded Firmware Library 31 121 Embedded Firmware Library UM003 6 2 5 VN100 SPI GetsSerial Table 13 describes the VN100 SPI GetSerial function Table 13 VN100 SPI GetSerial Function prototype VN100 SPI GetsSerial unsigned char sensorID unsigned long serialNumber Behavior description Get the serial number from the requested sensor Example Get the serial number VN100 SPI Packet packet unsigned long SN 3 packet VN100 SPI GetSerial 0 SN KA Embedded Firmware Library 32 121 Embedded Firmware Library UM003 6 2 6 VN100 SPI GetFWVer Table 14 describes the VN100 SPI_GetFWVer function Table 14 VN100 SPI GetFWVer Function prototype VN100 SPI_GetFWVer unsigned char sensorID unsigned long firmwareVersion Behavior description Get the firmware version from the requested sensor Example Get the firmware version VN100 SPI Packet packet unsigned long version packet VN100 SPI GetFWVer 0 amp version KA Embedded Firmware Library 33 121 Embedded Firmware Library UM003 6 2 7 VN100 SPI GetBaudRate Table 15 describes the VN100 SPI GetBaudRate function Table 15 VN100 SPI GetBaudRate Function prototype VN100 SPI GetBaudRate unsigned char sensorID VN100
16. Embedded Navigation Solutions Embedded Firmware Library VectorNav Technologies 10501 Markison Road Dallas Texas 75238 O United States of America AA Contact Info Phone 1 512 772 3615 Email support vectornav com Website www vectornav com Embedded Firmware Library UM003 Document Information Title Embedded Firmware Library Subtitle User Manual for Embedded Firmware Library Document Type User Manual Document Number UM003 Document Status Released KA Embedded Firmware Library 2 121 Embedded Firmware Library UM003 VectorNav Technical Documentation In addition to our product specific technical data sheets the following manuals are available to assist VectorNav customers in product design and development e VN 100 User Manual The user manual provides a high level overview of product specific information for each of our inertial sensors Further detailed information regarding hardware integration and application specific use can be found in the separate documentation listed below e Hardware Integration Manual This manual provides hardware design instructions and recommendations on how to integrate our inertial sensors into your product e Application Notes This set of documents provides a more detailed overview of how to utilize many different features and capabilities offered by our products designed to enhance performance and usability in a wide range of application specific scenarios Document Symbols Th
17. Euler angle 1 3 2 set Matlab equation Euler132 quat2angle q XZY Example Convert the quaternion into a Euler 132 angles float g 4 float Eulerl132 3 VN100 SPI GetOuat 0 q Get quaternion from device VN100 Quat2Euler132 q Eulerl32 Compute the Euler 132 angles KA Embedded Firmware Library 102 121 Embedded Firmware Library UM003 7 2 28 VN_Quat2Euler212 Table 82 describes the VN_Quat2Euler212 function Table 82 VN Quat2Euler212 Example Convert the quaternion into a Euler 212 angles float g 4 float Fuler212 3 VN100 SPI GetQuat 0 q Get quaternion from device VNI00 QuatZEulerz127 q Fulerz12 Compute the Euler 212 angles KA Embedded Firmware Library 103 121 Embedded Firmware Library UM003 7 2 29 5 VN Quat2Euler213 Table 83 describes the VN Quat2Euler213 function Table 83 VN Quat2Euler213 Function prototype void VN_Quat2Euler213 float a float Euler213 Behavior description Convert a quaternion attitude representation to an Euler angle 2 1 3 set Matlab equation Euler213 quat2angle q YXZ Example Convert the quaternion into a Euler 213 angles float g 4 float Fuler213 3 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2Euler213 q Euler213 Compute the Euler 213 angles KA Embedded Firmware Library 104 121 Embedded Firmware Library UM003 7 2 30 VN Quat2Euler231 Table 84 descr
18. Euler232 7 2 32 VN_Quat2Euler312 7 2 33 VN_Quat2Euler313 7 2 34 VN_Quat2Euler321 7 2 35 VN_Quat2Euler323 7 2 36 VN_Quat2Gibbs 7 2 37 VN_Quat2MRP 7 2 38 VN_Quat2PRV 7 2 39 VN_AddQuat 7 2 40 VN_SubQuat 7 2 41 VN_QuatKinematicDiffEq 7 2 42 VN_YPRKinematicDiffEq 7 2 43 VN_Body2Inertial 7 2 44 VN_Inertial2Body 8 Revision history Embedded Firmware Library UM003 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 7 121 Embedded Firmware Library UM003 1 Introduction This document describes the VectorNav embedded firmware library The firmware library consists of a collection of routines data structures and macros that provide the user with high level control over the functionality of the entire line of VectorNav embedded sensors This library effectively serves two purposes The first and foremost purpose is to create a set of device drivers for each of the VectorNav embedded sensors that help developers spend more time focusing on utilizing the rich features and capabilities of the sensors and less time worrying about the low level details of the communication protocols The second purpose is to provide a rich embedded software library that will assists users in capturing the full capabilities provided by the line of VectorNav products There are some applications that only require the measurements taken directly from the sensor For these applications the firmware libra
19. K define VN100 If the VN100 constant is defined during compilation then the code in the VN100 c file will be compiled in the user s program If for instance you wanted to provide your own functions for the control of the VN 100 and you only wanted to use the math library provided by the firmware library then you could comment out the _VN100 line in order to keep the VN 100 drivers from being included in the final code KK KKK KK KK KK KK KKK KK KK KK KK KKK KK KK KK VN 100 KK KK KKK KK KK KK KK KK KK KK KK KKK KKK define _VN100 5 2 User Functions There are three functions that need to be implemented by the user for the correct operation of the VectorNav embedded firmware library These functions are found in the VN_user c source file KA Embedded Firmware Library 17 121 Embedded Firmware Library UM003 5 2 1 VN_SPI_SetSS Table 5 describes the VN SPI SetSS function Table 5 _SPI_SetSS Function prototype VN100 SPI Packet SPI SetSS unsigned char sensorlD unsigned char regID unsigned char regWidth Behavior description This is a generic function that will set the SPI slave select line for the given sensor This function needs to be added by the user with the logic specific to their hardware to perform the necessary actions to either raise or lower the slave select line for the given sensor If a multiplexer is used then the logic communications necessary to perform the actions should be placed here Input par
20. LOO SPI GecOuatRates O guat races KA Embedded Firmware Library 44 121 Embedded Firmware Library UM003 6 2 18 VN100 SPI GetQuatMagAcc Table 26 describes the VN100 SPI GetQuatMagAcc function Table 26 VN100 SPI GetQuatMagAcc Function prototype VN100 SPI GetQuatMagAcc unsigned char sensorID float q float mag float acc Behavior description Get the measured attitude quaternion magnetic and acceleration Example Get the quaternion magnetic and acceleration VN100 SPI Packet packet float quat 4 float mag 3 float accs packet VN100 SPI GetQuatMagAcc 0 quat mag acc KA Embedded Firmware Library 45 121 Embedded Firmware Library UM003 6 2 19 VN100 SPI GetQuatAccRates Table 27 describes the VN100 SPI GetQuatAccRates function Table 27 VN100 SPI GetQuatAccRates Function prototype VN100 SPI GetQuatAccRates unsigned char sensorID float q float acc float rates Behavior description Get the measured attitude quaternion acceleration and angular rates Example Get the quaternion acceleration and angular rates VN100 SPI Packet packet float quat 4 float accel sl float rates 3 packet VN100 SPI GetQuatAccRates 0 quat acc rates KA Embedded Firmware Library 46 121 Embedded Firmware Library UM003 6 2 20 VN100 SPI GetQuatMagAccRates Table 28 describes the VN100 SPI GetQuatMagAccRates function Table 28 VN100 SPI GetQuatMagAc
21. MatMult Function prototype void VN MatMult float FA float B unsigned long Arows unsigned long Acols unsigned long Bcols float C Example Multiply matrix A and B to gat C VN CreateMatrix A 3 3 1 0 VN CreateMatrax By 3p oy 103 ly VN CreateMatrix C 3 3 10 VN MatMult Ay By By 3r By Cg KA Embedded Firmware Library 84 121 Embedded Firmware Library UM003 7 2 10 VN MatMultMMT Table 64 describes the VN MatMultMMT function Table 64 VN MatMultMMT Function prototype void VN MatMultMMT float FA float BT unsigned long Arows unsigned long Acols unsigned long Brows float C Example 7 Multiply matrix A and transpose of B to get C VN CreateMatrix A 5 fi 5 r or TUFF VN CreateMatrix B k or AULLE VN CreateMatrix C y Tp 40403 VN MatMultMMT A B 5 3 7 C KA Embedded Firmware Library 85 121 Embedded Firmware Library UM003 7 2 11 VN MatMultMTM Table 65 describes the VN MatMultMTM function Table 65 VN MatMultMTM Function prototype void VN MatMultMTM float FA float BT unsigned long Arows unsigned long Acols unsigned long Bcols float C Example Multiply the transpose of matrix A and B to get C VN Createllatrix Ay 3y Dy 101 VN CreateMatrix B 3 Tr 10 VN CreateMatrix C Sp Tr 10 VN MatMultMTM A B 3 5 7 C KA Embedded Firmware Library 86 121 Embedded Firmware Library UM003 7 2 12 VN MatScalarMu
22. N100 SPI SetMagAccRef Table 36 describes the VN100 SPI SetMagAccRef function Table 36 VN100 SPI SetMagAccRef Function prototype VN100 SPI SetMagAccRef unsigned char sensorID float refMag float refAcc Behavior description Set the magnetic and acceleration reference vectors The reference vectors are the vectors measured by the magnetometer and accelerometer respectively in the inertial reference frame The inertial reference frame is NED North East Down Example Set the magnetic and acceleration reference vectors VN100 SPI Packet packet float magRef 3 1 0 0 0 1 73 float accRef 3 0 0 0 0 1 0 packet VNDOO SPL GerMagAcckRer 0 magket accker KA Embedded Firmware Library 55 121 Embedded Firmware Library UM003 6 2 29 5 VN100 SPI GetFiltMeasVar Table 37 describes the VN100 SPI GetFiltMeasVar function Table 37 8 VN100 SPI GetFiltMeasVar Function prototype VN100 SPI GetFiltMeasVar unsigned char sensorID float measVar Behavior description Get the Kalman filter measurement variance parameters This is discussed in the User Manual in Section 6 22 The measurement variance parameters controls how much weight the Kalman filter will place on each measurement See application note A001 for more details on how to set these values for your specific application Input parameter sensorlD The sensor to get the requested data from Output parameter measVar The variance on the m
23. Rot Table 46 describes the VN100 SPI SetRefFrameRot function Table 46 VN100 SPI SetRefFrameRot VN100 SPI SetRefFrameRot Function prototype VN100 SPI SetRefFrameRot unsigned char sensorID float refFrameRot Behavior description Set the reference frame rotation matrix This matrix allows the user to transform all measured vectors from the body reference frame of the VN 100 to any other rigidly attached coordinate frame The effect of this transformation is that the computed attitude solution and measured measurement vectors will now be measured in the chosen coordinate system ofthe user and not the VN 100 coordinate system This is further explained in Section 6 26 of the User Manual Example Set the reference frame rotation parameters VN100 SPI Packet packet float rir 9 1 0 0 0 1 0 0 0 1 packet VNLOU SPI SecRetFrameRou 0 Lier KA Embedded Firmware Library 65 121 Embedded Firmware Library UM003 6 2 39 5 VN100 SPI GetAccGain Table 47 describes the VN100 SPI GetAccGain function Table 47 VN100 SPI GetAccGain Function prototype VN100 SPI GetAccGain unsigned char sensorID VN100 AccGainType gain Behavior description Get the current accelerometer gain setting The accelerometer on the VN 100 can be set to either a 2g or 6g gain setting Called functions VN100 SPI ReadRegister Example Get the accelerometer gain VN100 SPI Packet packet VN100 AccGainType gain
24. SPI GetYPRMagAccRates Get the yaw pitch roll magnetic acceleration and angular rates KJ Embedded Firmware Library 26 121 Embedded Firmware Library UM003 VN100 SPI Tare Zero out the current attitude VN100 SPI Reset Reset the VN 100 sensor VN100 SP1I GetAcclnertial Get the measured inertial acceleration VN100 SPI GetMaglnertial Get the measured inertial magnetic KJ Embedded Firmware Library 27 121 Embedded Firmware Library UM003 6 2 1 VN100 SPI ReadRegister Table 9 describes the VN100 SPI ReadRegister function Table 9 VN100 SPI ReadRegister Function prototype VN100 SPI Packet VN100 SPI ReadRegister unsigned char sensorID unsigned char reglD unsigned char reg Width Behavior description Read the register with the ID regID on a VN 100 sensor using the SPI interface Input parameter 1 sensorlD The sensor to get the requested data from Called functions VN_SPI_ SetSS VN SPI SendReceive VN Delay Example Read model number register VN100 SPI Packet packet packet VN100 SPI ReadRegister 0 VN100 REG MODEL 3 KA Embedded Firmware Library 28 121 Embedded Firmware Library UM003 6 2 2 VN100 SPI WriteRegister Table 10 describes the VN100 SPI WriteRegister function Table 10 VN100 SPI WriteRegister Function prototype VN100 SPI Packet VN100 SPI WriteRegister unsigned char sensorID unsigned char reglD unsigned char regWidth unsigned long ptrWriteValues Behavior desc
25. Tuning 6 2 35 VN100 SPI GetAccComp 6 2 36 VN100 SPI SetAccComp 6 2 37 VN100 SPI GetRefFrameRot Embedded Firmware Library UM003 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 5 121 Embedded Firmware Library 6 2 38 VN100 SPI SetRefFrameRot 6 2 39 VN100 SPI GetAccGain 6 2 40 VN100 SPI SetAccGain 6 2 41 VN100 SPI RestoreFactorySettings 6 2 42 VN100 SPI Tare 6 2 43 VN100 SPI Reset 6 2 44 VN100 SPI GetAcclnertial 6 2 45 VN100_SPI_GetMaglnertial 7 Math Library 7 1 DATA STRUCTURES 7 2 MATH LIBRARY FUNCTIONS 7 2 1 VN DotP 7 2 2 VN CrossP 7 2 3 VN VecAdd 7 2 4 VN VecSub 7 2 5 VN VecMultT 7 2 6 VN Diagonal 7 2 7 VN MatAdd 7 2 8 VN MatSub 7 2 9 VN MatMult 7 2 10 VN MatMult MMT 7 2 11 VN MatMultMTM 7 2 12 VN MatScalarMult 7 2 13 VN MatVecMult 7 2 14 VN MatTVecMult 7 2 15 VN MatCopy 7 2 16 VN Matinv 7 2 17 VN SkewMatrix 7 2 18 VN Transpose 7 2 19 VN Norm 7 2 20 VN Normalize 7 2 21 VN Quat2DCM 7 2 22 VN YPR2DCM 7 2 23 VN MatZeros Embedded Firmware Library UM003 65 66 67 68 69 70 7i 72 73 73 73 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 6 121 Embedded Firmware Library 7 2 24 VN_Quat2Euler121 7 2 25 VN_Quat2Euler123 7 2 26 VN_Quat2Euler131 7 2 27 VN_Quat2Euler132 7 2 28 VN_Quat2Euler212 7 2 29 VN_Quat2Euler213 7 2 30 VN_Quat2Euler231 7 2 31 VN_Quat2
26. a directional cosine matrix VN MatZeros Sets all elements of matrix A equal to zero VN Quat2Fuler121 Convert a quaternion attitude representation to an Fuler angle 1 2 1 set VN_Quat2Euler123 Convert a quaternion attitude representation angle 1 2 3 set VN_Quat2Euler131 Convert a quaternion attitude representation angle 1 3 1 set VN_Quat2Euler132 Convert a quaternion attitude representation angle 1 3 2 set VN_Quat2Euler212 Convert a quaternion attitude representation angle 2 1 2 set VN_Quat2Euler213 Convert a quaternion attitude representation angle 2 1 3 set VN_Quat2Euler231 Convert a quaternion attitude representation angle 2 3 1 set VN_Quat2Euler232 Convert a quaternion attitude representation angle 2 3 2 set VN_Quat2Euler312 Convert a quaternion attitude representation angle 3 1 2 set VN_Quat2Euler313 Convert a quaternion attitude representation angle 3 1 3 set VN_Quat2Euler321 Convert a quaternion attitude representation to an Euler KJ Embedded Firmware Library 74 121 Embedded Firmware Library UM003 VN Quat2Euler323 VN SubQuat VN QuatKinematicDiffEq VN YPRKinematicDiffEq VN Body2Inertial VN Inertial2Body Convert a quaternion attitude representation to an Fuler angle 3 2 3 set Convert a quaternion attitude representation to the Gibbs angle representation Convert a quaternion attitude representation to an Modified Rodrigues Parameters representation Convert a quate
27. al data that is passed back to the user from the VN 100 will either take the form of a 32 bit unsigned integer or a 32 bit floating point number The following example code shows how the data in the SPI response packet is accessed as a 32 bit unsigned integer VN100 SPI Packet ReturnPacket VN100 BaudType baudRate VN100 Baud 115200 Set the baud rate to 115200 7 7 ReturnPacket VN100 SPI SetBaudRate 0 VN100 Baud 115200 Check to see if the baud rate was set correctly 1T VNLIOO BandType ReturmPacket gt Datal0 UlnG YNLOO Baud 115200 4 The baud rate was set successfully telse Check the error code The next example shows how you can access the data in the SPI response packet as a floating point value VN100 SPI Packet ReturnPacket float fp 4 1 0 1 0 0 99 0 99 KA Embedded Firmware Library 24 121 Embedded Firmware Library UM003 Set the baud rate to 115200 7 ReturnPacket VN100 SPI SetFiltActTuning 0 amp fp 0 amp fp 1 fp 2 amp fp 3 Check to see if the second tuning parameter was set correctly 1f fabs ReturnPacket gt Data 1 Float fp 1 lt 0 0001f The parameter was set successfully lelse Check the error code 6 2 VN 100 library functions Table 8 lists the various functions of the VN 100 firmware library Table 8 VN 100 library functions KA Embedded Firmware Library 25 121 Embedded Firmware Library UM003 VN100
28. ameter 1 sensorlD gt The sensor to set the slave select line for This parameter allows the user to communicate with multiple orientation sensors Input parameter 2 State gt The state to set the slave select to Two possibilities are allowed either VN PIN LOW or VN_PIN_HIGH Example Example code for an STM32F103 ARM7 MCU void VN SPI SetSS unsigned char sensorID VN PinState state User code to set SPI SS lines goes here switch sensorID case 0 if state VN PIN LOW Start SPI Transaction Pull SPI CS line low GPIO ResetBits GPIOA GPIO Pin 0 else End SPI transaction Pull SPI CS line high GPIO SetBits GPIOA GPIO Pin 0 break KA Embedded Firmware Library 18 121 Embedded Firmware Library UM003 ieee VN_SPI_SendReceive Table 6 describes the VN SPI SendReceive function Table 6 VN_SPI_SendReceive Function prototype VN SPI SendReceive unsigned long data Behavior description Transmits the given 32 bit word on the SPI bus The user needs to place their hardware specific logic here to send 4 bytes out the SPI bus The slave select line is controlled by the function VN SPI SetSS given above so the user only needs to deal with sending the data out the SPI bus with this function Example Example code for an STM32F103 ARM7 MCU unsigned long VN SPI SendReceive unsigned long data User code to send out 4 bytes over SPI goes here unsigned long i
29. any usable units The magnetic vector is calibrated at the factory to have a magnitude of one on the XY plane Input parameter sensorlD The sensor to get the requested data from Output parameter 1 q The address of the location to write the returned measured quaternion 4x1 Example Get the quaternion and magnetic VNIUU SPI Packer packet float quat 4 float magla packet VN100 SPI GetQuatMag 0 guat mag KA Embedded Firmware Library 42 121 Embedded Firmware Library UM003 6 2 16 8 VN100 SPI GetQuatAcc Table 24 describes the VN100 SPI GetQuatAcc function Table 24 VN100 SPI GetQuatAcc Function prototype VN100 SPI GetQuatAcc unsigned char sensorID float q float acc Behavior description The quaternion is a 4x1 unit vector with the fourth term q 3 as the scalar term Example Get the quaternion and acceleration VN100 SPI Packet packet float quat 4 float acco packet VNLOO SPi GerOuatAcc 0 guat acc KA Embedded Firmware Library 43 121 Embedded Firmware Library UM003 6 2 17 7 VN100 SPI GetQuatRates Table 25 describes the VN100 SPI GetQuatRates function Table 25 VN100 SPI GetQuatRates Function Name VN100 SPI GetQuatRates unsigned char sensorID float q float rates Function prototype VN100 SPI_GetQuatRates Example Get the quaternion and angular rates VN100 SPI Packet packet float quat 4 float rates 3 packet VN
30. aw pitch roll orientation angles Example Get the yaw pitch and roll VN100 SPI Packet packet float yaw pitch roll packet VNIOU SPI GetyrPRi0 yaw piteh rOL1 7 KA Embedded Firmware Library 40 121 Embedded Firmware Library UM003 6 2 14 VN100 SPI GetQuat Table 22 describes the VN100 SPI GetQuat function Table 22 VN100 SPI GetQuat Function prototype VN100 SPI GetQuat Behavior description Get the measured attitude quaternion The quaternion is a 4x1 vector unit vector with the fourth term q 3 as the scalar term Input parameter sensorlD The sensor to get the requested data from Output parameter q The address of the location to write the returned measured quaternion 4x1 Pointer to SPI packet returned by the sensor Called functions VN100 SPI ReadRegister Example Get the quaternion VNIOO SPI Packet packet float quat 4 packet VN100 SPI GetQuac O qual KA Embedded Firmware Library 41 121 Embedded Firmware Library UM003 6 2 15 VN100 SPI GetQuatMag Table 23 describes the VN100 SPI GetQuatMag function Table 23 VN100 SPI GetQuatMag Function prototype VN100 SPI GetQuatMag unsigned char sensorID float q float mag Behavior description Get the measured attitude quaternion and magnetic vector The quaternion is a 4x1 unit vector with the fourth term q 3 as the scalar term The magnetic is a 3x1 vector The measured magnetic vector does not have
31. cRates Function prototype VN100 SPI GetQuatMagAccRates unsigned char sensorID float q float mag float acc float rates Behavior description Get the measured attitude quaternion magnetic acceleration and angular rates Input parameter sensorlD The sensor to get the requested data from Output parameter 1 q Measured quaternion 4x1 Output parameter 2 mag The magnetic measured vector 3x1 iene VN100 SPI ReadRegister Example Get the quaternion magnetic acceleration and angular rates VN100 SPI Packet packet float quat 4 float magii float acc 3 float rates 3 packet VN100 SPI GetQuatMagAccRates 0 quat mag acc rates KA Embedded Firmware Library 47 121 Embedded Firmware Library UM003 6 2 21 VN100 SPI GetYPRMagAccRates Table 29 describes the VN100 SPI GetYPRMagAccRates function Table 29 BVN100 SPI GetYPRMagAccRates Function prototype VN100 SPI GetYPRMagAccRates unsigned char sensorID float YPR float mag float acc float rates Behavior description Get the yaw pitch roll magnetic acceleration and angular rates VN100 SPI ReadRegister Example Get the yaw pitch roll magnetic acceleration and angular rates VN100 SPI Packet packet float ypr 3 float mag 3 float acc 3 float rates 3 packet VN100 SPI GetYPRMagAccRates 0 ypr mag acc rates KA Embedded Firmware Library 48 121 Embedded Fir
32. ccel body Get body acceleration VN Body2Inertial accel body q accel inertial Convert to inertial measured acceleration accel inertial 2 VN G Remove gravity in inertial frame Now accel inertial is the actual acceleration measured in the body frame It can be integrated once to find inertial velocity and twice to find inertial acceleration KA Embedded Firmware Library 118 121 Embedded Firmware Library UM003 7 2 44 VN Inertial2Body Table 98 describes the VN Inertial2Body function Table 98 VN Inertial2Body Function prototype void VN Inertial2Body float v1 float q float v2 Behavior description Convert a vector measured in the inertial frame into the body reference frame Input parameter 1 Vector measured in the inertial reference frame Input parameter 2 q quaternion attitude of body with respect to the inertial reference frame Input in the quaternion here that you receive from the attitude sensor Example Compute the body acceleration without gravity float accel body 3 Accel in body frame float gravitybi3 Gravity in body frame float q 4 Quaternion 7 float gravityI 3 0 0 VN G Gravity acceleration in inertial frame VNIOO SPI GetQuatAcc 0 q accel body Get quat and measured accel in body reference frame VN Inertial2Body gravity qd GravityB Convert gravity into body frame VN vecSub accel body gravityB
33. ction prototype void VN MatCopy float A unsigned long nrows unsigned long ncols float B Behavior description Copy the values from one matrix to another Example Copy Matrix A into Matrix B VN CreateMatrix A 3 3r tly 070 0 1 0 0 0 1 7 7 Identity matrix VN CreateMatrix B 3 3r 10 VN MatCopy A 3 3 B B will now be equal to A KA Embedded Firmware Library 90 121 Embedded Firmware Library UM003 7 2 16 VN Matinv Table 70 describes the VN Matlinv function Table 70 VN Matinv Function prototype void VN Matinv float FA s32 n float B Behavior description Compute the matrix inverse of A Matlab equation B inv A Example Calculate inverse of A VN CreaceMetrix st 3 3 1707070 1 070 0 1 Identity matrix 7 YN CreateMatrix B 3r 3 1O0 VN MatInv A 3 B B will now be equal to inverse of A KA Embedded Firmware Library 91 121 Embedded Firmware Library UM003 7 2 17 VN SkewMatrix Table 71 describes the VN SkewMatrix function Table 71 VN SkewMatrix Function prototype void VN SkewMatrix float V float A Behavior description Compute the matrix cross product of vector V This operation converts a vector into a matrix that when multiplied by another vector would give the result of a cross product operation between the two vectors A skew V where A b cross V b if b is a vector same size as V Example Calc
34. d Firmware Library UM003 6 2 24 VN100 SPI GetAcc Table 32 describes the VN100 SPI GetAcc function Table 32 VN100 SPI GetAcc Function prototype VN100 SPI GetAcc unsigned char sensorID float Acc Behavior description Get the measured acceleration The measured acceleration has the units of m s 2 and its range is dependent upon the gain set by the VN100 SPI SetAccGain function Called functions VN100 SPI ReadRegister Example Get the acceleration measurements VN100 SPI Packet packet float acc 3 packet VN100 SPI GetAcc 0 acc KA Embedded Firmware Library 51 121 Embedded Firmware Library UM003 6 2 25 5 VN100 SPI GetRates Table 33 describes the VN100 SPI GetRates function Table 33 VN100 SPI GetRates Function prototype VN100 SPI GetRates Behavior description Get the measured angular rates The measured angular rates have the units of rad s This is the filtered angular rate and is compensated by the onboard Kalman filter to account for gyro bias drift Input parameter sensorlD The sensor to get the requested data from Output parameter rates The measured angular rates 3x1 in rad s Called functions VN100 SPI ReadRegister Example Pointer to SPI packet returned by the sensor Get the angular rate measurements VN100 SPI Packet packet float rates 3 packet VNIOU SPI CECRaCces 0 raves KA Embedded Firmware Library 52 121 Embedded Firmware Library UM003
35. ded Firmware Library 15 121 Embedded Firmware Library UM003 4 Device firmware overview This section describes in detail the firmware library provided for each device The related functions are fully described along with an example of how to use them The functions are described in the following format Table 4 Function description format KA Embedded Firmware Library 16 121 Embedded Firmware Library UM003 5 User Configuration Files The VectorNav embedded firmware library is platform independent In order for this library to be used on a specific hardware platform the user will need to modify two files to enable hardware specific functionality All of the necessary user configurable parameters and functions are located in the VN user h and VN user c source files 5 1 Device Selection The user needs to select which devices they want to control using the embedded firmware library In the VN user h file you will find a set of constants one for each device provided by VectorNav The code for each device provided by the embedded library is conditionally compiled if the corresponding name of the device is defined as a constant in the VN user h header file For instance if you are working on a project using the VN 100 orientation sensor then in the VN user h file you will want to make sure that the following line is NOT commented out KK KKK KK KK KK KK KKK KK KK KK KK KKK KK KK KK VN 100 KK KK KK KK KK KK KK kK KKK KK KK KK KKK KK
36. dth VN100 Error ErrorListOverflow VN1OO Error ADOR Type Asynchronous Data Output Register typedef enum VN100 ADORType VN100 ADOR OFF VN100 ADOR YPR VN100 ADOR QTN VN100 ADOR QTM VN100 ADOR QTA VN100 ADOR QTR VN100 ADOR QMA VN100 ADOR QAR VN100 ADOR QMR VN100 ADOR DCM VN100 ADOR MAG VN100 ADOR ACC XO TI oF OF 5 GN Fr Embedded Firmware Library O02 0x03 Ox04 0x06 250 UM003 22 121 Embedded Firmware Library UM003 VN100 ADOR GYR 12 VN100 ADOR MAR 1 VN100 ADOR YMR 14 VN100 ADORType The ADOR register is described in more detail in Section 6 6 of the VN 100 User Manual 6 1 5 ADOF Type The ADOF register values are represented by the following data structure Asynchronous Data Ouput Rate Register typedef enum VN100 ADOFType VN100 ADOF 1H7 a VN100 ADOF 2HZ Oy VN100 ADOF 4HZ a VN100 ADOF 5HZ 5 VN100 ADOF 10HZ Io VN100 ADOF 20H2 20 VN100 ADOF 25HZ D VN100 ADOF 40HZ 20 VN100 ADOF 50HZ oo VN100 ADOF 100HZ 100 VN100 ADOF 200HZ 200 VN100 ADOFType The ADOF register is described in more detail in Section 6 7 of the VN 100 User Manual 6 1 6 Baud Type The baud rate register is represented by the following data structure Serial Baud Rate Register typedef enum VN100 BaudType VN100 Baud 9600 9600 VN100 Baud 19200 19200 VN100 Baud 38400 38400 VN100 Baud 57600
37. e following symbols are used to highlight important information within the manual U The information symbol points to important information within the manual Q The warning symbol points to crucial information or actions that should be followed to avoid reduced performance or damage to the navigation module Technical Support Our website provides a large repository of technical information regarding our navigation sensors A list of the available documents can be found at the following address http www vectornav com support If you have technical problems or cannot find the information that you need in the provided documents please contact our support team by email or phone Our engineering team is committed to providing the required support necessary to ensure that you are successful with the design integration and operation of our embedded navigation sensors Technical Support Contact Info Email support vectornav com Phone 1 512 772 3615 KA Embedded Firmware Library 3 121 Embedded Firmware Library Table of Contents 1 Introduction 2 Document and Library Rules 2 1 ACRONYMS 2 2 NAMING CONVENTIONS 3 Firmware Library 3 1 PACKAGE DESCRIPTION 3 1 1 Examples folder 3 1 2 Library folder 3 1 3 Project folder 3 1 4 Description of firmware library files 3 2 LIBRARY INITIALIZATION AND CONFIGURATION 4 Device firmware overview 5 User Configuration Files 5 1 DEVICE SELECTION 5 2 USER FUNCTIONS 5 2 1 VN_SPI_SetSS 5
38. e the addition of vector A with vector B Example Add vector A and B float A 3 float B 3 float C 3 VN VecAdd A B 3 C KA Embedded Firmware Library 78 121 Embedded Firmware Library UM003 7 2 4 VN_VecSub Table 58 describes the VN VecSub function Table 58 VN VecSub Function prototype void VN VecSub float A float B unsigned long rows float C Behavior description Compute the subtraction of vector A with vector B Example Subtract vector A and B float A 3 float B 3 float C 3 VN VecSub A B 3 C KA Embedded Firmware Library 79 121 Embedded Firmware Library UM003 7125 VN_VecMultT Table 59 describes the VN_VecMultT function Table 59 VN VecMultT Function prototype void VN VecMultT float FA float BT unsigned long rows float C Behavior description Compute the multiplication of a vector with the transpose of another vector The result will be a square matrix with the size of nxn where N rows Output parameter C result of multiplication of A with the transpose of B Example Multiply vector A with transpose of vector B float A 3 float B 3 VN CreateMatrix C 3 3y 10 VN VecMultT A B 3 C KA Embedded Firmware Library 80 121 Embedded Firmware Library UM003 7 2 6 VN Diagonal Table 60 describes the VN Diagonal function Table 60 VN Diagonal Function prototype void VN Diagonal float scalar unsigned long Aro
39. easured inputs to the filter This is a 10x1 vector Pointer to SPI packet returned by the sensor Called functions VN100 SPI ReadRegister Example Get the filter measurement variance parameters VN100 SPI Packet packet float measVar 10 packet VN100 SPI GetFiltMeasVar 0 measVar KA Embedded Firmware Library 56 121 Embedded Firmware Library UM003 6 2 30 VN100 SPI SetFiltMeasVar Table 38 describes the VN100 SPI SetFiltMeasVar function Table 38 VN100 SPI SetFiltMeasVar VN100 SPI SetFiltMeasVar Function prototype VN100 SPI SetFiltMeasVar unsigned char sensorID float measVar Behavior description Set the Kalman filter measurement variance parameters This is discussed in the User Manual in Section 6 22 The measurement variance parameters controls how much weight the Kalman filter will place on each measurement See application note A001 for more details on how to set these values for your specific application Input parameter sensorlD The sensor to get the requested data from Output parameter measVar The variance on the measured inputs to the filter This is a 10x1 vector Pointer to SPI packet returned by the sensor Called functions VN100 SPI WriteRegister Example Set the filter measurement variance parameters VN100 SPI Packet packet float measVar 10 le 9 1le 9 1le 9 1le 9 1le 6 1le 6 1e 6 le 6 1e 6 1e 6 packet VN100 SPI SetFiltMeasVar 0 measVar KA
40. ehavior description Send a tare command to the selected VN 100 The tare command will zero out the current sensor orientation The attitude of the sensor will be measured form this point onwards with respect to the attitude present when the tare command was issued It is important with v4 of the firmware to keep the device still for at least 3 seconds after performing a tare command The tare command will also set the reference vectors in the inertial frame to the vectors currently measured in the body frame Example Zero out current attitude VN100 SPI Packet packet packet VNIUO SPI Tare 0 KA Embedded Firmware Library 69 121 Embedded Firmware Library UM003 6 2 43 VN100 SPI Reset Table 51 describes the VN100 SPI Reset function Table 51 VN100 SPI Reset Function prototype VN100 SPI Reset unsigned char sensorlD Behavior description Command the given sensor to perform a device hardware reset This is equivalent to pulling the NRST pin low on the VN 100 Any changes to any of the registers on the VN 100 that were made since last issuing a Write Settings commands will be lost Example Reset the sensor VN100 SPI Packet packet packet VN100 SPI Reset 0 KA Embedded Firmware Library 70 121 Embedded Firmware Library UM003 6 2 44 VN100 SPI GetAcclInertial Table 52 describes the VN100 SPI GetAcclnertial function Table 52 VN100 SPI GetAccInertial Function prototype VN100 SPI GetAcclInertial
41. ert the quaternion into a Modified Rodrigues Parameters float g 4 float MRP 3 VNLOO SPI GetOuat 0 q Get quaternion from device VNLOO Quat2MRP q MRP Compute the Modified Rodrigues Parameters KA Embedded Firmware Library 112 121 Embedded Firmware Library UM003 7 2 38 VN Quat2PRV Table 92 describes the VN Quat2PRV function Table 92 VN Quat2PRV Function prototype void VN Quat2PRV float a float PRV Behavior description Convert a quaternion attitude representation to the principal rotation vector Example Convert the quaternion into a principal rotation vector float g 4 float PRV 3 VNLOO SPI GetOuat 0 q Get quaternion from device VNLOO_OQuat2PRV q PRV Compute the principal rotation vector KA Embedded Firmware Library 113 121 Embedded Firmware Library UM003 7 2 39 VN AddQuat Table 93 describes the VN AddQuat function Table 93 VN AddQuat Function prototype void VN AddQuat float q1 float a2 float q3 Behavior description VN AddQuat provides the quaternion which corresponds to performing two successive rotations from q1 and q2 Example Create a combined rotation of quaternion 1 and 2 float q1 4 float g2 4 float g3 4 VN100 AddQuat ql q2 q3 KA Embedded Firmware Library 114 121 Embedded Firmware Library UM003 7 2 40 VN SubQuat Table 94 describes the VN SubQuat function Table 94 VN SubQuat Function pro
42. fine VN100 REG ACT 25 define VN100 REG RER 26 define VN100 REG YMR 27 define VN100 REG ACG 28 More information on each of these register can be found in Section 6 of the VN 100 User Manual 6 1 2 Command IDs The available commands for the VN 100 are presented by the following data structure Command IDs 7 typedef enum VN100 CmdID VN100 CmdID ReadRegister 0x01 KA Embedded Firmware Library 21 121 Embedded Firmware Library VN100 CmdID WriteRegister VN100 CmdID WriteSettings VN100 CmdID RestoreFactorySettings 0x05 VNLOO CmAID Tare YNLOO CMAID Reset VN100 CmdID The commands are described in more detail in Section 5 2 of the VN 100 User Manual 6 1 3 Error IDs The error codes for the VN 100 are represented by the following data structure System Error typedef enum VN100 Error The error codes are described in more detail in Section 5 3 of the VN 100 User Manual 6 1 4 The ADOR register values are represented by the following data structure VN100 Error None VNIOO Error ErrorLisiCverilow VN100 Error HardFaultException VNIOO Error JnputBurterOverrlow VNI00O Error InvalidChecksum VN100 Error InvalidCommand VN100 Error NotEnoughParameters VN100 Error TooManyParameters VN100 Error InvalidParameter VN100 Error InvalidRegister VN100 Error UnauthorizedAccess VN100 Error WatchdogReset VNLO0 Error OucpurcBurterOver Low VN100 Error InsufficientBandwi
43. first letter in each word is in upper case For example VN100 SPI WriteRegister KA Embedded Firmware Library 10 121 Embedded Firmware Library UM003 3 Firmware Library 3 1 Package description The firmware library is provided in one single zip file After extracting this zip file you should have one folder VN FWLib that contains the following subfolders Table2 Firmware library folder structure E CO YN PwLib E O FwLib E examples E VN100 CJ SPI O UART E O library fm inc am SFC Ta project 3 1 1 Examples folder This Examples folder contains for each product examples for how to use each of the provided interfaces Each example will contain the minimum number of files required to run a typical example listed below e Readme txt brief text file describing the example and how to make it work e VN user h header file allowing the user to configure which products should be included in the library e VN_user c source file containing the platform specific routines that need to be modified by the user for the example to work e main c main example code All of the examples provided are independent of the software toolchain Balad Library folder The Library folder contains all the subdirectories and files that make up the core of the library e inc sub folder contains the firmware library header files They do not need to be modified by the user VN type h common data types and enumeration used in al
44. ibes the VN Quat2Euler231 function Table 84 VN Quat2Euler231 Example Convert the quaternion into a Euler 231 angles float 9 4 float Fuler231 3 VN100 SPI GetQuat 0 q Get quaternion from device VNLOO Quat2Euler231 q Euler231 Compute the Euler 231 angles KA Embedded Firmware Library 105 121 Embedded Firmware Library UM003 7 2 31 VN Quat2Euler232 Table 85 describes the VN Quat2Euler232 function Table 85 VN Quat2Euler232 Function prototype void VN_Quat2Euler232 float a float Euler232 Behavior description Convert a quaternion attitude representation to an Euler angle 2 3 2 set Matlab equation Euler232 quat2angle q YZY Example Convert the quaternion into a Euler 232 angles float 9 4 float Euler232 3 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2Euler232 q Euler232 Compute the Euler 232 angles KA Embedded Firmware Library 106 121 Embedded Firmware Library UM003 7 2 32 VN Quat2Euler312 Table 86 describes the VN_Quat2Euler312 function Table 86 VN Quat2Euler312 Function prototype void VN_Quat2Euler312 float q float Euler312 Behavior description Convert a quaternion attitude representation to an Euler angle 3 1 2 set Matlab equation Euler312 quat2angle q ZXY Example Convert the quaternion into a Euler 312 angles float g 4 float Fuler312 3 VN100 SPI GetQuat 0 q Get quate
45. iption Computes the time rate of change of the 321 Euler angles yaw pitch roll as a function of the angular rates You can use this function if you need to determine how the Euler angles are instantaneously changing as a function of time Example Compute the instantaneous time derivative of the Euler angles float g 4 float ypr 3 float angular rates 3 float ypr dot 3 VN100 SPI GetQuatRates 0 q angular rates Get quat and angular rates VN Quat2Euler321 q ypr Convert quaternion into yaw pitch and roll VN OvuatKinematicDiffkq q angular rates ypr dot Get ypr dot yor dot yaw dot pitch dot roll dot where dot is derivative KA Embedded Firmware Library 117 121 Embedded Firmware Library UM003 7 2 43 VN Body2Inertial Table 97 describes the VN Body2Inertial function Table 97 8 VN Body2Inertial Function prototype void VN Body2Inertial float v1 float q float v2 Behavior description Converts a vector measured in the body frame into the inertial reference frame Input parameter 1 Vector measured in the body reference frame Input parameter 2 q quaternion attitude of body with respect to the inertial reference frame Input in the quaternion here that you receive from the attitude sensor Example Compute the inertial acceleration float accel body 3 float accel inertial gt float g 4 quaternion VNLOO SPL GetQuats cc 0 Gd a
46. l other files VN lib h main header file that includes all other header files VN math h math library header file VN100 h header file for the VN 100 specific code e src sub folder contains the firmware library source files They do not need to be modified by the user KA Embedded Firmware Library 11 121 Embedded Firmware Library UM003 VN lib c main library source file Includes routines that are shared between all VectorNav products VN math c math library source file VN100 c source file for the VN 100 specific code All library files are coded in Strict ANSI C and are independent from the software toolchain pe Mc Project folder The Project folder contains a standard template project program that compiles all library files plus all the user modifiable files that are necessary to create a new project VN user h header file for user modifiable code and settings Use this file to set which code will compile VN user c source file for the user modifiable code This file needs to be modified by the user to handle platform specific features main c main program body 3 1 4 Description of firmware library files Table 2 lists and describes the different files used by the firmware library The firmware library layout design and file relationships are shown in Figure 2 Each product has both a source and header file The header file VN lib h includes all the product header files This is the onl
47. le is compiled if the VN100 is defined in the VN user h file All functions specific to the VN 100 product are contained in this file Main example program body mware Library 13 121 Embedded Firmware Library UM003 Figure 1 Firmware library file architecture Application Layer VN lib h VN type h VN math h VN math c API Layer VN lib c VN100 h VN100 c Hardware Layer KA Embedded Firmware Library 14 121 Embedded Firmware Library UM003 3 2 Library initialization and configuration This section describes how to initialize and setup the VectorNav embedded library 1 Inthe main application file include the VN lib h for example include VN lib h 2 In the VN user h header file uncomment the lines necessary to include the functions for the product s that you are interested in For example if you want to interface with the VN 100 then you will need to uncomment the following line define VN100 3 If you are using the SPI interface then you will need to modify the following functions found in the VN config c file a VN SPI SetSS Place your hardware specific code here that is required to set reset the SPI slave slect lines for the given sensor b VN SPI SendReceive Place your hardware specific code here that is required to send and receive 4 bytes over the SPI bus c VN Delay Place your hardware specific code here that is required to delay the processor by the given number of microseconds KA Embed
48. lt Table 66 describes the VN MatScalarMult function Table 66 VN MatScalarMult Function prototype void VN MatScalarMult double A double scalar unsigned long Arows unsigned long Acols double C C The result of the operation scalar A Example Multiply all the terms in matrix A by 10 VN CreateMatrix A 3 5r 10 VN CreateMatrix B 2 Sy TUS VN MatMultMTM A 10 0f 3 5 B KA Embedded Firmware Library 87 121 Embedded Firmware Library UM003 7 2 13 VN MatVecMult Table 67 describes the VN MatVecMult function Table 67 VN MatVecMult Function prototype void VN MatVecMult float A float B unsigned long Arows unsigned long Acols float C Example Moleiply Matrix A by vector B VN CreateMatrix A 3 3p 10 float B 3 float C 3 VN MatVecMult A B 3 3 C KA Embedded Firmware Library 88 121 Embedded Firmware Library UM003 7 2 14 VN MatTVecMult Table 68 describes the VN MatTVecMult function Table 68 VN MatTVecMult Function prototype void VN MatTVecMult float FA float B unsigned long Arows unsigned long Acols float C Example Multiply transpose of matrix A by vector B VN CreateMatrix A 3 3p 10 float B 3 float C 3 VN MatTVecMult A B 3 3 C KA Embedded Firmware Library 89 121 Embedded Firmware Library UM003 7 2 15 VN MatCopy Table 69 describes the VN_MatCopy function Table 69 VN MatCopy Fun
49. mware Library UM003 6 2 22 VN100 SPI GetDCM Table 30 describes the VN100 SPI GetDCM function Table 30 VN100 SPI GetDCM Function prototype VN100 SPI GetDCM unsigned char sensorID float DCM Behavior description Get the measured attitude as a directional cosine matrix Input parameter sensorlD The sensor to get the requested data from Output parameter DCM Directional Cosine Matrix 9x1 The order of the terms in the matrix is first row second row third row Pointer to SPI packet returned by the sensor Called functions VN100 SPI ReadRegister Example Get the directional cosine matrix VN100 SPI Packet packet float dem data 9 0 float dem ptr amp dcm data 0 amp dcm data 3 amp dcm data 6 float dom dem ptr packet VN100 SPI GetDCM 0 dcm KA Embedded Firmware Library 49 121 Embedded Firmware Library UM003 6 2 23 VN100 SPI GetMag Table 31 describes the VN100 SPI GetMag function Table 31 VN100 SPI GetMag Function prototype VN100 SPI GetMag unsigned char sensorID float mag Behavior description Get the measured magnetic field The measured magnetic field does not have any usable units The magnetic vector is calibrated at the factory to have a magnitude of one on the XY plane Example Get the magnetic measurements VN100 SPI Packet packet float mag 3 packet VN100 SPI GetMag 0 mag KA Embedded Firmware Library 50 121 Embedde
50. oat ypr 3 VN CreateMatrix DCM 3 3 10 7 VN100 SPI GetYPR 0O amp ypr 0 e eypr l amp ypr 2 Get YPR from device VN100 YPR2DCM q DCM Compute the DCM KA Embedded Firmware Library 97 121 Embedded Firmware Library UM003 7 2 23 VN MatZeros Table 77 describes the VN MatZeros function Table 77 VN MatZeros Function prototype void VN MatZeros float FA unsigned long Arows unsigned long Acols Behavior description Sets all elements of matrix A equal to zero Matlab equation A zeros Arows Acols Example Zero out matrix A VN CreateMatrix A 3 3p 41 O O O ly 0 O O Of Identity matrix VN MatZeros A 3 3 Zero out matrix A KA Embedded Firmware Library 98 121 Embedded Firmware Library UM003 7 2 24 VN Quat2Euler121 Table 78 describes the VN_Quat2Euler121 function Table 78 VN Quat2Euler121 Function prototype void VN_Quat2Euler121 float q float Euler121 Behavior description Convert a quaternion attitude representation to an Euler angle 1 2 1 set Matlab equation Euler121 quat2angle q XYX Example Convert the quaternion into a Euler 121 angles float g 4 float Fulerl121 3 VN100 SPI GetQuat 0 q Get quaternion from device VNIOO Quat Fulerl2L O Buleriz Compute the Euler 121 angles KA Embedded Firmware Library 99 121 Embedded Firmware Library UM003 7 2 25 VN MQuat2Euler123 Table 79 describes the
51. ription Read the register with the ID regID on a VN 100 sensor using the SPI interface Input parameter 1 sensorID The sensor to write the requested data to Called functions VN SPI SetS5 VN SPI SendReceive VN Delay Example Write to baud rate register VN100 SPI Packet packet unsigned long newBaud 115200 packet VN100 SPI WriteRegister 0 VN100 REG SBAUD 1 amp newBaud KA Embedded Firmware Library 29 121 Embedded Firmware Library UM003 6 2 3 VN100 SPI GetModel Table 11 describes the VN100 SPI GetModel function Table 11 VN100 SPI GetModel Function prototype VN100 SPI GetModel unsigned char sensorID char model Behavior description Read the model number from the sensor Input parameter sensorlD The sensor to get the model number from Output parameter model Pointer to a character array where the requested model number is placed This needs to be a character array that is 12 characters in size Pointer to SPI packet returned by the sensor Called functions VN100 SPI ReadRegister Example Get the sensor model VN100 SPI Packet packet char model 12 packet VN100 SPI GetModel 0 model KA Embedded Firmware Library 30 121 Embedded Firmware Library UM003 6 2 4 VN100 SPI GetHWRev Table 12 describes the VN100 SPI GetHWRev function Table 12 VN100 SPI GetHWRev Function prototype VN100 SPI GetHWRev unsigned char sensorID unsigned long revision
52. rnion attitude representation to the principal rotation vector VN AddQuat provides the quaternion which corresponds to performing two successive rotations from q1 and q2 VN SubQuat provides the quaternion which corresponds to the relative rotation from q2 to q1 Computes the time rate of change of the quaternion parameters as a function of the angular rates Computes the time rate of change of the 321 Euler angles yaw pitch roll as a function of the angular rates Converts a vector measured in the body frame into the inertial reference frame Convert a vector measured in the inertial frame into the body reference frame KA Embedded Firmware Library 75 121 Embedded Firmware Library UM003 Fal VN_DotP Table 55 describes the VN_DotP function Table 55 VN_DotP Example Compute the dot product of A and B float A 3 float B 3 il oat GF C VN DotP A B KA Embedded Firmware Library 76 121 Embedded Firmware Library UM003 tabak VN CrossP Table 56 describes the VN CrossP function Table 56 VN CrossP Example Compute the cross product of A and B float A 3 float B 3 float C 3 VN CrossP A B C KA Embedded Firmware Library 77 121 Embedded Firmware Library UM003 Za VN_VecAdd Table 57 describes the VN_VecAdd function Table 57 VN VecAdd Function prototype void VN VecAdd float FA float B unsigned long rows float C Behavior description Comput
53. rnion from device VN100 Quat2Euler312 q Euler312 Compute the Euler 312 angles KA Embedded Firmware Library 107 121 Embedded Firmware Library UM003 7 2 33 VN Quat2Euler313 Table 87 describes the VN Quat2Euler313 function Table 87 VN Quat2Euler313 Function prototype void VN_Quat2Euler313 float a float Euler313 Behavior description Convert a quaternion attitude representation to an Euler angle 3 1 3 set Matlab equation Euler313 quat2angle q ZXZ Example Convert the quaternion into a Euler 313 angles float 9 4 float Buler313 3 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2Euler313 q Euler313 Compute the Euler 313 angles KA Embedded Firmware Library 108 121 Embedded Firmware Library UM003 7 2 34 VN MQuat2Euler321 Table 88 describes the VN Quat2Euler321 function Table 88 VN Quat2Euler321 Function prototype void VN_Quat2Euler321 float a float Euler321 Behavior description Convert a quaternion attitude representation to an Euler angle 3 2 1 set Matlab equation Euler321 quat2angle q ZYX Example Convert the quaternion into a Euler 321 angles float g 4 float Fuler321 3 VN100 SPI GetQuat 0 q Get quaternion from device VN100 Quat2Euler321 q Euler321 Compute the Euler 321 angles KA Embedded Firmware Library 109 121 Embedded Firmware Library UM003 7 2 35 VN Quat2Euler323 Table 89
54. rometer compensation parameters The purpose of these parameters is explained in Section 6 25 of the User Manual These parameters are not required for normal operation Example Set the accelerometer compensation parameters VN100 SPI Packet packet float C l2 AkO DQ hp DOO hp 0 O OY packet VNIVO SPI SecAccComp O act KA Embedded Firmware Library 63 121 Embedded Firmware Library UM003 6 2 37 7 VN100 SPI GetRefFrameRot Table 45 describes the VN100 SPI GetRefFrameRot function Table 45 VN100 SPI GetRefFrameRot VN100 SPI GetRefFrameRot Function prototype VN100 SPI GetRefFrameRot unsigned char sensorID float refFrameRot Behavior description Get the reference frame rotation matrix This matrix allows the user to transform all measured vectors from the body reference frame of the VN 100 to any other rigidly attached coordinate frame The effect of this transformation is that the computed attitude solution and measured measurement vectors will now be measured in the chosen coordinate system of the user and not the VN 100 coordinate system This is further explained in Section 6 26 of the User Manual Called functions VN100 SPI ReadRegister Example Get the reference frame rotation parameters VN100 SPI Packet packet float rfr 9 packet VNIOO SPI GetRerrrameRor Uy PET KA Embedded Firmware Library 64 121 Embedded Firmware Library UM003 6 2 38 8 VN100 SPI SetRefFrame
55. ry will help you get up and running with the data you need without having to deal with the inter workings of the device When working with inertial and orientation sensors in particular most users require some form of data post processing in order to fulfill their project requirements This post processing may be in the form of mathematical coordinate transformations or possibly selecting a different form of attitude representation Performing many of these mathematical transformations in an embedded environment is not a trivial task to say the least In order to help developers overcome this potential hurdle VectorNav provides an extensive set of math routines integrated into the firmware library This library consists of a wide variety of attitude and inertial guidance related functions that will assist developers in making use of the rich set of measurements provided by the VectorNav line of inertial sensors The driver source code is developed in Strict ANSI C Providing the library in Strict ANSI C makes it independent from the software toolchain Note that since the firmware is generic and covers all device functionalities the size and or execution speed of the application code will not likely be optimized for your application For many task the library may be used as is However for applications that have very strict requirements on code size or execution speed the library should be used as a reference on how to interface with the
56. sensors In this case the code may need to be tailored to meet your specific application requirements The firmware library user manual is structured as follows Definitions document conventions and firmware library rules Overview of the firmware library and examples on how to make use of the library Detailed description of the firmware library including all data structures and software functions for each of the VectorNav embedded sensors and related peripheral library files KA Embedded Firmware Library 8 121 Embedded Firmware Library UM003 2 Document and Library Rules 2 1 Acronyms Table 1 describes the acronyms used in the firmware and documentation Table 1 List of abbreviations KA Embedded Firmware Library 9 121 Embedded Firmware Library UM003 2 2 Naming conventions The firmware library uses the following naming conventions e All functions constants variables and macros start with VN_ e System and source header file names are preceded by VN_ for example VN_lib h e Registers for individual products are considered as constants Their names are in upper case The name of the registers is preceded by the product name followed by the register name The register name is the same as in the product user manual For example the ADOR register on the VN100 has the name VN100 ADOR e The name for all functions constants and variables that are specific to a given product are preceded by the product name The
57. totype void VN SubQuat float q1 float a2 float q3 Behavior description VN SubQuat provides the quaternion which corresponds to the relative rotation from q2 to q1 Example Create a relative rotation from q2 to ql float q1 4 float g2 4 float g3 4 VNLOO SubOuet Gly G2 43 KA Embedded Firmware Library 115 121 Embedded Firmware Library UM003 7 2 41 VN QuatKinematicDiffEq Table 95 describes the VN QuatKinematicDiffEq function Table 95 VN QuatKinematicDiffEq Function prototype void VN QuatKinematicDiffEq float a float rates float tq dot Behavior description Computes the time rate of change of the quaternion parameters as a function of the angular rates You can use this function if you need to determine how the quaternion parameters are instantaneously changing as a function of time Example Compute the instantaneous time derivative of the quaternion parameters float g 4 float angular rates 3 float q dot 4 VN100 SPI GetQuatRates 0 q angular rates Get quat and angular rates VN QuatKinematicDiffEq q angular rates q dot Derivative of quaternion KA Embedded Firmware Library 116 121 Embedded Firmware Library UM003 7 2 42 VN YPRKinematicDiffEq Table 96 describes the VN YPRKinematicDiffEq function Table 96 VN YPRKinematicDiffEq Function prototype void VN YPRKinematicDiffEq float YPR float rates float YPR_ dot Behavior descr
58. ual in Section 6 23 Example Set the magnetic hard soft iron compensation parameters VN100 SPI Packet packet float GL 12 1105050610 0 O 1 0 0 013 packet VN100 SPI SetHardSoftIronComp 0 HSI KA Embedded Firmware Library 59 121 Embedded Firmware Library UM003 6 2 33 VN100 SPI GetFiltActTuning Table 41 describes the VN100 SPI GetFiltActTuning function Table 41 VN100 SPI GetFiltActTuning VN100 SPI GetFiltActTuning Function prototype VN100 SPI GetFiltActTuning unsigned char sensorID float gainM float gainA float memM float memA Behavior description Get the filter active tuning parameters The active tuning parameters control how the filter handles dynamic disturbances in both magnetic and acceleration These values are not needed for normal operation More on these parameters can be found in the User Manual in Section 6 24 Example Get the filter active tuning parameters VN100 SPI Packet packet float atpl atp2 atp3 atp4 packet VN100 SPI GetPiltActTuning 0 atpl g atp2 amp atp3 atp4 7 KA Embedded Firmware Library 60 121 Embedded Firmware Library UM003 6 2 34 VN100 SPI SetFiltActTuning Table 42 describes the VN100 SPI SetFiltActTuning function Table 42 VN100 SPI SetFiltActTuning VN100 SPI SetFiltActTuning Function prototype VN100 SPI SetFiltActTuning unsigned char sensorID float gainM float gainA float memM float memA Beha
59. ulate skew matrix of A float A 3 1 O Oj float B 3 0 1 O VN CreateMeatrix C Bp opr l0 ly float D 3 VN SkewMatrix A C C will now equal skew matrix of A D VN MatVecMult C B 3 3 D D VN crossP A B O O 1 KA Embedded Firmware Library 92 121 Embedded Firmware Library UM003 7 2 18 VN Transpose Table 72 describes the VN Transpose function Table 72 VN Transpose Function prototype void VN Transpose float FA unsigned long Arows unsigned long Acols float B Behavior description Calculate the transpose of matrix A Matlab equation B transpose A Example Calculate transpose of A VN CreateMatrix A 3 3 1 2 3 4 5 6 7 8 9 VN CreateMatraix B 3 3r 10 k7 VN Transpose A 3 3 Bh B 41yp47 1o275r073767 9 t KA Embedded Firmware Library 93 121 Embedded Firmware Library UM003 7 2 19 VN Norm Table 73 describes the VN Norm function Table 73 VN Norm Function prototype float VN Norm float FA unsigned long m Behavior description Compute the length of the given vector with size m x 1 Input parameter 1 A Vector to compute the length of with size m x 1 Input parameter 2 m Number of terms in the vector A Example Calculate length of vector A float A 3 1 2 3 float len len VN Norm A 3 7 len sqrt 141 242 343 KA Embedded Firmware Library 94 121 Embedded Firmware Library UM003
60. vior description Set the filter active tuning parameters The active tuning parameters control how the filter handles dynamic disturbances in both magnetic and acceleration These values are not needed for normal operation More on these parameters can be found in the User Manual in Section 6 24 ee aS a e Example Set the filter active tuning parameters VN100 SPI Packet packet float atp 4 1 0 1 0 0 99 0 99 packet VNIO0 SPI SetriltActiuning 0 tp 0 gatpll 4tp Z2 s satrli KA Embedded Firmware Library 61 121 Embedded Firmware Library UM003 6 2 35 VN100 SPI GetAccComp Table 43 describes the VN100 SPI GetAccComp function Table 43 VN100 SPI GetAccComp Function prototype VN100 SPI GetAccComp unsigned char sensorID float AccComp Behavior description Get the accelerometer compensation parameters The purpose of these parameters is explained in Section 6 25 of the User Manual These parameters are not required for normal operation Example Get the accelerometer compensation parameters VN100 SPI Packet packet float act 12 packet VN100 SPI GetAccComp 0 act KA Embedded Firmware Library 62 121 Embedded Firmware Library UM003 6 2 36 5 VN100 SPI SetAccComp Table 44 describes the VN100 SPI SetAccComp function Table 44 VN100 SPI SetAccComp Function prototype VN100 SPI SetAccComp unsigned char sensorID float AccComp Behavior description Set the accele
61. ware Library UM003 7 Math Library The data structures used in the math library are described in Section 7 1 while Section 7 2 describes the firmware library functions 1 Data Structures 7 2 Math library functions Table 54 lists the various functions of the math firmware library Table 54 Math library functions VN VecMultT Compute the multiplication of a vector with the transpose of another vector VN Diagonal Create a zero matrix with the diagonal elements equal to the magnitude of a scalar VN_MatAdd Compute the addition of matrix A and B VN_MatSub Compute the subtraction of matrix A and B VN_MatMult Compute the multiplication of matrix A and B VN MatMultMMT Compute the multiplication of matrix A with the transpose of matrix B VN MatMultMTM Compute the multiplication of the transpose of matrix A with matrix B KA Embedded Firmware Library 73 121 Embedded Firmware Library UM003 VN SkewMatrix Compute the matrix cross product of vector V This operation converts a vector into a matrix that when multiplied by another vector would give the result of a cross product operation between the two vectors VN Transpose Calculate the transpose of matrix A Compute the length of the given vector with size m x 1 VN Normalize Compute the unit normal vector with the direction given by vector V1 VN Quat2DCM Convert a quaternion into to a directional cosine matrix VN YPR2DCM Convert the given yaw pitch and roll into
62. ws unsigned long Acols float A Behavior description Create a diagonal matrix with the diagonal terms equal to scalar and the non diagonal elements equal to zero Example Create 5x5 identity matrix VN CreateMatrax A 5 3r 10 7 VN Diagonal l Of 5 5S A KA Embedded Firmware Library 81 121 Embedded Firmware Library UM003 7 27 VN_MatAdd Table 61 describes the VN_MatAdd function Table 61 VN MatAdd Function prototype void VN MatAdd float A float B unsigned long Arows unsigned long Acols float C C Result of matrix addition with size of Arows x Acols Example Add matrix A and B EO get C VN CreateMatrix A 3 3 3 3 e AOF p 40337 r LORS VN CreateMatrix B 3 VN CreateMatrix C 3 VN MatAdd A B 3 3 C KA Embedded Firmware Library 82 121 Embedded Firmware Library UM003 7 2 8 VN MatSub Table 62 describes the VN MatSub function Table 62 VN MatSub Function prototype void VN MatSub float FA float B unsigned long Arows unsigned long Acols float C C Result of matrix subtraction with size of Arows x Acols Example Subtract matrix A and B to get C VN CreateMatrix A 3 3 0 y VN CreateMatrix B 3 3 TUJI VN CreateMatrix C 3 3 1 0 VN MatSub A B 3 3 C KA Embedded Firmware Library 83 121 Embedded Firmware Library UM003 1 2 9 VN MatMult Table 63 describes the VN MatMult function Table 63 VN
63. y file that needs to be included in the user application to interface with the library VN user h and VN user c are the only files that need to be modified by the user The VN user h file is used to determine which products will be included in the compiled version of the library KA Embedded Firmware Library 12 121 Embedded Firmware Library UM003 Table3 Firmware library files VN lib h Header file including all other header files VN lib c VN type h VN math h VN math c VN user h VN user c VN100 h VN100 c main c KJ Embedded Fir Source file that includes all code that is shared in between all of the VectorNav products Header file that includes all data types that are shared by all other files in the library Header file for the VectorNav math library Source file for the VectorNav math library This library is included to assist the user in performing attitude transformations and other matrix vector mathematics Header file for the user configuration file This file is used to set which products in the library are included when compiled For instance if you want to include the code necessary to interface with the VN100 then you need to uncomment the following line in this file define VN100 Source file for the user modifiable code Header file for the VN100 This file is compiled if the VN100 is define in the VN user h file Source file for VN 100 specific functions This fi
64. you check your compiler documentation before attempting to write your own delay US gt Time to delay the processor in microseconds Example Example code for an STM32F103 ARM7 MCU void VN Delay unsigned long delay uS unsigned long i fOrii delay UU LO FF Ng j KA Embedded Firmware Library 20 121 Embedded Firmware Library UM003 6 VN 100 Orientation Sensor The data structures used in the VN 100 firmware library are described in Section 6 1 while Section 6 2 describes the firmware library functions 6 1 Data Structures The data structures used by the VN 100 firmware library are defined here More information on the registers can be found in the VN 100 User Manual 6 1 1 Registers The registers present on the VN 100 are represented by as constants in the firmware as shown below VN 100 Registers define VN100 REG MODEL 1 define VN100 REG HWREV 2 define VN100 REG SN 3 define VN100 REG FWVER 4 define VN100 REG SBAUD 5 define VN100 REG ADOR 6 define VN100 REG ADOF 7 define VN100 REG YPR 8 define VN100 REG QTN 9 define VN100 REG QTM 10 define VN100 REG QTA 11 define VN100 REG QTR 12 define VN100 REG QMA 13 define VN100 REG QAR 14 define VN100 REG QMR ds define VN100 REG DCM 16 define VN100 REG MAG 17 define VN100 REG ACC 18 define VN100 REG GYR 19 define VN100 REG MAR 20 define VN100 REG REF 21 define VN100 REG SIG 22 define VN100 REG HSI 23 define VN100 REG ATP 24 de
Download Pdf Manuals
Related Search
Related Contents
KAC-8405 - ご利用の条件|取扱説明書|ケンウッド MOVI-PLC® Programação com PLC Editor - SEW Manual de instalação Manual de instalación 3GHD-OE 3GHD-OE-2 User manual Guida dell`utente di Synology NAS Basata su DSM 5.0 Barco RLM-W8 Regional Financial Management User Manual Deutsche Telekom Nokia 3720, TMO XTRA 2.2" 94g Grey Copyright © All rights reserved.