ngscopeclient 0.1-dev+51fbda87c
NanoVNA.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
37#ifndef NanoVNA_h
38#define NanoVNA_h
39
40class EdgeTrigger;
41
46class NanoVNA : public virtual SCPIVNA, public virtual CommandLineDriver
47{
48public:
49 NanoVNA(SCPITransport* transport);
50 virtual ~NanoVNA();
51
52 //not copyable or assignable
53 NanoVNA(const NanoVNA& rhs) =delete;
54 NanoVNA& operator=(const NanoVNA& rhs) =delete;
55
56public:
57
58 //Channel configuration
59
60 //Triggering
61 virtual OscilloscopeChannel* GetExternalTrigger() override;
62 virtual Oscilloscope::TriggerMode PollTrigger() override;
63 virtual bool AcquireData() override;
64 virtual void Start() override;
65 virtual void StartSingleTrigger() override;
66 virtual void Stop() override;
67 virtual void ForceTrigger() override;
68 virtual bool IsTriggerArmed() override;
69 virtual void PushTrigger() override;
70 virtual void PullTrigger() override;
71
72 //Timebase
73 virtual std::vector<uint64_t> GetSampleDepthsNonInterleaved() override;
74 virtual uint64_t GetSampleDepth() override;
75 virtual void SetSampleDepth(uint64_t depth) override;
76 // Sweep configuration
77 virtual void SetSpan(int64_t span) override;
78 virtual int64_t GetSpan() override;
79 virtual void SetCenterFrequency(size_t channel, int64_t freq) override;
80 virtual int64_t GetCenterFrequency(size_t channel) override;
81 // Rbw
82 virtual int64_t GetResolutionBandwidth() override;
83 virtual void SetResolutionBandwidth(int64_t rbw) override;
84
85protected:
86 // Device communication methods and members
87 enum Model {
88 MODEL_UNKNOWN,
89 MODEL_NANOVNA,
90 MODEL_NANOVNA_D,
91 MODEL_NANOVNA_F_DEEPELEC,
92 MODEL_NANOVNA_F,
93 MODEL_NANOVNA_H,
94 MODEL_NANOVNA_H4,
95 MODEL_NANOVNA_F_V2,
96 MODEL_NANOVNA_V2
97 };
98
99 void SendBandwidthValue(int64_t bandwidth);
100
101 std::string GetChannelColor(size_t i);
102
103 bool m_triggerArmed = false;
104 bool m_triggerOneShot = false;
105
106 int64_t m_sampleDepth = 0;
107 size_t m_maxDeviceSampleDepth = 0;
108 int64_t m_rbw = 0;
109 std::map<int64_t,int64_t> m_rbwValues;
110
111 Model m_nanoVNAModel = MODEL_UNKNOWN;
112
113 // Span control
114 int64_t m_sweepStart;
115 int64_t m_sweepStop;
116
117 int64_t m_freqMax;
118 int64_t m_freqMin;
119
120public:
121 static std::string GetDriverNameInternal();
122 VNA_INITPROC(NanoVNA)
123};
124
125#endif
Helper class for command line drivers: provides helper methods for command line based communication w...
Definition: CommandLineDriver.h:46
Simple edge trigger.
Definition: EdgeTrigger.h:44
NanoVNA - driver for talking to a NanoVNA using the NanoVNA 5 software.
Definition: NanoVNA.h:47
virtual std::vector< uint64_t > GetSampleDepthsNonInterleaved() override
Get the legal memory depths for this scope in all-channels mode.
Definition: NanoVNA.cpp:292
virtual void SetResolutionBandwidth(int64_t rbw) override
Gets the resolution bandwidth for frequency-domain channels.
Definition: NanoVNA.cpp:493
virtual int64_t GetResolutionBandwidth() override
Gets the resolution bandwidth for frequency-domain channels.
Definition: NanoVNA.cpp:488
virtual uint64_t GetSampleDepth() override
Gets the current sample depth of this scope.
Definition: NanoVNA.cpp:309
virtual bool AcquireData() override
Pull data from the instrument.
Definition: NanoVNA.cpp:319
std::string GetChannelColor(size_t i)
Color the channels based on Pico's standard color sequence (blue-red-green-yellow-purple-gray-cyan-ma...
Definition: NanoVNA.cpp:216
virtual Oscilloscope::TriggerMode PollTrigger() override
Checks the curent trigger status.
Definition: NanoVNA.cpp:247
virtual void PullTrigger() override
Updates m_trigger with any changes made from the instrument side.
Definition: NanoVNA.cpp:280
void SendBandwidthValue(int64_t bandwidth)
Set the bandwidth value.
Definition: NanoVNA.cpp:477
virtual bool IsTriggerArmed() override
Checks if the trigger is currently armed.
Definition: NanoVNA.cpp:275
virtual void StartSingleTrigger() override
Arms the trigger for a single acquistion.
Definition: NanoVNA.cpp:257
virtual void Stop() override
Stops triggering.
Definition: NanoVNA.cpp:263
virtual void PushTrigger() override
Pushes changes made to m_trigger to the instrument.
Definition: NanoVNA.cpp:285
virtual void Start() override
Starts the instrument in continuous trigger mode.
Definition: NanoVNA.cpp:251
virtual void SetSpan(int64_t span) override
Sets the span for frequency-domain channels.
Definition: NanoVNA.cpp:508
virtual void SetSampleDepth(uint64_t depth) override
Sets the sample depth of the scope.
Definition: NanoVNA.cpp:314
virtual void ForceTrigger() override
Forces a single acquisition as soon as possible.
Definition: NanoVNA.cpp:269
virtual void SetCenterFrequency(size_t channel, int64_t freq) override
Sets the center frequency for frequency-domain channels.
Definition: NanoVNA.cpp:528
virtual int64_t GetSpan() override
Gets the span for frequency-domain channels.
Definition: NanoVNA.cpp:523
virtual OscilloscopeChannel * GetExternalTrigger() override
Returns the external trigger input channel, if we have one.
Definition: NanoVNA.cpp:242
virtual int64_t GetCenterFrequency(size_t channel) override
Gets the center frequency for a frequency-domain channel.
Definition: NanoVNA.cpp:543
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
TriggerMode
Definition: Oscilloscope.h:411
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47
Generic representation of a vector network analyzer.
Definition: SCPIVNA.h:43