data storage prior to use, whats the best way here?


Results 1 to 7 of 7

Threaded View

  1. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Here I have a code for you written in quick thinking.
    It should work out, if not, should give you some ideas.
    As Steve mentioned, there are actually two different arrays in this code but one is hidden in for loop.


    Code:
    '...Do the port registers, ADC settings etc. here...
    
    A VAR BYTE 'A loop variable.                                                     
    Z var byte 'Dynamic end point for loop.
    Flag  var byte     'The array address where we hit the out of limit.
    Dumpy VAR WORD     'A dummy variable.
    X con 13   'Lower limit
    Y con 25   'Upper Limit
    
    ADCData VAR WORD[31]
    Serpin VAR PORTC.0
    
    
    Start:
        Flag = 100           'Default value.
        Z = 20               'Normally, initial reading is 20 times.
    
    
        FOR A = 1 TO Z     'Take Z times readings.
            ADCIN 0,adcdata[A]
            IF ADCDATA[A] < X OR ADCDATA[A] > Y AND Flag = 100 THEN
               Z = 30    
               Flag = A  'Store the array variable where we hit the reading out of the limit.
            ENDIF                                       '[ why Z = 30 ? : IF we have a reading out of the limits, 
            PAUSE 1000    'Wait for 1 second.            '...we then add 10 more locations to our array 
        NEXT A                                               '...so that we can add extra 10 readings after the event.]
    
        'Now, readings are complete. 
        
        IF Z = 30 THEN     'if Z = 30 that means we had an "out of limit" reading.
            FOR A = (Flag-10) TO (Flag+10)    'Flag is the point where we hit the first out of limit reading.
              'Serout your values here.
              'You need to send your values starting from -10 AND +10 of array location using Flag value.
              Dumpy = ADCData[A]
              SEROUT Serpin,4,[Dumpy.LowByte,Dumpy.HighByte]
            NEXT A
        ENDIF
    
    
    GOTO Start
    Last edited by sayzer; - 3rd February 2007 at 20:00. Reason: for some reason, the code does not appear to be what I posted.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 03:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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