Jump to content
Electronics-Lab.com Community

Leaderboard

Popular Content

Showing content with the highest reputation since 08/25/2021 in all areas

  1. Introduction Arduino IDE is a convenient tool to write your code and upload to microcontrollers. However, it doesn’t come with debugger function, which means the only way to debug our program is through using debug message through standard output, in this case, Serial Monitor. Debug message is handy and it helps to print out the information the registers holds at a specific time, but once you have done debugging and your program is ready to go, we often have to delete/comment out those debug message code manually, in a big project, this could be problematic as there are just too manny of them. Today, I am going to show you an easy method to turn on / off debug message with only a few lines of code. Method Take a look of the following C code, //#define __DEBUG__ #ifdef __DEBUG__ #define DEBUG(...) printf(__VA_ARGS__) #else #define DEBUG(...) #endif Since all Ameba microcontroller supports printf(), we can re-define printf() to a preprocessor function, in this case, I name it DEBUG(). Whenever you want to print out the debug message, instead of Serial.print() or printf(), you should try using DEBUG() instead, it works just like the previous two, but can be easily enabled or disabled by uncomment //#define __DEBUG__ or just leave the comment syntax there. Let’s look at an example Example code 1 This is a simple code that only print out “Debug msg 1” and “Debug msg 2” alternatively with a 1 second delay in between. Screenshot 2021-01-22 1639441919×1079 173 KB Note that the first line of the code is uncommented, and we are seeing the debug messages actually got printed out using the DEBUG() function. Example code 2 Screenshot 2021-01-22 1641171920×1077 127 KB Note that this is the same code except I keep the first line commented out, and as a result, no debug messages got print out at all. It works! Conclusion All you need to do is to copy the few lines of code from above into the top of your arduino sketch and you may name your custom debug function anything you like and it will work like a charm. Turn on / off is just to keep / remove the // at the first line, very convenient. Hope you like this content, stay healthy and happy coding~
    1 point
  2. This site gives the MPXV7002DPT1 as an alternative to the MPXV7002DP see: https://www.apogeeweb.net/circuitry/mpxv7002dp-transducer-datasheet-features-pinout.html#product-overview This one has a list of exact alternatives also: https://www.newark.com/nxp/mpxv7002dpt1/pressure-sensor-2-to-2kpa-sop/dp/28X3717
    1 point
  3. But even if we disable debug, it will call print method and do not print anything. I mean we should make it something like #ifdef DEBUG Serial.print("\n debug controlled print"); #endif Here when we disable macro, its like code is not written for compiler, code will be removed in macro processing itself.
    1 point
  4. repairman2be

    0-30V 0-3A Latest Data

    Hi all, Finally after some months have gone by, my build of the Power Supply is done. I have used liquibyte schematic Rev. 8 and had made the cirquit board according to the Gerber.zip file he posted here: 0-30V Stabilized Power Supply Page 88 posted October 6, 2014 "http://electronics-lab.com/community/index.php?/topic/29563-0-30v-stabilized-power-supply/&page=88" I left out D10 and R15 as per his description. I have plenty of boards leftover if someone has a need for it. There was only one mistake liquibyte made which have outlined in one of the pictures uploaded here. I was fortunate enough to get a big case with a Toroidal transformer from the scrapyard. Also many parts are recycled from various sources. Regards, William
    1 point
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.