Purpose
Use a Crimson program on a Red Lion G07 to request a measurement from an Agilent 34461A voltmeter through its LAN interface. The sample uses Crimson logical port 4 with a raw TCP/IP driver, sends CR and LF after each command, reads the returned text, converts the text to a floating-point value, and exits the program.
When to Use
- Use this sample when the G07 communicates with the 34461A through a Crimson raw TCP/IP port.
- Use this sample when that raw connection is Crimson logical port 4.
- Use this sample when the returned measurement must be retained as text and converted to a floating-point tag value.
Requirements
Hardware
- Red Lion G07.
- Agilent 34461A voltmeter with LAN connectivity.
- Ethernet connection between the devices.
Software
- Crimson 3.2.
- A raw TCP/IP driver assigned to Crimson logical port 4.
- String tag
Voltmeter.RawVolts. - Floating-point tag
CV.CV_ForPartA.
Configuration note: The supplied information does not specify the 34461A IP address, TCP service or port number, measurement setup, or the Crimson program/event that executes the code. Configure and verify these application-specific items for the installed system.
How It Works
-
PortPrint(4, "CLS")sends theCLScommand through logical port 4. -
PortWrite(4,13)sends CR (carriage return), andPortWrite(4,10)sends LF (line feed), through logical port 4. - The program waits 200 ms.
-
PortPrint(4, "INIT")sends theINITcommand, followed by CR and LF. - The program waits 800 ms.
-
PortPrint(4, "FETC?")sends theFETC?query, followed by CR and LF. -
PortInput(4, 0, 10, 100, 20)reads the response from logical port 4. Reception begins immediately becausestartis zero. The end character is 10, the inter-character timeout is 100 ms, and the maximum length is 20 characters. - The returned string is stored in
Voltmeter.RawVolts. -
TextToFloat(Voltmeter.RawVolts)converts the returned text and assigns the result toCV.CV_ForPartA. -
return;exits the program at that point.
Crimson documents PortPrint(), PortWrite(), and PortInput() for raw port drivers, including raw TCP/IP drivers. PortInput() returns the received characters without the start or end byte. If it times out while either end or length is nonzero, it returns an empty string.
Applying the Code in Crimson
- Configure the communications connection used by the application with a raw TCP/IP driver and verify that its Crimson logical port number is 4. Crimson documents that the logical port number is displayed in the status bar when the port is selected in the Communications category.
- Create or verify the
Voltmeter.RawVoltsstring tag andCV.CV_ForPartAfloating-point tag. - Add the code to the application-specific Crimson program or action used to acquire the meter value.
- The supplied information does not identify the exact program name, trigger, execution interval, or event. These items must match the application design.
Validation
- Verify that the configured raw TCP/IP connection can communicate with the meter.
- Execute the program under the intended measurement configuration.
- Confirm that
Voltmeter.RawVoltscontains the expected returned text. - Confirm that
CV.CV_ForPartAcontains the corresponding converted value. - Compare the stored result with the value displayed by the meter or another approved reference.
No measured validation results were supplied.
Troubleshooting
- If
Voltmeter.RawVoltsis empty, verify the TCP connection, response termination, response timing, and expected response length. Crimson documents thatPortInput()returns an empty string after a timeout when the end or length parameter is nonzero. - If the response is truncated, verify that a maximum length of 20 characters is sufficient for the expected response.
- If readings are intermittent, verify that the 200 ms and 800 ms delays are appropriate for the configured instrument measurement. These delays are preserved from the supplied code; the supplied Crimson references do not specify 34461A measurement timing.
- If no data is received, verify that the raw driver is assigned to logical port 4 and verify the application-specific network settings.
Code Snippet
PortPrint(4, "*CLS"); PortWrite(4,13);//CR(CarriageReturn) PortWrite(4,10);//LF(LineFeed) Sleep(200); PortPrint(4, "INIT"); PortWrite(4,13);//CR(CarriageReturn) PortWrite(4,10);//LF(LineFeed) Sleep(800); PortPrint(4, "FETC?"); PortWrite(4,13);//CR(CarriageReturn) PortWrite(4,10);//LF(LineFeed) Voltmeter.RawVolts := PortInput(4, 0, 10, 100, 20); CV.CV_ForPartA = TextToFloat(Voltmeter.RawVolts); return;
References
- HMS Networks / Red Lion, Crimson 3.2 Reference Guide, Revision D: raw-port functions including
PortInput,PortPrint, andPortWrite. - HMS Networks / Red Lion, Crimson 3.2 Software Guide, Revision F: Crimson communications and TCP/IP concepts.
Need Further assistance? Submit a support ticket here.
https://support.hms-networks.com/
© HMS Networks AB 2026