The registers are just a bit different in this example but if you read through it things should become clearer. If not we will see you later
http://rentron.com/PICX2.htm
The registers are just a bit different in this example but if you read through it things should become clearer. If not we will see you later
http://rentron.com/PICX2.htm
Dave
Always wear safety glasses while programming.
ok, tells me how to do it, which i did already work out but doesn't answer my question...
What is the acquisition time and why do we have to wait?
And also, it says if required, so how do you know if it is required?
i've just spotted this bit...
Figure 21-5 shows the operation of the A/D converter
after the GO/DONE bit has been set, the
ACQT2:ACQT0 bits are set to ‘010’ and selecting a
4 TAD acquisition time before the conversion starts.
Which indicates that the program doesn't need to execute a wait before 'hitting go'...
And later it tells you this
Look at Figure 21-1, all of the ANX's go to the same converter. Needs a little time between reads...After the A/D conversion is completed or aborted, a
2 TAD wait is required before the next acquisition can be
started. After this wait, acquisition on the selected
channel is automatically started.
Dave
Always wear safety glasses while programming.
I must be awake now because it's starting to make sense...
I hadn't spotted the bit that allows manual acquisition... but in normal mode will do the acquisition automatically before the conversion.
And that's what was confusing me...
[shakes head] seems obvious now...
Thanks for the help
Try to do this. I have been used this for a while, and it works fine for my purposes.
Loop:
gosub LeeEntradaAnalogica ' calls to subroutine LeeEntradaAnalogica".
goto Lazo
end
LeeEntradaAnalogica:
Auxiliar = 0
For J1 = 0 To 9
ADCIN H2, Auxiliar ' Guarda el valor del canal analógico en la variable "Auxiliar"
AnlgInput[H2] = AnlgInput[H2] + Auxiliar
for J2 = 0 to 50
pause 1
next J2
Next J1
AnlgInput[H2] = (AnlgInput[H2] /10) ' Divide el valor de Canal[H2] entre 10 para obtener un promedio.
If AnlgInput[H2] < 0 Then ' Si el valor obtenido es menor que 0.
AnlgInput[H2] = 0 ' significa que el valor leido en el canal no es real.
EndIf
If AnlgInput[H2] > 1023 Then ' Si el valor obtenido es mayor que 1023.
AnlgInput[H2] = 1023 ' significa que el valor leido en el canal no es real.
EndIf
Return
I think the comments don't matter. sorry but I think in spanish.
By the way, this piece of code is embedded in a program that uses DT interrupts. Darrel Taylor Rules!
Bookmarks