Hi everybody! When outputting a variable of type integer, exclamation marks are displayed in the COM port, what could be the matter?
wrong baud rate. verify rate and format at both ends.
There are a few potential reasons why exclamation marks might be displayed when outputting an integer variable to the COM port:
- The variable might not actually be an integer. Make sure that the variable is of type "int" and not some other type, such as "char" or "float".
- The variable might contain an invalid value. If the variable contains a value that is outside the range of valid integer values (-32768 to 32767 for a 16-bit integer), it could cause strange characters to be displayed.
- The output might be interpreted as ASCII characters. When an integer value is output to the COM port, it is typically interpreted as an ASCII character. If the integer value corresponds to an exclamation mark (ASCII value 33), it will be displayed as such.
- There might be an issue with the serial connection or the serial monitor software. Make sure that the baud rate, data bits, stop bits, and parity settings are correct and match those of the Arduino board.
To troubleshoot the issue further, you could try printing the value of the integer variable in hexadecimal format using the "Serial.println(intValue, HEX)" function. This will allow you to see the actual value of the variable, rather than its ASCII representation. You could also try using a different serial monitor program to see if the issue persists.
The speed matches. If suddenly the speed does not match, then nothing is displayed. The cursor moves constantly to the right.
Looks like the serial monitor can't see your code ... neither can we
Thank you! I managed to remove the exclamation marks. I need a nice sequence of 0s and 1s. And I have some other information garbage, what could be the reason?
If you are still seeing other information garbage even after removing the exclamation marks, it may be due to a few different issues:
- Make sure that you are sending the command in the correct format as specified in the Megatec protocol. The command should be a sequence of binary digits (0s and 1s) that corresponds to the hexadecimal representation of the command as specified in the documentation.
- Check if the variable that you are using to store the command is of appropriate size, if the variable is too small it could be causing truncation and the wrong command is being sent
- Check if there is any extra character, white spaces or new lines concatenated to the command, that could cause unwanted noise on the output.
- Make sure the serial connection settings such as baud rate and data format match between the Arduino and the UPS.
- Another possible reason could be that the UPS is expecting a checksum or a specific end of line character to be appended to the command, check with the documentation if that is the case.
- Double check that the physical connection is correct and stable, for example, make sure that the cable is well plugged and not damaged.
Try to isolate the issue by sending only the command, without any extra characters and check the response from the UPS. If you are still facing difficulties, you may want to use a software to monitor the serial communication between the Arduino and the UPS, this can help you to see the exact commands and responses that are being sent and received, which can be helpful in troubleshooting the issue.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.