I'm building a system to monitor a few powerlines it works well but some times the conversion results into a 0; i took the data sheet of the pic i use (16f88) read the whole chapter about it over and over and i finished up changing my code(snippets; of course the enable bit and so are set) from this:
to this:Code:'GO/DONE: A/D Conversion Status bit 'If ADON = 1: '1 = A/D conversion in progress (setting this bit starts the A/D conversion) '0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D 'conversion is complete) symbol AD_Progress = ADCON0.2 ADCON0.5 = 0 ADCON0.4 = 0 ADCON0.3 = 0 AD_Progress = 1 while AD_Progress = 1: wend Sound_Level.lowbyte = ADRESL Sound_Level.highbyte = ADRESH
as I understood of the manual: if I change the input port from the a/d converter I need to wait a minimum of time before recalling a new a/d conversion. So far so good but what happens is it stucks @ "while AD_Progress = 1: wend" because it simply does not clear any more the code above without the pause 50 does work! so if I remove that line "pause 50" the code runs but some times I get a 0 in the result of the a/d conversion :S I don;t get it do you?Code:'GO/DONE: A/D Conversion Status bit 'If ADON = 1: '1 = A/D conversion in progress (setting this bit starts the A/D conversion) '0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D 'conversion is complete) symbol AD_Progress = ADCON0.2 ADCON0.5 = 0 ADCON0.4 = 0 ADCON0.3 = 0 pause 50 AD_Progress = 1 while AD_Progress = 1: wend Sound_Level.lowbyte = ADRESL Sound_Level.highbyte = ADRESH




Bookmarks