diff --git a/3.3.4-semiconductor-hall-effect/processing.ipynb b/3.3.4-semiconductor-hall-effect/processing.ipynb index 1143054..3416ebf 100644 --- a/3.3.4-semiconductor-hall-effect/processing.ipynb +++ b/3.3.4-semiconductor-hall-effect/processing.ipynb @@ -370,7 +370,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.2" + "version": "3.10.6" } }, "nbformat": 4, diff --git a/3.5.1-ne-plasma/latex.zip b/3.5.1-ne-plasma/latex.zip new file mode 100644 index 0000000..8c0533a Binary files /dev/null and b/3.5.1-ne-plasma/latex.zip differ diff --git a/3.5.1-ne-plasma/report.pdf b/3.5.1-ne-plasma/report.pdf index 0a00e2c..ca936cd 100644 Binary files a/3.5.1-ne-plasma/report.pdf and b/3.5.1-ne-plasma/report.pdf differ diff --git a/3.6.1-spectrum/latex.zip b/3.6.1-spectrum/latex.zip new file mode 100644 index 0000000..c8e750c Binary files /dev/null and b/3.6.1-spectrum/latex.zip differ diff --git a/3.6.1-spectrum/report.pdf b/3.6.1-spectrum/report.pdf index 9a278df..0233911 100644 Binary files a/3.6.1-spectrum/report.pdf and b/3.6.1-spectrum/report.pdf differ diff --git a/project/.gitignore b/project/.gitignore new file mode 100644 index 0000000..fcea9db --- /dev/null +++ b/project/.gitignore @@ -0,0 +1,6 @@ +*test* +*tmp* +.vscode +*.exe +*.o +main \ No newline at end of file diff --git a/project/hardware/Device.cpp b/project/hardware/Device.cpp new file mode 100644 index 0000000..d52d933 --- /dev/null +++ b/project/hardware/Device.cpp @@ -0,0 +1,44 @@ +#include "Device.hpp" + + +Device::Device(std::string path_name) : root_path("/dev/" + path_name) +{ + std::string response = query("*IDN?"); + response.erase(0, response.find(',') + 1); + response.erase(response.find(',')); + + name = response; +} + +void Device::command(std::string comm) +{ + std::ofstream out; + out.open(root_path); + + if (!out.is_open()) + std::cerr << "**ERROR** file is not open to output." << std::endl; + else + { + out << comm; + out.close(); + } +} + +std::string Device::query(std::string comm) +{ + command(comm); + + std::string buffer; + std::ifstream in; + in.open(root_path); + + if (!in.is_open()) + std::cerr << "**ERROR** file is not open to input." << std::endl; + else + { + std::getline(in, buffer); + in.close(); + } + + return buffer; +} diff --git a/project/hardware/Device.hpp b/project/hardware/Device.hpp new file mode 100644 index 0000000..0caf7eb --- /dev/null +++ b/project/hardware/Device.hpp @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include + +class Device +{ +public: + Device(std::string path_name); + + std::string get_name() + { + return name; + } + + void command(std::string comm); + std::string query(std::string comm); + +protected: + std::string name; + std::string root_path; +}; + + + diff --git a/project/hardware/Generator.cpp b/project/hardware/Generator.cpp new file mode 100644 index 0000000..18b6cf8 --- /dev/null +++ b/project/hardware/Generator.cpp @@ -0,0 +1,2 @@ +#include "Generator.hpp" + diff --git a/project/hardware/Generator.hpp b/project/hardware/Generator.hpp new file mode 100644 index 0000000..471d6b0 --- /dev/null +++ b/project/hardware/Generator.hpp @@ -0,0 +1,54 @@ +#pragma once +#include "Device.hpp" + +class Generator : public Device +{ +public: + Generator(std::string path_name) : Device(path_name), m_channel("C1") {} + + void set_channel(size_t channel) + { + if (channel == 1 || channel == 2) + m_channel = "C" + std::to_string(channel); + else + std::cerr << "Invalid channel" << std::endl; + } + + void buzz() + { + command("BUZZ ON"); + } + + void set_waveform(std::string waveform) + { + command(m_channel + ":BSWV WVTP," + waveform); + } + + void set_frequency(double frequency) + { + command(m_channel + ":BSWV FRQ," + std::to_string(frequency)); + } + + void set_period(double period) + { + command(m_channel + ":BSWV PERI," + std::to_string(period)); + } + + void set_amplitude(double amplitude) + { + command(m_channel + ":BSWV AMP," + std::to_string(amplitude)); + } + + void set_offset(double offset) + { + command(m_channel + ":BSWV OFST," + std::to_string(offset)); + } + + void set_phase(double phase) + { + command(m_channel + ":BSWV PHSE," + std::to_string(phase)); + } + +private: + std::string m_channel; +}; \ No newline at end of file diff --git a/project/hardware/Makefile b/project/hardware/Makefile new file mode 100644 index 0000000..50db55b --- /dev/null +++ b/project/hardware/Makefile @@ -0,0 +1,26 @@ +CC=g++ +CFLAGS=-c +EXECUTABLE=start + +all: $(EXECUTABLE) + +$(EXECUTABLE): main.o Device.o Generator.o Oscilloscope.o + $(CC) main.o Device.o Generator.o Oscilloscope.o -o main + +main.o: main.cpp + $(CC) $(CFLAGS) main.cpp + +Device.o: Device.cpp + $(CC) $(CFLAGS) Device.cpp + +Generator.o: Generator.cpp + $(CC) $(CFLAGS) Generator.cpp + +Oscilloscope.o: Oscilloscope.cpp + $(CC) $(CFLAGS) Oscilloscope.cpp + +clean: + rm -f main + rm -f *.o + +.PNONY: all clean diff --git a/project/hardware/Measurement.hpp b/project/hardware/Measurement.hpp new file mode 100644 index 0000000..5189d8c --- /dev/null +++ b/project/hardware/Measurement.hpp @@ -0,0 +1,28 @@ +#pragma once +#include +#include +#include "Oscilloscope.hpp" + +class Measurement +{ +public: + + Measurement() = default; + + Measurement(std::string name_) : name(name_) { } + + Measurement(std::string stat_response, bool) + { + size_t name_start = stat_response.find(" C") + 5; + size_t name_end = stat_response.find(":"); + name = stat_response.substr(name_start, name_end - name_start); + } + +// private: + std::string name; + double mean; + double min; + double max; + double std_dev; + double count; +}; \ No newline at end of file diff --git a/project/hardware/Oscilloscope.cpp b/project/hardware/Oscilloscope.cpp new file mode 100644 index 0000000..9ee135e --- /dev/null +++ b/project/hardware/Oscilloscope.cpp @@ -0,0 +1 @@ +#include "Oscilloscope.hpp" \ No newline at end of file diff --git a/project/hardware/Oscilloscope.hpp b/project/hardware/Oscilloscope.hpp new file mode 100644 index 0000000..9c669c6 --- /dev/null +++ b/project/hardware/Oscilloscope.hpp @@ -0,0 +1,61 @@ +#pragma once +#include "Device.hpp" +#include "Measurement.hpp" +#include +#include + +class Oscilloscope : public Device +{ +public: + Oscilloscope(std::string path_name) : Device(path_name), m_channel("C1") {} + + void set_channel(size_t channel) + { + if (channel == 1 || channel == 2) + m_channel = "C" + std::to_string(channel); + else + std::cerr << "Invalid channel" << std::endl; + } + + Measurement get_pkpk() + { + comm_param_custom("PKPK"); + comm_param_stat(1); + + // size_t count = 0; + // while (count <= 20) + // { + // std::string response = quer_param_value("STAT1"); + // size_t count_ind = response.find("count,") + 5; + // std::string count_str = response.substr(count_ind); + // std::cerr << count_str; + // comm_param_stat(0); + + // count = std::stoi(count_str); + // } + std::string response = quer_param_value("STAT1"); + comm_param_stat(0); + + std::cout << response << std::endl; + return Measurement(response, 1); + } + + +private: + void comm_param_custom(std::string param) + { + command("PACU " + param + "," + m_channel); + } + + void comm_param_stat(bool condition) + { + command("PASTAT " + condition ? "ON" : "OFF"); + } + + std::string quer_param_value(std::string custom) + { + return query("PAVA? " + custom); + } + + std::string m_channel; +}; \ No newline at end of file diff --git a/project/hardware/main.cpp b/project/hardware/main.cpp new file mode 100644 index 0000000..9812c67 --- /dev/null +++ b/project/hardware/main.cpp @@ -0,0 +1,36 @@ +#include "Generator.hpp" +#include "Oscilloscope.hpp" +#include +#include + +int main() { + + // initialize generator and oscilloscope + + std::string generator_path; + std::string oscilloscope_path; + + for (size_t i = 0; i < 2; i++) { + auto path = "usbtmc" + std::to_string(i); + Device device(path); + + if (device.get_name() == "AKIP-3409-4") + generator_path = path; + else if (device.get_name() == "AKIP-4131/1") + oscilloscope_path = path; + else { + std::cerr << "Devices not available!" << std::endl; + return EXIT_FAILURE; + } + } + + Generator generator(generator_path); + Oscilloscope oscilloscope(oscilloscope_path); + + + // work with devices + + std::cout << oscilloscope.query("C1:WF? DAT2").substr(1, 3) << std::endl; + + return EXIT_SUCCESS; +} diff --git a/project/hardware/osc.md b/project/hardware/osc.md new file mode 100644 index 0000000..5009c4b --- /dev/null +++ b/project/hardware/osc.md @@ -0,0 +1,13 @@ +## Channel commands + +TRA -- trace +VDIV -- vertical sensitivity + +## MEASURE commands + +PACU -- parameter custom +PAVA? -- parameter value + +## WAVEFORM commands + +#todo \ No newline at end of file diff --git a/project/materials/SDG_Programming-Guide_PG02-E04A.pdf b/project/materials/SDG_Programming-Guide_PG02-E04A.pdf new file mode 100644 index 0000000..76b246a Binary files /dev/null and b/project/materials/SDG_Programming-Guide_PG02-E04A.pdf differ diff --git a/project/materials/SDS1000-SeriesSDS2000XSDS2000X-E_ProgrammingGuide_PG01-E02D.pdf b/project/materials/SDS1000-SeriesSDS2000XSDS2000X-E_ProgrammingGuide_PG01-E02D.pdf new file mode 100644 index 0000000..86518a4 Binary files /dev/null and b/project/materials/SDS1000-SeriesSDS2000XSDS2000X-E_ProgrammingGuide_PG01-E02D.pdf differ diff --git a/project/hard_standarts.md b/project/materials/hard_standart.md similarity index 100% rename from project/hard_standarts.md rename to project/materials/hard_standart.md