-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temp_commit: testing the new write function to raw attribute
Signed-off-by: Adrian Stanea <[email protected]>
- Loading branch information
1 parent
f4b6652
commit 92b610e
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# Copyright (c) 2019 Analog Devices Inc. | ||
# | ||
# This file is part of libm2k | ||
# (see http://www.github.com/analogdevicesinc/libm2k). | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 2.1 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
import libm2k | ||
|
||
ctx=libm2k.m2kOpen("ip:192.168.2.1") | ||
if ctx is None: | ||
print("Connection Error: No ADALM2000 device available/connected to your PC.") | ||
exit(1) | ||
|
||
ctx.calibrateADC() | ||
aout = ctx.getAnalogOut() | ||
|
||
print(f"channel 0: {aout.setChannelRaw(0, 555)}") | ||
print(f"channel 0: {aout.setChannelRaw(1, 666)}") | ||
|
||
|
||
|
||
|
||
|
||
libm2k.contextClose(ctx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.1.3) | ||
set (CMAKE_CXX_STANDARD 11) | ||
project(custom LANGUAGES CXX) | ||
|
||
|
||
if (LIBM2K_VERSION) # in-source build | ||
set(PROJECT_VERSION ${LIBM2K_VERSION}) | ||
else() # standalone build | ||
set(PROJECT_VERSION "1.0.0") | ||
find_package(libm2k REQUIRED) | ||
endif() | ||
|
||
if (NOT WIN32) | ||
find_library(PTHREAD_LIBRARIES pthread) | ||
endif() | ||
|
||
add_executable(${PROJECT_NAME} "main.cpp") | ||
target_link_libraries(${PROJECT_NAME} PRIVATE libm2k::libm2k) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2019 Analog Devices Inc. | ||
* | ||
* This file is part of libm2k | ||
* (see http://www.github.com/analogdevicesinc/libm2k). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 2.1 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
// This example assumes the following connections: | ||
// W1 -> 1+ | ||
// W2 -> 2+ | ||
// GND -> 1- | ||
// GND -> 2- | ||
// | ||
// The application will generate a sine and triangular wave on W1 and W2. The signal is fed back into the analog input | ||
// and the voltage values are displayed on the screen | ||
|
||
#define _USE_MATH_DEFINES | ||
#include <iostream> | ||
#include <math.h> | ||
#include <libm2k/m2k.hpp> | ||
#include <libm2k/contextbuilder.hpp> | ||
#include <libm2k/analog/m2kpowersupply.hpp> | ||
#include <libm2k/analog/m2kanalogin.hpp> | ||
#include <libm2k/analog/m2kanalogout.hpp> | ||
|
||
using namespace std; | ||
using namespace libm2k; | ||
using namespace libm2k::analog; | ||
using namespace libm2k::context; | ||
|
||
// uncomment the following definition to test triggering | ||
//#define TRIGGERING | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
M2k *ctx = m2kOpen("ip:192.168.2.1"); | ||
if (!ctx) { | ||
std::cout << "Connection Error: No ADALM2000 device available/connected to your PC." << std::endl; | ||
return 1; | ||
} | ||
|
||
M2kAnalogIn *ain = ctx->getAnalogIn(); | ||
M2kAnalogOut *aout = ctx->getAnalogOut(); | ||
#ifdef TRIGGERING | ||
M2kHardwareTrigger *trig = ain->getTrigger(); | ||
#endif | ||
|
||
// Prevent bad initial config | ||
ain->reset(); | ||
aout->reset(); | ||
|
||
aout->setChannelRaw(0, 123); | ||
aout->setChannelRaw(1, 456); | ||
|
||
|
||
contextClose(ctx); | ||
|
||
return 0; | ||
} |