Hi,
I have code for 10 Bit AD converter with array storage four samples.
If I send results from array separately, I see all numbers of array results on LCD, (Example 1.)
But If I send all results from array together, LCD show number 0. (Example 2.)
My question is, what is wrong, how correct this code, how can I send all results from array to LCD?
Thanks
Kuba
Example 1.
Lcdout DEC array[0]," ", Dec array[1]," ", Dec array[2]," ", Dec array[3]
Example 2.
Lcdout DEC array[counter]
This is my code:
Define LCD_DREG PORTB
Define LCD_DBIT 4
Define LCD_RSREG PORTC
Define LCD_RSBIT 4
Define LCD_EREG PORTC
Define LCD_EBIT 5
' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 3 ' Set sampling time in uS
TRISA = %11111111 ' Set PORTA to all input
TRISB = %00000000 ' Set PORTB to all output
TRISC = %00000000 ' Set PORTC to all output
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Pause 500 ' Wait .5 second
array Var Word [4]
counter VAR Byte
Start_array VAR Byte
Stop_array VAR Byte
Start_array =0 : Stop_array = 3
adc_runtime:
for counter = Start_array to Stop_array
ADCIN 0, array[counter] ' Read channel 0 to array[counter]
next counter
Pause 100 ' Wait .1 second
Lcdout $fe, 1 ' Clear LCD
Lcdout DEC array[counter]
Pause 100 ' Wait .1 second
Goto adc_runtime ' Do it forever
End
Bookmarks