unstable ADCIN readings when using DT ELAPSED.PBP


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1

    Default unstable ADCIN readings when using DT ELAPSED.PBP

    Hi,

    when we measure a voltage divider and have activated the timer for ELAPSED.PBP from Darrel Taylor, every 40th measurement or so is way off. When we never call start_timer from that file our readings are as stable as we expect.

    If we call stop_timer before the ADCIN command and start_timer afterwards our measurements are still off. I also tried to disable the timer0 interrupts via PIE1.0 = 0.

    Admittingly our version of ELAPSED.PBP is from 12/16/2003 but the examples from Darrels site show no big differences when using (assembler?) interrupts for measuring elapsed time periods.

    Is there anything to have in mind when mixing ADC and interrupts?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    What chip are you using?

    Which wsave? variables do you have uncommented?

    What version of PBP are you using?

    Have you modified the files?

    Have you changed any Interrupt registers?

    Can you post your code?
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel, thanks for your fast reply. Thanks for your libs!

    See the attached ZIP for the code

    The PIC is a 18F2423 Device ID Revision = 00000007
    Attached Images Attached Images  
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Peter,

    You are using an 18F with the Elapsed Timer for 14-bit cores.

    You should be using the one in post #18 of the original thread ...

    http://www.picbasic.co.uk/forum/show...5575#post15575
    <br>
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    my fears came truth. I've inherited the codebase and suspected that those parts need updates as I visited your page and saw that updates were released after 2003 BTW: The ELAPSED-18.bas still list 12/16/2003 as date.

    But I lucked out as your promise from the thread holds true: Your *-18.bas files are drop-in replacements for the old versions. No line modified, just the extension changed to .pbp as .bas is reserved for the Visual Basic code.

    The code is reduced to the clock output shown below, the clock counting is working without errors, but the display has artefacts, as about every 10 seconds the display has wrong information in the places of the clock, never where the separators are appearing.

    I need a hint:
    Do we have to protect instructions like ARRAYWRITE or is it rather the SPI were the interrupts are interfering?

    actually: scratch that, it must be the ARRAYWRITE as else the separators would be influenced too. time to read assembler. Stuff that I avoided since 1990.

    if the PAUSE before the last GOTO is removed, the problem isn't visible bt I think the updates are simply happening more often and the problem is still appearing.

    Code:
    'Code is licensed as http://creativecommons.org/licenses/by-sa/3.0/de/
    '(c) 2010 Ing Buero A. Czech
    
    DEFINE DEBUG_MODE 1    'Auf 1 setzen, wenn keine Debuggen notwendig
    DEFINE DEBUGIN_MODE 1
    
    INCLUDE "BS1DEFS.bas"
    INCLUDE "EBS18F2423.pbp"
    INCLUDE "EBSMasterKonf.pbp"
    INCLUDE "EBSMasterVar.pbp"
    INCLUDE "Elapsed-18.pbp"
    INCLUDE "LCDAusgabe.pbp"
    
    '===============================================================================
    'VP: LCD Initialisierung
    '===============================================================================
    GOSUB EBSLCDINIT
    LCDTextAnz = 16
    
    GOSUB ResetTime
    GOSUB StartTimer
    
    '===============================================================================
    ' Hauptprogramm
    '===============================================================================
    HauptSchleife:
        GOSUB EBSLCDZeile1
        ARRAYWRITE LCDText,[DEC2 days, "+", DEC2 Hours, ":", DEC2 Minutes, ":", DEC2 seconds, REP 32\11]
        GOSUB EBSLCDTEXTOUT
        'DEBUG
        PAUSE 500
        GOTO HauptSchleife

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by peter_wiersig View Post
    actually: scratch that, it must be the ARRAYWRITE as else the separators would be influenced too. time to read assembler. Stuff that I avoided since 1990.
    I chickened out, if I use this construct:
    Code:
        T1CON.0 = 0                   ; Turn OFF Timer1
        ARRAYWRITE LCDText,[DEC2 days, "+", DEC2 Hours, ":", DEC2 Minutes, ":", DEC2 seconds, REP 32\11]
        T1CON.0 = 1                   ; Turn OFF Timer1
    the clock is working without problems and the ADC readings are stable. It was the output and not the measurement that had the problem.

Similar Threads

  1. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21

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