Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20642

BASCOM-AVR : ADC Measurement : REPLY

$
0
0
Hallo, OK I'll try and help you a bit:- [code:1:66a0598c6d]Check_adc: For Gp1 = 2 To 5 'Loop through Gp1 (2-5) This is the ADC number we'll read later W_single = 0 'Setup an accumulator For Gp2 = 1 To 200 'Read the ADC 200 times in this loop W = Getadc(gp1) 'Actually read the ADC Value W_single = W_single + W 'Add to the accumulator Next Gp2 ' If W_single <> 0 Then 'If the total of all ADC values read for this ADC is > 0 then W_single = W_single / 200 'Divide by 200 (The number of times we read the ADC). This will give us an average Else W_single = 0 End If Select Case Gp1 'Where should the average value for the ADC just read be stored? Case 2 : Sol_v = W_single 'Save value from ADC 2 to Sol_v Case 3 : B_high = W_single 'Save value from ADC 3 to B_High Case 4 : B_low = W_single 'Save value from ADC 4 to B_low Case 5 : Bat_v = W_single 'Save value from ADC 5 to Bat_v Case Else End Select Next Gp1 Return [/code:1:66a0598c6d] Not the most beautiful code I've seen, but if it works why not. Regards Ian Dobson

Viewing all articles
Browse latest Browse all 20642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>