7/2/2023 0 Comments Debug through spi arduino![]() Using a real debugger with Simple FOClibrary can be a challenge. Using this technique will not impact the execution time, and using your oscilloscope or logic analyser you can check the output pin and see things like how long calls are taking to execute, whether the code is taking certain branches, etc… IDE Debugger Spare pinsĪ great way to debug simple things is to use digitalWrite and an usused pin:ĭigitalWrite ( 5, HIGH ) // 5 is an unused pin //. You will have to write the code in such a way to minimize the bytes you output, and include some timing code to make sure you only output once or twice a second. ![]() The move and loopFOC functions need to called very often in your main loop and you can’t output to the Serial port all time. Yes and no… There is no problem with calling Serial.println() in your sketches, you are not forced to use our debug facility as described above.īut you have to care not to use too much time for Serial output. Other debugging methods Plain old Serial.printlnĬan I just use Serial output as per normal in my Simple FOClibrary sketch? For this reason it is also good to have a seperation between debug and Serial. In future we may abstract the debug output functionality one level further, allowing debug output via SPI, MQTT or other protocols. We also like the abstraction it provides, making it easier to port Simple FOClibrary to other platforms/frameworks. Some MCUs support 6 or more Serial ports. We also can’t make assumptions about which Serial object you would want to use. While it is a pretty standard feature of Arduino framework, a given board may not support it, or may for whatever reasons have a different name for it. When supporting many hardware platforms (as Simple FOClibrary does), we can’t make assumptions about the availability of the Serial object. ![]() Why have our own SimpleFOCDebug? Wny not just use Serial.println? ![]() Using the build flag SIMPLEFOC_DISABLE_DEBUG you can globally disable all debug output, potentially also saving a few bytes of program space if you are short on memory. The SimpleFOCDebug macro automatically uses FlashStringHelper, and you should not use the F() macro on strings supplied to the SIMPLEFOC_DEBUG macro. See the SimpleFOCDebug class header for all available methods. Using this macro has several advantages, see FlashStringHelper, global disable and rationale, below. SIMPLEFOC_DEBUG ( "Hello world!" ) SIMPLEFOC_DEBUG ( "Float value: ", fval ) SIMPLEFOC_DEBUG ( "Int value: ", ival ) ![]()
0 Comments
Leave a Reply. |