install added
This commit is contained in:
parent
42e6a6d12d
commit
c200f5da63
30
driver/examples/pegel/Makefile
Normal file
30
driver/examples/pegel/Makefile
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Name: Makefile
|
||||||
|
# Project: B15F (board15 Famulus Edition)
|
||||||
|
# Author: Tristan Krause
|
||||||
|
# Creation Date: 2019-05-15
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
COMPILER_PATH = g++
|
||||||
|
|
||||||
|
# Options
|
||||||
|
CFLAGS = -std=c++17 -O3 -Wall -Wextra
|
||||||
|
LDFLAGS = -lb15fdrv
|
||||||
|
OBJECTS = main.o
|
||||||
|
OUT = main.elf
|
||||||
|
|
||||||
|
COMPILE = $(COMPILER_PATH) $(CFLAGS)
|
||||||
|
|
||||||
|
main: $(OBJECTS)
|
||||||
|
$(COMPILE) $(OBJECTS) -o $(OUT) $(LDFLAGS)
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "This Makefile has the following targets:"
|
||||||
|
@echo "make main .... to compile"
|
||||||
|
@echo "make clean ... to delete objects and executables"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo "Cleaning..."
|
||||||
|
rm -f $(OBJECTS) $(OUT)
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(COMPILE) -c $< -o $@
|
178
driver/examples/pegel/main.cpp
Normal file
178
driver/examples/pegel/main.cpp
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
#include <b15f/b15f.h>
|
||||||
|
#include <b15f/plottyfile.h>
|
||||||
|
|
||||||
|
|
||||||
|
void kennlinieErsterQuadrant()
|
||||||
|
{
|
||||||
|
|
||||||
|
B15F& drv = B15F::getInstance();
|
||||||
|
PlottyFile pf;
|
||||||
|
|
||||||
|
uint16_t ba[1024];
|
||||||
|
uint16_t bb[1024];
|
||||||
|
|
||||||
|
const uint16_t sample_count = 1024;
|
||||||
|
const uint16_t delta = 1;
|
||||||
|
|
||||||
|
const uint16_t u_gs_start = 440;
|
||||||
|
const uint16_t u_gs_delta = 20;
|
||||||
|
const uint16_t u_gs_end = 600;
|
||||||
|
|
||||||
|
pf.setUnitX("V");
|
||||||
|
pf.setUnitY("mA");
|
||||||
|
pf.setUnitPara("V");
|
||||||
|
pf.setDescX("U_{DS}");
|
||||||
|
pf.setDescY("I_D");
|
||||||
|
pf.setDescPara("U_{GS}");
|
||||||
|
pf.setRefX(5);
|
||||||
|
pf.setRefY(50);
|
||||||
|
pf.setParaFirstCurve(u_gs_start);
|
||||||
|
pf.setParaStepWidth(u_gs_delta);
|
||||||
|
|
||||||
|
uint8_t curve = 0;
|
||||||
|
|
||||||
|
std::cout << "Erfasse Kennlinie erster Quadrant..." << std::endl << std::flush;
|
||||||
|
|
||||||
|
for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta)
|
||||||
|
{
|
||||||
|
drv.analogWrite1(u_gs);
|
||||||
|
|
||||||
|
drv.analogSequence(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count);
|
||||||
|
|
||||||
|
for(uint16_t k = 0; k < sample_count; k++)
|
||||||
|
{
|
||||||
|
uint16_t i_d = ba[k] - bb[k];
|
||||||
|
uint16_t u_ds = bb[k];
|
||||||
|
pf.addDot(Dot(u_ds, i_d, curve));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\033[1K\r" << 1e2 * (u_gs - u_gs_start) / (u_gs_end - u_gs_start) << "%" << std::flush;
|
||||||
|
|
||||||
|
curve++;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\033[1K\r" << std::flush;
|
||||||
|
|
||||||
|
// speichern und plotty starten
|
||||||
|
pf.writeToFile("test_plot");
|
||||||
|
pf.startPlotty("test_plot");
|
||||||
|
}
|
||||||
|
|
||||||
|
void kennlinieZweiterQuadrant()
|
||||||
|
{
|
||||||
|
B15F& drv = B15F::getInstance();
|
||||||
|
PlottyFile pf;
|
||||||
|
|
||||||
|
uint16_t ba[1024];
|
||||||
|
uint16_t bb[1024];
|
||||||
|
|
||||||
|
const uint16_t sample_count = 1024;
|
||||||
|
const uint16_t delta = 1;
|
||||||
|
|
||||||
|
const uint16_t u_gs_start = 300;
|
||||||
|
const uint16_t u_gs_delta = 25;
|
||||||
|
const uint16_t u_gs_end = 700;
|
||||||
|
|
||||||
|
pf.setQuadrant(2);
|
||||||
|
pf.setUnitX("V");
|
||||||
|
pf.setUnitY("mA");
|
||||||
|
pf.setUnitPara("V");
|
||||||
|
pf.setDescX("U_{GS}");
|
||||||
|
pf.setDescY("I_D");
|
||||||
|
pf.setDescPara("U_{DS}");
|
||||||
|
pf.setRefX(5);
|
||||||
|
pf.setRefY(50);
|
||||||
|
pf.setParaFirstCurve(u_gs_start);
|
||||||
|
pf.setParaStepWidth(u_gs_delta);
|
||||||
|
|
||||||
|
uint8_t curve = 0;
|
||||||
|
|
||||||
|
std::cout << "Erfasse Kennlinie zweiter Quadrant..." << std::endl << std::flush;
|
||||||
|
|
||||||
|
for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta)
|
||||||
|
{
|
||||||
|
drv.analogWrite1(u_gs);
|
||||||
|
|
||||||
|
drv.analogSequence(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count);
|
||||||
|
|
||||||
|
curve = 0;
|
||||||
|
for(uint16_t k = 0; k < sample_count; k++)
|
||||||
|
{
|
||||||
|
if(ba[k] > bb[k] && bb[k] % 50 == 0 && bb[k] != 0)
|
||||||
|
{
|
||||||
|
uint16_t i_d = ba[k] - bb[k];
|
||||||
|
pf.addDot(Dot(u_gs, i_d, bb[k] / 50));
|
||||||
|
}
|
||||||
|
curve++;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\033[1K\r" << 1e2 * (u_gs - u_gs_start) / (u_gs_end - u_gs_start) << "%" << std::flush;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\033[1K\r" << std::flush;
|
||||||
|
|
||||||
|
// speichern und plotty starten
|
||||||
|
pf.writeToFile("test_plot");
|
||||||
|
pf.startPlotty("test_plot");
|
||||||
|
}
|
||||||
|
|
||||||
|
void testFunktionen()
|
||||||
|
{
|
||||||
|
B15F& drv = B15F::getInstance();
|
||||||
|
|
||||||
|
std::cout << "DIP-Switch: " << (int) drv.readDipSwitch() << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
drv.digitalWrite0(0xFF);
|
||||||
|
drv.analogWrite0(128);
|
||||||
|
std::cout << (int) drv.digitalRead0() << std::endl;;
|
||||||
|
std::cout << "adc: " << (int) drv.analogRead(4) << std::endl;
|
||||||
|
|
||||||
|
drv.digitalWrite0(0x00);
|
||||||
|
drv.analogWrite0(0);
|
||||||
|
std::cout << (int) drv.digitalRead0() << std::endl;;
|
||||||
|
std::cout << "adc: " << (int) drv.analogRead(4) << std::endl;
|
||||||
|
|
||||||
|
drv.digitalWrite0(0xFF);
|
||||||
|
drv.analogWrite0(255);
|
||||||
|
std::cout << (int) drv.digitalRead0() << std::endl;
|
||||||
|
std::cout << "adc: " << (int) drv.analogRead(4) << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "Kennlinie..." << std::endl;
|
||||||
|
uint16_t a[1024];
|
||||||
|
uint16_t b[1024];
|
||||||
|
drv.analogSequence(0, &a[0], 0, 1, &b[0], 0, 0, 1, 1024);
|
||||||
|
|
||||||
|
/*for(uint16_t i= 0; i < sizeof(a) / sizeof(uint16_t); i++)
|
||||||
|
{
|
||||||
|
std::cout << (int) i << " : " << a[i] << " " << b[i] << std::endl;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//testFunktionen();
|
||||||
|
//kennlinieZweiterQuadrant();
|
||||||
|
|
||||||
|
B15F& drv = B15F::getInstance();
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
//uint8_t be0 = drv.digitalRead0();
|
||||||
|
//uint8_t be1 = drv.digitalRead1();
|
||||||
|
//uint8_t dsw = drv.readDipSwitch();
|
||||||
|
drv.analogRead(0);
|
||||||
|
drv.analogRead(1);
|
||||||
|
drv.analogRead(2);
|
||||||
|
drv.analogRead(3);
|
||||||
|
drv.analogRead(4);
|
||||||
|
drv.analogRead(5);
|
||||||
|
drv.analogRead(6);
|
||||||
|
drv.analogRead(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Schluss." << std::endl;
|
||||||
|
}
|
|
@ -8,11 +8,14 @@ COMPILER_PATH = g++
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
LIB_DRV = ../lib/libb15fdrv.so
|
LIB_DRV = ../lib/libb15fdrv.so
|
||||||
|
LIB_PATH = /usr/lib/
|
||||||
|
INCLUDE_PATH = /usr/include/b15f
|
||||||
OBJ_MAIN = main.o
|
OBJ_MAIN = main.o
|
||||||
OUT_CLI = ../bin/cli.elf
|
OUT_CLI = ../bin/cli.elf
|
||||||
OBJ_CLI = cli.o
|
OBJ_CLI = cli.o
|
||||||
CFLAGS = -std=c++17 -O3 -Wall -Wextra -fPIC
|
CFLAGS = -std=c++17 -O3 -Wall -Wextra -fPIC
|
||||||
LDFLAGS = -lcurses -lpthread
|
LDFLAGS_DRV = -lcurses -lpthread
|
||||||
|
LDFLAGS = $(LDFLAGS_DRV) -lb15fdrv
|
||||||
OBJECTS_DRV = drv/usart.o drv/b15f.o drv/plottyfile.o drv/dot.o
|
OBJECTS_DRV = drv/usart.o drv/b15f.o drv/plottyfile.o drv/dot.o
|
||||||
OBJECTS_UI = ui/view.o ui/view_selection.o ui/view_promt.o ui/view_info.o ui/view_monitor.o ui/ui.o
|
OBJECTS_UI = ui/view.o ui/view_selection.o ui/view_promt.o ui/view_info.o ui/view_monitor.o ui/ui.o
|
||||||
|
|
||||||
|
@ -26,13 +29,19 @@ drv: $(OBJECTS_DRV) $(LIB_DRV)
|
||||||
cli: drv $(OBJECTS_UI) $(OBJ_CLI)
|
cli: drv $(OBJECTS_UI) $(OBJ_CLI)
|
||||||
@echo "Linking cli..."
|
@echo "Linking cli..."
|
||||||
mkdir -p ../bin
|
mkdir -p ../bin
|
||||||
$(COMPILE) $(OBJ_CLI) $(OBJECTS_UI) -L../lib -Wl,-rpath=../lib -lb15fdrv -o $(OUT_CLI) $(LDFLAGS)
|
$(COMPILE) $(OBJ_CLI) $(OBJECTS_UI) -L../lib -Wl,-rpath=../lib -o $(OUT_CLI) $(LDFLAGS)
|
||||||
|
|
||||||
|
install: drv
|
||||||
|
cp $(LIB_DRV) $(LIB_PATH)
|
||||||
|
mkdir -p $(INCLUDE_PATH)
|
||||||
|
cp drv/*.h $(INCLUDE_PATH)
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "This Makefile compiles the b15f driver lib and command line interface (CLI):"
|
@echo "This Makefile compiles the b15f driver lib and command line interface (CLI):"
|
||||||
@echo "make ......... to compile all"
|
@echo "make ......... to compile all"
|
||||||
@echo "make drv ..... to compile the b15f driver lib"
|
@echo "make drv ..... to compile the b15f driver lib"
|
||||||
@echo "make cli .... to compile the cli"
|
@echo "make cli ..... to compile the cli"
|
||||||
|
@echo "make install . to install the lib and headers on this machine"
|
||||||
@echo "make clean ... to delete objects and executables"
|
@echo "make clean ... to delete objects and executables"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -45,4 +54,4 @@ clean:
|
||||||
$(LIB_DRV):
|
$(LIB_DRV):
|
||||||
@echo "Linking driver library..."
|
@echo "Linking driver library..."
|
||||||
mkdir -p ../lib
|
mkdir -p ../lib
|
||||||
$(COMPILE) $(OBJECTS_DRV) -shared -o $(LIB_DRV) $(LDFLAGS)
|
$(COMPILE) $(OBJECTS_DRV) -shared -o $(LIB_DRV) $(LDFLAGS_DRV)
|
||||||
|
|
Loading…
Reference in a new issue