Record, storage and compare analog signals


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    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

  2. #2
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    Use example 1 as example 2 will only display array[4] or you could do something like this

    adc_runtime:
    Lcdout $fe, 1 ' Clear LCD
    for counter = Start_array to Stop_array
    ADCIN 0, array[counter] ' Read channel 0 to array[counter]
    Lcdout DEC array[counter]," "
    next counter
    Pause 100 ' Wait .1 second

    Try it a see what happens

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    You try to display only one array element and especially the array[4] element that does not exist. You have defined from 0 to 3 (4 elements) and the variable counter after the end of the For-Next loop ends up with the value of 4.

    So you try to display an non-existence variable, that could have a random value.

    Steve has given you an example to display the variable within the loop and should work as you expect.

    Ioannis

  4. #4
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    Hi loannis,
    I tried your metod, it does not work.
    Method of EarlyBird2 really works, Im surprise.

    Thanks
    Kuba

  5. #5
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    Working, great

    Thanks EarlyBird2

    Kuba
    Last edited by Kuba230; - 9th May 2014 at 10:47.

  6. #6
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    Kuba,

    You are welcome.

    Steve

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    What method? I explained what Steve has given you as an example.

    Ioannis

  8. #8
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    Hi loannis,
    now I understand you explanation.
    Exist other method, how to send all array elements to LCD, after the completion loop, except my 1. Example?


    Thanks
    Kuba

    Sorry for my english

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: Record, storage and compare analog signals

    With arrays the STR modifier is used to send without FOR-NEXT loop.

    But in your case you need a second modifier and up to this moment this is not supported.

    This does work: STR my_array\16 ' sends the first 16 bytes of the array my_array

    This does not work: STR DEC my_array\16

    But I wish sometime in the next update/upgrade it will be supported!

    Ioannis
    Last edited by Ioannis; - 9th May 2014 at 13:24.

Similar Threads

  1. how to record sound into eeprom
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th November 2009, 21:16
  2. How to read analog signals?
    By thm ov3rkill in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 8th March 2009, 05:00
  3. Using a PIC to record voice
    By weirdjim in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th December 2007, 20:21
  4. Replies: 6
    Last Post: - 20th August 2006, 22:00
  5. The best way to record non-volatile data
    By johnson in forum General
    Replies: 3
    Last Post: - 19th July 2004, 09:03

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts