basic signal generator control
This commit is contained in:
parent
d8164d120f
commit
0c8be8bb27
@ -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
7
src/awg/CMakeLists.txt
Normal 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
33
src/awg/main.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user