02-06-2025 01:33 PM - edited 02-06-2025 01:36 PM
I have a sensor tester that needs to send a global variable serial number to a pin stamp printer to etch on the part tested.
The format is very plain: SETVAR SER xxxx[LF].
If i use the serial monitor and type SETVAR SER 1111\n it changes the serial number to be printed to 1111.
I haven't had any luck incorporating a global variable in place of the xxxx.
My last attempt was SETVAR SER StrFmt(${SERIAL_NUMBER},4,0)\n that didn't work either.
Everything I have sent, other than the string with numbers, has resulted in the serial number showing 0000 on the pin stamp printer.
I wish the serial monitor would also show you the characters sent out the RS232 line as well.
Any ideas how to make this work?
DASYLab 16.0 Full
Windows 11 Pro
Solved! Go to Solution.
02-06-2025 03:06 PM
I'm unsure what generates the serial number, but if it's stored in a global variable (${VAR_1}), you can format a global string as follows:
"SETVAR SER" + strfmt(${VAR_1}, 4, 0)
This should produce "SETVAR SER1111"
Use the RS232 Output set for Single Commands. Set the format to [a]\n to send a line feed and use an Action module to send the global string.
02-14-2025 07:35 AM
I have worked with serial communications since the 80's.
As a newbie to DASYLab, the answer wasn't working at first, but I finally figured out I had to put the solution into the string calculation box instead of directly into the variable string.
I needed to see what data was going across the serial line, but didn't have the inline capture setup I had at previous jobs. Adding to the issue was having to use a USB to Serial converter.
I found a USBPcap interface for WireShark that allowed me to see what was going across the USB interface to the Serial Converter. Once I was able to see the data, it was pretty simple to troubleshoot.
I really appreciate the assistance!