ngscopeclient 0.1-dev+51fbda87c
AlientekPowerSupply.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
38#ifndef AlientekPowerSupply_h
39#define AlientekPowerSupply_h
40
46 : public virtual SCPIPowerSupply
47 , public virtual HIDInstrument
48{
49public:
51 virtual ~AlientekPowerSupply();
52
53 //Device information
54 virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override;
55
56 //Device capabilities
57 virtual bool SupportsIndividualOutputSwitching() override;
58 virtual bool SupportsVoltageCurrentControl(int chan) override;
59
60 //Read sensors
61 virtual double GetPowerVoltageActual(int chan) override; //actual voltage after current limiting
62 virtual double GetPowerVoltageNominal(int chan) override; //set point
63 virtual double GetPowerCurrentActual(int chan) override; //actual current drawn by the load
64 virtual double GetPowerCurrentNominal(int chan) override; //current limit
65 virtual bool GetPowerChannelActive(int chan) override;
66
67 //Configuration
68 virtual void SetPowerVoltage(int chan, double volts) override;
69 virtual void SetPowerCurrent(int chan, double amps) override;
70 virtual void SetPowerChannelActive(int chan, bool on) override;
71 virtual bool IsPowerConstantCurrent(int chan) override;
72
73protected:
74 enum Function : uint8_t
75 {
76 DEVICE_INFO = 0x10, // 16
77 FIRM_INFO = 0x11, // 17
78 START_TRANS = 0x12, // 18
79 DATA_TRANS = 0x13, // 19
80 END_TRANS = 0x14, // 20
81 DEV_UPGRADE = 0x15, // 21
82 BASIC_INFO = 0x30, // 48
83 BASIC_SET = 0x35, // 53
84 SYSTEM_INFO = 0x40, // 64
85 SYSTEM_SET = 0x45, // 69
86 SCAN_OUT = 0x50, // 80
87 SERIAL_OUT = 0x55, // 85
88 DISCONNECT = 0x80, // 128
89 NONE = 0xFF // 255
90 };
91
92 enum Operation : uint8_t
93 {
94 OUTPUT = 0x20, // 32
95 SETTING = 0x40, // 64
96 READ = 0x80 // 128
97 };
98
99 void SendReceiveReport(Function function, int sequence = -1, std::vector<uint8_t>* data = nullptr);
100 void SendGetBasicSetReport();
101 void SendSetBasicSetReport();
102
103 uint8_t m_deviceAdress = 0xFB;
104
105 // Cache management for BASIC_INFO and BASIC_SET functions
106 std::chrono::system_clock::time_point m_nextBasicInfoUpdate;
107 std::chrono::milliseconds m_basicInfoCacheDuration = std::chrono::milliseconds(10); // 100 Hz
108 std::chrono::system_clock::time_point m_nextBasicSetUpdate;
109 std::chrono::milliseconds m_basicSetCacheDuration = std::chrono::milliseconds(1000); // 1 Hz => not supposed to change in lock mode
110
112 double m_vIn;
113
115 double m_vOut;
116
118 double m_vOutSet;
119
121 double m_iOut;
122
124 double m_iOutSet;
125
127 double m_vOutMax;
128
130 double m_temp1;
131
133 double m_temp2;
134
136 double m_dc5V;
137
139 uint8_t m_outMode;
140
142 uint8_t m_workState;
143
145 double m_ovpSet;
146
148 double m_ocpSet;
149
152
153public:
154 static std::string GetDriverNameInternal();
155 POWER_INITPROC(AlientekPowerSupply);
156};
157
158#endif
An Alientek DP-100 power supply or other equivalent model.
Definition: AlientekPowerSupply.h:48
double m_iOutSet
Set output current in A.
Definition: AlientekPowerSupply.h:124
double m_iOut
Actual output current in A.
Definition: AlientekPowerSupply.h:121
uint8_t m_outMode
Output mode => 0 = CC, 1 = CV, 2 = OVP/OCP (according to workState)
Definition: AlientekPowerSupply.h:139
virtual bool SupportsIndividualOutputSwitching() override
Determines if the power supply supports switching individual output channels.
Definition: AlientekPowerSupply.cpp:111
bool m_powerState
Power state.
Definition: AlientekPowerSupply.h:151
double m_temp2
Temperature 2 in °C.
Definition: AlientekPowerSupply.h:133
uint8_t m_workState
Work state => 1 = OVP, 2 = OCP.
Definition: AlientekPowerSupply.h:142
virtual uint32_t GetInstrumentTypesForChannel(size_t i) const override
Returns a bitfield describing the set of instrument types that a given channel supports.
Definition: AlientekPowerSupply.cpp:103
double m_ovpSet
Over-voltage protection setting in V.
Definition: AlientekPowerSupply.h:145
virtual bool SupportsVoltageCurrentControl(int chan) override
Determines if the power supply supports voltage/current control for the given channel.
Definition: AlientekPowerSupply.cpp:116
double m_temp1
Temperature 1 in °C.
Definition: AlientekPowerSupply.h:130
double m_vOutSet
Set output voltage in V.
Definition: AlientekPowerSupply.h:118
static std::string GetDriverNameInternal()
Return the constant driver name "alientek_dp".
Definition: AlientekPowerSupply.cpp:98
double m_dc5V
5V rail in V.
Definition: AlientekPowerSupply.h:136
double m_ocpSet
Over-current protection setting in A.
Definition: AlientekPowerSupply.h:148
double m_vOutMax
Max output voltage in V.
Definition: AlientekPowerSupply.h:127
double m_vIn
Input voltage in V.
Definition: AlientekPowerSupply.h:112
double m_vOut
Actual output voltage in V.
Definition: AlientekPowerSupply.h:115
Base class for instruments using USB HID communication protocol.
Definition: HIDInstrument.h:46
An SCPI-based power supply.
Definition: SCPIPowerSupply.h:38
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47