Go Down

Topic: Reccomendation: Troubleshootig techinque (Read 518 times) previous topic - next topic

Watcher

Hi all,

My project based on Arduino micro, receives hex commands from an RS485 link through the hardware serial port Serial1 and then sends hex strings to a software serial port talking to an external RS232 device.

No feedback from the external RS232 device is needed.

Both received and sent strings are also echoed on the (USB) Serial port for monitoring.

Although it generally works fine, it occasionally seems to be stuck somewhere and spends a considerable amount of time (1-2s) apparently doing nothing or maybe waiting for something. This results in what appears to be intermittent operation.

I know of course I am supposed to post the actual code, but that would be too big and I frankly couldn't see anybody actually trying to go through it easily.

My question is if there was a way to pinpoint where the program is stuck during these times by adding some code for troubleshooting.

Thanks for your help.

MorganS

If you've decided that you need help from the forum then a productive technique is to strip down your program to the smallest possible program which shows the error. Either you get to a small program you can post here or your mistake becomes obvious to you.
"The problem is in the code you didn't post."

ElusivePi

My project based on Arduino micro, receives hex commands from an RS485 link through the hardware serial port Serial1 and then sends hex strings to a software serial port talking to an external RS232 device.

Both received and sent strings are also echoed on the (USB) Serial port for monitoring.

Although it generally works fine, it occasionally seems to be stuck somewhere and spends a considerable amount of time (1-2s) apparently doing nothing or maybe waiting for something. This results in what appears to be intermittent operation.

...

My question is if there was a way to pinpoint where the program is stuck during these times by adding some code for troubleshooting.
Your uC receives, processes, and sends hex commands. Add 3 LEDs and have each light up at each different stages of the routine: turn the first LED on when it it's begun receiving, the next on when it begins processing, and the final LED on when it beings sending, and all off after it's finished sending.

If it stalls, then you'll know which stage of the routine to look at.
Oscilloscope: Rigol DS1054z 50MHz (100MHz)
Function Generator: Siglent SDG 2042X
DC Power Supply: HY3005F-3

Watcher

Quote
Your uC receives, processes, and sends hex commands. Add 3 LEDs and have each light up at each different stages of the routine: turn the first LED on when it it's begun receiving, the next on when it begins processing, and the final LED on when it beings sending, and all off after it's finished sending.

If it stalls, then you'll know which stage of the routine to look at.
Thanks for the tip!

I thought of inserting serial.println statements to have flags appearing on the serial terminal at various steps but I ended up with a screen full of flags which was useless. The led approach you propose might be far better!

Go Up