basic signal generator control

This commit is contained in:
BENEDEK László 2025-03-28 15:57:57 +01:00
parent d8164d120f
commit 0c8be8bb27
3 changed files with 41 additions and 0 deletions

View File

@ -13,3 +13,4 @@ link_directories(/opt/picoscope/lib)
add_subdirectory(src/recorder)
add_subdirectory(src/filter)
add_subdirectory(src/awg)

7
src/awg/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCES "./*.c")
add_executable(awg ${SOURCES})
target_compile_options(awg PRIVATE -Wall -Wextra)
target_link_libraries(awg ps2000)
set_target_properties(awg PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)

33
src/awg/main.c Normal file
View File

@ -0,0 +1,33 @@
#include <libps2000/ps2000.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
int main(void) {
int16_t unit = ps2000_open_unit();
if (unit == -1) {
fprintf(stderr, "failed to open a unit!\n");
return -1;
} else if (unit == 0) {
fprintf(stderr, "no units to open!\n");
return -1;
}
for (int32_t i = 0; i < 2000; i++) {
int16_t err = ps2000_set_sig_gen_built_in(unit, i * 1000, 0, PS2000_DC_VOLTAGE, 0, 0, 0, 0, PS2000_UPDOWN, 0);
if (err == 0) {
printf("failed to set voltage\n");
return 1;
} else {
fprintf(stderr, "%d\n", i);
}
usleep(1000);
}
ps2000_stop(unit);
ps2000_close_unit(unit);
return 0;
}