We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2018-12-21
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Magnetic
Downloaded: 3868 times
Not followed.
License: MIT license
Magnetic rotary click is a very accurate position sensing Click board which utilizes the HMC1512, a magnetic field displacement sensor IC.
Do you want to subscribe in order to receive notifications regarding "Magnetic rotary click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Magnetic rotary click" changes.
Do you want to report abuse regarding "Magnetic rotary click".
Library Description
The library performs a magnetic field angle measurement and calculates angle value to degrees. The library also performs the all necessary settings for the AD conversion, for example channel selection and mode setting. For more details check documentation.
Key functions:
uint16_t magnrotary_readADC( uint8_t cmndByte )
- Function returns a 12bit result of AD conversion.uint16_t magnrotary_outVoltADC( uint8_t cmdByte, uint16_t pwrVolt )
- Function returns ADC voltage value calculated to millivolts, depending on the VDD (power) voltage selection.double magnrotary_getFieldAngle( uint8_t cmdByte )
- Function returns a magnetic field angle calculated to degrees, in the range from -90 to 90 degrees.Examples description
The application is composed of the three sections :
void applicationTask()
{
magnAngle = magnrotary_getFieldAngle( _MAGNROTARY_CHA_POS_GND_NEG | _MAGNROTARY_MSB_ZEROS_ORDER );
FloatToStr( magnAngle, text );
floatCut();
mikrobus_logWrite( "Angle is : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( logDeg, _LOG_LINE );
Delay_ms( 300 );
}
Additional Functions :
void floatCut()
- - Makes float value to be rounded on two decimal places.void plotAngle()
- Sends results of angle on serial plotter.
Other mikroE Libraries used in the example:
Conversion
SPI
UART
Additional notes and information
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.