Search code examples
c#remote-access

Controlling AIM-TTI Power supply via C#


I’m working with a Aim-TTi CPX400DP power supply and tasked with using it remotely strictly via Visual Studio using C#. I’ve seen a lot of people on here using LabView and other software but nothing with Visual Studio. In addition upon looking up a manual for this power supply I’m also not seeing any syntax that I could use to call for this power supply in C#. Does anyone have an knowledge or support they could lend for this issue?

I’ve tried downloading NiMax and using it to verify the power supply is connected via USB. It’s denoting the Power supply as COM4. However, when I open up the panel in NiMax there’s no other connections or operations to speak of. I have no way of connecting it and sending or receiving data


Solution

  • Firstly I should let you know I work for Aim-TTi so I can assist in using your CPX400DP in Visual Studio with C#.

    The USB port on a CPX400DP is implemented as a CDC class virtual COM port and can be treated as a standard COM port by any application software.

    Below you find a small console application that I created in C#.

    Make sure to add "using System.IO.Ports;" which may require you to install the package of the same name (published by Microsoft) from the NuGet Package Manager in Visual Studio.

    I would recommend single stepping through this code and then you can see the responses you get in the rx_message string.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO.Ports;
    
    namespace CPX_Console
    {
        class Program
        {
    
            static SerialPort _serialPort;
    
            static void Main(string[] args)
            {
    
    
                string tx_message;
                string rx_message;
    
                _serialPort = new SerialPort();
    
    
                // configure the serial port to use the sesired COM port
                // Note, you dont have to configure the baud rate or any of the other default serialPort settings
                _serialPort.PortName = "COM7";
    
                // open the COM port
                _serialPort.Open();
    
                // query the CPX identification string
                tx_message = "*IDN?";
                _serialPort.WriteLine(tx_message);
    
                // get the response
                rx_message = _serialPort.ReadLine();
    
    
                // set channel 1 output to 1.23V
                tx_message = "V1 1.23";
                _serialPort.WriteLine(tx_message);
    
    
                // enable channel 1
                tx_message = "OP1 1";
                _serialPort.WriteLine(tx_message);
    
                // query the measured output voltage on channel 1
                tx_message = "V1O?";
                _serialPort.WriteLine(tx_message);
    
                // get the response
                rx_message = _serialPort.ReadLine();
    
                // close the COM port
                _serialPort.Close();
    
    
            }
        }
    }