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-08-20
Package Version: 1.0.0.0
Example: 1.0.0.0
Category: Measurements
Downloaded: 3694 times
Not followed.
License: MIT license
V to Hz 2 click is a device that converts an analog voltage input signal into a pulse wave signal of a certain frequency.
Do you want to subscribe in order to receive notifications regarding "V to Hz 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "V to Hz 2 click" changes.
Do you want to report abuse regarding "V to Hz 2 click".
Library Description
Library initializes and defines GPIO driver and performs commands that can enable or disable the device and get frequency (FOUT) by getting the state of the INT pin. For more details check the documentation.
Key functions :
void vtohz2_enable( uint8_t state )
- The function performs enabling and disabling of the device.uint8_t vtohz2_getFreqOut( void )
- The function gets the out frequency on mikrobus INT pin.Example description
The application is composed of three sections:
void applicationTask()
{
if (UART_Rdy_Ptr())
{
rxDat = UART_Rd_Ptr();
if ((rxDat == '+') && (percCheck < 100))
{
pwmDutySum += onePercPwm;
percCheck += 1;
}
else if ((rxDat == '-') && (percCheck > 0))
{
pwmDutySum -= onePercPwm;
percCheck -= 1;
}
else if ((rxDat == '*') && (percCheck <= 90))
{
pwmDutySum += tenPercPwm;
percCheck += 10;
}
else if ((rxDat == '/') && (percCheck >= 10))
{
pwmDutySum -= tenPercPwm;
percCheck -= 10;
}
else if (rxDat == 'h')
{
vtohz2_writeHelp();
}
pwmDuty = pwmDutySum;
vtohz2_setSpeed( pwmDuty );
mikrobus_logWrite( "PWM Duty is : ", _LOG_TEXT );
WordToStr( percCheck, text );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( " %", _LOG_LINE );
}
}
Additional functions :
void vtohz2_writeHelp()
- Writes instructions that perform the determined commands.void vtohz2_setSpeed( uint16_t pwm_duty )
- Determines the desired pwm duty cycle and checks the limit of the pwm duty.void vtohz2_pwmInit( uint32_t pwm_freq )
- Initializes the PWM with the desired frequency and calculates the maximal value of the pwm duty cycle.
Other mikroE Libraries used in the example:
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.