Hello sir, I have connected the ADC and made the setup as explained. The output is displayed on a LCD. It displays the value. However the strange thing is ADC converts and shows the value only when reset button is pressed. The continues mode though enabled doesn't work. For each of value, I need to press the rest button. What could be the issue?
In the while loop, start and stop adc as shown below. Thanks HAL_ADC_Start(&hadc1); HAL_ADC_PollForConversion(&hadc1,1000); readValue = HAL_ADC_GetValue(&hadc1); HAL_ADC_Stop(&hadc1);
@@NizarMohideen I did that , after I posted the msg. It is working. There is another issue. For an input of 1.06v the displayed value changes from 0.79 to 1.05. Thank you very much.
@@NizarMohideen I found that changing the clock frequency of the adc1 & 2 to /8 =1 produce a higher reading very much near to my dmm. now the adc value show 1233 (should actually about 1292) . With higher frequency the adc value drops. to below 900.
See video-no-57 in my channel for I2C LCD And then combine with following code to display floating number (Voltage with decimal point) /* USER CODE BEGIN Includes */ #include "stdio.h" /* USER CODE END Includes */ /* USER CODE BEGIN PV */ uint8_t VI,VD; char strCopy[15]; /* USER CODE END PV */ /* USER CODE BEGIN WHILE */ while (1) { HAL_ADC_PollForConversion(&hadc1,1000); readValue = HAL_ADC_GetValue(&hadc1); voltage =(float)readValue/4095*16.5; VI = voltage; // voltage integral VD = voltage*10-VI*10; // voltage decimal sprintf(strCopy,"%d.%d C ", VI, VD); HD44780_SetCursor(0,0); HD44780_PrintStr(strCopy) HAL_Delay(100); /* USER CODE END WHILE */
@@NizarMohideen Instead of voltage sensor I have used voltage divider circuit for measuring the voltage with stm32f401re . to which pin we supposed to connect the 'S' point in stm32f401re
Any pwm capable pins can be used. Common pins are labled A0,A1,A2,A3,A4 AND A5. I have done a video with potentiometer with F446RE. It will be very similar to F401RE. See video-no-69 in my channel. Connect middle of voltage divider as like the potentiometer middle pin See video-no-61 in my channel for I2C LCD
Hi Sir, could you please explain how we can measure AC voltage. I am trying to use 3 channels to measure 3 phase voltages and I am still confused after seeing this video. Your help would be much appreciated! Thankyou!
You need to use step down transformer to measure AC voltage. A common one is ZMPT101B. If the AC voltage is in the form of pure sine wave, you can simply get the maximum zero offset ADC value and multiply by 0.707 for RMS.
You need ZMPT101B module or similar. I don’t have ZMPT101B with me at the moment to demonstrate. Please take all safety precautions whenever working with ac voltages.