damoney27
One of my students just came across an issue.  When 2 PWM controllers are used, the live debug does not work. 
Messages saying "Debug: target couldn't trace all requested variables" keep popping up, and no values are coming from the analog input of the wind turbine or any other values showing.  When either PWM controller is deleted, everything works fine. 
 
The screenshots below show the issue.Screenshot 2024-04-17 184425.pngScreenshot 2024-04-17 184627.png
Reply 0 0
Write a reply...
thiagoralves
What hardware board are you using? It is likely that your application is running out of memory and the debugger can’t run. The popular 8-bit platforms (Arduino uno, mega, etc) have very small RAM and can run out of memory pretty quickly. 
Reply 0 0
damoney27
What hardware board are you using? It is likely that your application is running out of memory and the debugger can’t run. The popular 8-bit platforms (Arduino uno, mega, etc) have very small RAM and can run out of memory pretty quickly. 
We are using the Mega
Reply 0 0
damoney27
Sketch uses 20092 bytes (7%) of program storage space. Maximum is 253952 bytes.
Global variables use 2128 bytes (25%) of dynamic memory, leaving 6064 bytes for local variables. Maximum is 8192 bytes.
Reply 0 0
thiagoralves
Those statistics are for static allocation. The debugger uses dynamic allocation since it is impossible to know before hand how big the trace buffer will be for each request. Try something real quick for me please: create a blank project and add two PWM controllers to it. If the code is still locking up during debug, then most likely there is something in the PWM Controller code that is not right. If the debug goes just fine then most likely that’s really a memory issue. 
Reply 0 0
damoney27
Those statistics are for static allocation. The debugger uses dynamic allocation since it is impossible to know before hand how big the trace buffer will be for each request. Try something real quick for me please: create a blank project and add two PWM controllers to it. If the code is still locking up during debug, then most likely there is something in the PWM Controller code that is not right. If the debug goes just fine then most likely that’s really a memory issue. 
It did the same thing.  However before we left class, I saw another students program and he was using 2 PWM controllers and his ladder logic is significantly larger and more complex.  We looked over exactly how he did his, and it was the same way.   I will ask him to send me his code now. 
Reply 0 0
damoney27
Those statistics are for static allocation. The debugger uses dynamic allocation since it is impossible to know before hand how big the trace buffer will be for each request. Try something real quick for me please: create a blank project and add two PWM controllers to it. If the code is still locking up during debug, then most likely there is something in the PWM Controller code that is not right. If the debug goes just fine then most likely that’s really a memory issue. 
So I got the code from the other student. The live debug runs completely fine.  I copied the two PWM blocks and variables and put them in a new program....and the live debug just sticks.  Below shows his massive code, and then the short code.Screenshot 2024-04-17 222447.pngScreenshot 2024-04-17 223714.png
Reply 0 0
thiagoralves
Good! Thanks for the feedback. So it appears indeed that the problem is with using two PWM Controllers. I’ll have to check the code to figure out what’s happening. But that’s definitely better than reducing the footprint of the debugger.
 
Without connecting the debugger do the PWM Controllers work? Or is the board frozen?
Reply 0 0
damoney27
Good! Thanks for the feedback. So it appears indeed that the problem is with using two PWM Controllers. I’ll have to check the code to figure out what’s happening. But that’s definitely better than reducing the footprint of the debugger.
 
Without connecting the debugger do the PWM Controllers work? Or is the board frozen?
So some errors do come up with using one PWM Controller as shown below in the console. The Live debug does work and the servos move.
When adding an extra PWM Controller, the live debug freezes, however the servos still operate as intended on button press. 
Screenshot 2024-04-18 101335.png Screenshot 2024-04-18 102049.png
Reply 0 0
thiagoralves
Are you guys running on the latest version of the editor? I feel like these error messages are from previous versions. This probably won't fix the problem, but will give more clarity to what's happening
Reply 0 0
damoney27
Are you guys running on the latest version of the editor? I feel like these error messages are from previous versions. This probably won't fix the problem, but will give more clarity to what's happening
We definitely are using the latest version. 
Reply 0 0
thiagoralves
Could I have a copy of those projects please? This will help me debug the issue
Reply 0 0
damoney27
Could I have a copy of those projects please? This will help me debug the issue
No problem
Reply 0 0
thiagoralves
 
This was a nasty bug to find I must say. First, after debugging the serial responses from the tracer I found the following strings:
 
[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00
[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00
[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00
[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00
[PWM] AVR_PWM:Too low frequency = 50.00 , min =  244.14
[PWM] AVR_PWM:Too low frequency = 50.00 , min =  62500.00
[PWM] Error, not usable for PWM, pin =255
The AVR_PWM library used on the PWM_CONTROLLER block was spitting out random messages on serial disrupting the correct behavior of the serial debugger. A simple 
#define _PWM_LOGLEVEL_       0
was enough to silence that crap. After that, things started to clear up a bit, but I was still finding issues on packets. Then after some more debugging I found out that for whatever reason the CRC on trace messages was being calculated incorrectly. Since those messages are like UDP packets (if you receive them, good, if not, you'll get another one shortly) I found it would be better to just disable CRC for the tracer. With those changes in, everything now runs smoothly.
 
Ah, as a plus, I changed the way the tracer is doing dynamic allocation for the buffer. There is a chance you will be able to use even small Unos now, if you want to try.
 
Screenshot 2024-04-18 at 3.22.50 PM.png
Reply 1 0
damoney27
 
This was a nasty bug to find I must say. First, after debugging the serial responses from the tracer I found the following string: "[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00\r\n[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00\r\n[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00\r\n[PWM] AVR_PWM:Too low frequency = 490.00 , min = 62500.00". The AVR_PWM library used on the PWM_CONTROLLER block was spitting out random messages on serial disrupting the correct behavior of the serial debugger. A simple 
  1. #define _PWM_LOGLEVEL_       0
was enough to silence that crap. After that, things started to clear up a bit, but I was still finding issues on packets. Then after some more debugging I found out that for whatever reason the CRC on trace messages was being calculated incorrectly. Since those messages are like UDP packets (if you receive them, good, if not, you'll get another one shortly) I found it would be better to just disable CRC for the tracer. With those changes in, everything now runs smoothly.
 
Ah, as a plus, I changed the way the tracer is doing dynamic allocation for the buffer. There is a chance you will be able to use even small Unos now, if you want to try.
 
Screenshot 2024-04-18 at 3.22.50 PM.png
That is some great news! Thanks so much.  Will be sure to let you know of any other strange stuff happening with the guys lol.
Reply 0 0
Write a reply...
Reply