Is there a wise way to debug a large code?


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    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

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    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

  3. #3
    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.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    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

  5. #5
    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?

    As mentioned above, that noise comes from PWM, PWM is used to adjust brightness of the nixie tubes
    The HPWM output from the chip is used to modulate bases of all MPSA42 transistors, emitters of which, individually, go into ports of MCU, and collectors are tied to nixie tube cathodes.
    That PCB is quite large - about 88x44mm, now I've designed even more compact one, just 70x30mm. Good I haven't put it into production yet - will add capacitor place to PCB.

    Actually, reading schematics via PCB is not that hard - just you need to learn it, as you do with normal schematics.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

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

    I would try first the software filtering as I described to you.

    Last resort to capacitors. If something changes, then you would remove old caps and put new, larger or smaller???

    Ioannis

  7. #7
    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?

    Yeah maybe
    My software skills are quite limited as you can see from my posts
    And by the way, there was another issue which I've fixed now, and quite likely it was also causing the problems
    Due to coding error, I had that brightness adjusting PWM routine called 500 times per second (it was placed in middle dot blink loop)
    and when you use HPWM statement, instead of changing the current PWM register, Picbasic stops the pwm generator and restarts it with new values (you can check this with oscilloscope) which causes additional noise generation. Now I moved it into segment refresh routine, which happens once per minute (and keyboard input is deactivated during it), so most likely, it should work without capacitor now, but too lazy to take it apart and unsolder

    Name:  clcock.jpg
Views: 932
Size:  378.4 KB

  8. #8
    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 if you look at my code, you can see that I here have an special delay loop, which counts how long same value from ADC is being read, but as it turns out, that was not enough.
    Oh, and as a note, before soldering capacitor, I tried to add ferrite beads onto wires going to buttons - that helped a bit, previously, if issues were at PWM value of 170, after ferrite beads, only values below 80 were causing issues.
    So as I can estimate, the issues from wires acting as antennas. This means, for next revisions, I should add spread spectrum modulation, to reduce EMI sent into air, and maybe, even use shielding.

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