1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

"Continuous" debugging

Discussion in 'Microcontrollers' started by chris414, Jan 26, 2010.

  1. chris414

    chris414 New Member

    Joined:
    Apr 29, 2009
    Messages:
    132
    Likes:
    1
    I'm trying to calibrate two inputs (a tilt sensor and and the integration of the output of a gyroscope) as the tilt sensor does not provide a linear output. If I run my microprocessor in debug mode I can see what value each input is, however this requires me to reset the processor, click play, rotate the platform I'm measuring and press pause. Then either I have to hold the platform perfectly still while I somehow write those values down, or I have to go through the whole process of resetting everything and starting again for my next reading... the point is it's taking a ridiculous amount of time.

    Is there any way I can run my microprocessor so that I can watch certain variables as they update continuously, ie. so that I dont have to click stop / start every time? The only other way I can think of doing it is to write the value I want to read to a voltage on an analogue output pin... though I would think this would sacrifice some accuracy? What I really want at the end of all of this is a scatter plot of my tilt sensor vs the integration of my gyroscope.
     
    Last edited: Jan 26, 2010
  2. DirtyLude

    DirtyLude Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    1,904
    Likes:
    56
    Location:
    Toronto, Canada
    Usually a simple UART output to the PC is used for semi-real time debugging. Some IDE's even have terminal program's built in just for this purpose.
     
  3. Pavius

    Pavius New Member

    Joined:
    Jan 10, 2009
    Messages:
    104
    Likes:
    1
    1

    Indeed outputting to serial is most of the time the solution for this. Sometimes, though, you need much faster data capture - for such cases a simple circular/finite RAM buffer works well. Define an array of X values and then update this array with every N measurements. The greater X the more time you can capture and the smaller N, the higher the resolution. Once you want to see how the data behaves, simply break and watch the array. You can even copy it to clipboard and then manually shove it into an excel spreadsheet for plotting.
     
    Last edited: Jan 26, 2010
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. DirtyLude

    DirtyLude Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    1,904
    Likes:
    56
    Location:
    Toronto, Canada

    Good suggestion. I have also used this. Usually to capture a short data sequence and logging starts at a specific trigger point.
     
  6. chris414

    chris414 New Member

    Joined:
    Apr 29, 2009
    Messages:
    132
    Likes:
    1
    Thanks guys, will try it out
     
  7. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    I like to use a text LCD for "debugging" and often some LEDs. You can display whatever variables or system states as needed in real time on the LCD, or turn the LEDs on/off as code is executed to catch fast events.

    That's one of the reasons I like the EasyPIC development boards, there's always an LCD available and there is also a LED on every PIC pin so any unused pins can instantly become debugging lights.
     
  8. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    ONLINE
    Another way to do this, if you don't need a high storage rate, is to store values in the flash program memory. You could store a value 10 times a second and even if you only have 1k of spare memory you can store 10 seconds worth. Most of the newer chips would probably have 8k or so spare. Once full you just read it back using your programmer. And, it's in machine readable format.

    Mike.
     
    Last edited: Jan 27, 2010
  9. DirtyLude

    DirtyLude Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    1,904
    Likes:
    56
    Location:
    Toronto, Canada
    That's not another way; that's Pavius' suggestion of a buffer. ;)
     
  10. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    ONLINE
    No, Pavius suggested a RAM buffer. I suggested a FLASH buffer. There is a much larger area of flash available than RAM. On an 18F1320 (fitted on the Junebug) there are 256 bytes of ram and 8k of flash.

    Edit, I mentioned it because most people don't consider the flash memory as they consider it to be ROM.

    Mike.
     
    Last edited: Jan 28, 2010
  11. DirtyLude

    DirtyLude Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    1,904
    Likes:
    56
    Location:
    Toronto, Canada
    Ah. My mistake. Yes, that would be different.
     

Share This Page