-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing decimal values #158
Comments
Hard to say what are you trying to do without example code |
Hello Jan, static scpi_result_t DAC_MeasureVoltage(scpi_t * context) {
uint32_t param1; // Channel number
double output1 ;
if (!SCPI_ParamUInt32(context, ¶m1, TRUE)) {
return SCPI_RES_ERR;
}
if (param1 <= 0 ) {
return SCPI_ERROR_ILLEGAL_PARAMETER_VALUE;
} else if (param1 > 2) {
return SCPI_ERROR_ILLEGAL_PARAMETER_VALUE;
} else {
if (param1 == 1) { // Channel number
//Channel 1 : PA4
HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
output1 = HAL_DAC_GetValue(&hdac, DAC_CHANNEL_1);
} else {
//Do something else
}
}
//SCPI_ResultDouble(context, 3.3*output/4095);
SCPI_ResultDouble(context, output1);
return SCPI_RES_OK;
} it work for integer values from 0 to 4096 but the instruction Thank you |
@hakimoune , have you tried to put 3.3*output/4095 in a variable of type double, and see what its value is? suggestion to see what's wrong:
edit: your code has output in the calculation, instead of output1 |
I can't se anything wrong except the typo |
It didn't work even with double. scpi_result_t DAC_ConfigureVoltage(scpi_t * context) {
|
@hakimoune the
|
Hello,
I am having a problem sending decimal value like 2.8 to an STM32 DAC, it worked for me only with integer values. for a DAC in 12 bits mode for example, accepted values are only from 0 to 4096. maybe i made a mistake in conversion.
Thank you
The text was updated successfully, but these errors were encountered: