Is there a wise way to debug a large code?


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    I think, maybe this is RMW issue somehow?
    not at all likely , which pin is having its expected digitally "read back" value changed by a digital write to another pin on the the same port ?

    as ioannis suggests this is looks very much an EMI problem that could most likely could be ameliorated by having the switch circuitry of more suitable impedance and using appropriate adc conversion speed along with sample hold time and rate.


    with no schematic or code to look at it might just be bad code who would know
    Warning I'm not a teacher

  2. #2
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    Ok, here is the part of code which reads the keys:
    Code:
    adcin 7,ard
    if ard<130 then 'if any button is pressed
    ticker=ticker+1 'increase value and wait - debouncing
    pause 1
    endif
    if ticker>150 and ard<100 then  'if left button is pressed then next menu item
    menuitem=menuitem+1
    ticker=0 'reset debouncer
    endif
    if ticker>150 and ard<130 AND ARD>100 then  'if right button pressed, change the value
    CVLADI=CVLADI+1
    if cvladi>ulim or cvladi<dlim then cvladi=dlim
    ticker=0
    here is PCB

    Name:  herepcb.jpg
Views: 946
Size:  579.6 KB

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    Ok, here is the part of code which reads the keys:
    pointless snippet . how is adc setup ?

    good luck trying to use adc value without passing it through a lpf

    a pic of blank pcb is not a schematic
    Warning I'm not a teacher

  4. #4
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    DEFINE ADC_BITS 8 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds

    Here is ADC setup. All PBP defaults.

    Unfortunately, I don't create schematics - I directly draw PCB, since I can read it in same way, as schematics

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    Unfortunately, I don't create schematics - I directly draw PCB, since I can read it in same way, as schematics
    that just explains so much
    good luck with your endeavors i'm out
    Warning I'm not a teacher

  6. #6
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    Well, added 0.1uf capacitor at ADC input, so far, works fine.

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


    Did you find this post helpful? Yes | No

    Default Re: Is there a wise way to debug a large code?

    This just shows that you have strong interference in the analog inputs because of EMI noise. Where it is coming from?

    Well, you can read the PCB as schematics, so as Richard said, good luck here!

    If you make a lot of ADC readings, say 20, and then sort them in order, through away the 5 first and last numbers, with the rest 10 make a mean number, then you may get rid off the 100nF capacitor and be more confident of the readings. This makes for a low pass filter in software.

    Personally, NEVER use raw adc readings. This is just looking for troubles. A spike can ruin your day. Make many readings and get the best of them to be sure of noise free readings.

    Ioannis

Similar Threads

  1. DEBUG DEC DatVar vs DEBUG #DatVar
    By netstranger.nz in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th March 2011, 21:26
  2. Replies: 0
    Last Post: - 18th November 2010, 18:50
  3. How does everyone debug their code?
    By HankMcSpank in forum General
    Replies: 30
    Last Post: - 18th June 2009, 06:41
  4. SERIN from a large string
    By earltyso in forum Serial
    Replies: 5
    Last Post: - 2nd May 2008, 22:23
  5. large displays
    By George in forum Off Topic
    Replies: 2
    Last Post: - 18th March 2007, 21:56

Members who have read this thread : 1

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