Kennlinien funktionieren grob
This commit is contained in:
parent
e857b9a32e
commit
dd58ec7fed
2
Makefile
2
Makefile
|
@ -14,7 +14,7 @@ OBJECTS = main.o drv/b15f.o drv/plottyfile.o drv/dot.o
|
|||
|
||||
COMPILE = $(COMPILER_PATH) $(CFLAGS)
|
||||
|
||||
B15F: $(OBJECTS)
|
||||
B15F: clean $(OBJECTS)
|
||||
@echo "Linking..."
|
||||
$(COMPILE) $(OBJECTS) -o $(OUTPUT) $(LDFLAGS)
|
||||
|
||||
|
|
|
@ -282,6 +282,8 @@ bool B15F::analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t
|
|||
{
|
||||
buffer_a[offset_a + i] = readInt();
|
||||
buffer_b[offset_b + i] = readInt();
|
||||
if(buffer_a[offset_a + i] > 1023 || buffer_b[offset_b + i] > 1023)
|
||||
std::cout << "schlechte Werte gefunden" << std::endl;
|
||||
//std::cout << "(" << i << ") " << buffer_a[offset_a + i] << " \t| " << buffer_b[offset_b + i] << std::endl;
|
||||
}
|
||||
|
||||
|
|
BIN
drv/b15f.o
BIN
drv/b15f.o
Binary file not shown.
|
@ -17,6 +17,8 @@ void PlottyFile::setFunctionType(FunctionType function_type)
|
|||
|
||||
void PlottyFile::setQuadrant(uint8_t quadrant)
|
||||
{
|
||||
if(quadrant < 1 || quadrant > 4)
|
||||
throw std::range_error("Ungueltiger Quadrant");
|
||||
this->quadrant = quadrant;
|
||||
}
|
||||
|
||||
|
|
BIN
drv/plottyfile.o
BIN
drv/plottyfile.o
Binary file not shown.
|
@ -2,13 +2,33 @@ set margin 10,10
|
|||
unset key
|
||||
set grid
|
||||
set title ''
|
||||
set xlabel 'Zeit [t]'
|
||||
set ylabel 'Spannung [V]'
|
||||
set xrange [0:1023]
|
||||
set yrange [0:1023]
|
||||
set label at 1022,1022 '1' left
|
||||
set label at 1022,511 '2' left
|
||||
set xlabel 'U_{GS} [V]'
|
||||
set ylabel 'I_D [mA]'
|
||||
set xrange [5:0]
|
||||
set x2range [5:0]
|
||||
set y2range [0:50]
|
||||
set yrange [0:50]
|
||||
set label at 2,33 'U_{DS} [V] = 300' right
|
||||
set label at 2,30 'U_{DS} [V] = 325' right
|
||||
set label at 2,33 'U_{DS} [V] = 350' right
|
||||
set label at 2,35 'U_{DS} [V] = 375' right
|
||||
set label at 2,21 'U_{DS} [V] = 400' right
|
||||
set label at 2,21 'U_{DS} [V] = 425' right
|
||||
set label at 2,22 'U_{DS} [V] = 450' right
|
||||
set label at 2,22 'U_{DS} [V] = 475' right
|
||||
set label at 2,22 'U_{DS} [V] = 500' right
|
||||
set label at 2,5 'U_{DS} [V] = 525' right
|
||||
set label at 2,11 'U_{DS} [V] = 550' right
|
||||
set label at 2,11 'U_{DS} [V] = 575' right
|
||||
set label at 2,11 'U_{DS} [V] = 600' right
|
||||
set label at 2,11 'U_{DS} [V] = 625' right
|
||||
set label at 2,4 'U_{DS} [V] = 650' right
|
||||
set label at 2,4 'U_{DS} [V] = 650' right
|
||||
set label at 2,4 'U_{DS} [V] = 700' right
|
||||
set y2tics
|
||||
unset ytics
|
||||
set ytics format ''
|
||||
unset output
|
||||
set terminal qt
|
||||
unset output
|
||||
plot "/tmp/tempfile0" using ($1*1.000000):($2*1.000000) binary format="%int16%int16" endian=big title ' [] = 1' w l,"/tmp/tempfile1" using ($1*1.000000):($2*1.000000) binary format="%int16%int16" endian=big title ' [] = 2' w l
|
||||
plot "/tmp/tempfile1" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 300' w l,"/tmp/tempfile2" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 325' w l,"/tmp/tempfile3" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 350' w l,"/tmp/tempfile4" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 375' w l,"/tmp/tempfile5" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 400' w l,"/tmp/tempfile6" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 425' w l,"/tmp/tempfile7" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 450' w l,"/tmp/tempfile8" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 475' w l,"/tmp/tempfile9" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 500' w l,"/tmp/tempfile10" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 525' w l,"/tmp/tempfile11" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 550' w l,"/tmp/tempfile12" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 575' w l,"/tmp/tempfile13" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 600' w l,"/tmp/tempfile14" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 625' w l,"/tmp/tempfile15" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 650' w l,"/tmp/tempfile16" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 675' w l,"/tmp/tempfile17" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 700' w l
|
||||
|
|
132
main.cpp
132
main.cpp
|
@ -2,44 +2,116 @@
|
|||
#include "drv/b15f.h"
|
||||
#include "drv/plottyfile.h"
|
||||
|
||||
PlottyFile pf;
|
||||
|
||||
void kennlinieErsterQuadrant()
|
||||
{
|
||||
B15F& drv = B15F::getInstance();
|
||||
|
||||
uint16_t ba[1024];
|
||||
uint16_t bb[1024];
|
||||
|
||||
const uint16_t sample_count = 100;
|
||||
const uint16_t delta = 10;
|
||||
|
||||
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;
|
||||
for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta)
|
||||
{
|
||||
drv.analogeAusgabe1(u_gs);
|
||||
|
||||
drv.analogEingabeSequenz(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count);
|
||||
drv.delay(10);
|
||||
drv.discard();
|
||||
drv.delay(10);
|
||||
|
||||
for(uint16_t k = 0; k < sample_count+1; k++)
|
||||
{
|
||||
uint16_t i_d = ba[k] - bb[k];
|
||||
uint16_t u_ds = bb[k];
|
||||
pf.addDot(Dot(u_ds, i_d, curve));
|
||||
}
|
||||
|
||||
curve++;
|
||||
}
|
||||
}
|
||||
|
||||
void kennlinieZweiterQuadrant()
|
||||
{
|
||||
B15F& drv = B15F::getInstance();
|
||||
|
||||
uint16_t ba[1024];
|
||||
uint16_t bb[1024];
|
||||
|
||||
const uint16_t sample_count = 1000;
|
||||
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;
|
||||
for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta)
|
||||
{
|
||||
drv.analogeAusgabe1(u_gs);
|
||||
|
||||
drv.analogEingabeSequenz(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count);
|
||||
drv.delay(10);
|
||||
drv.discard();
|
||||
drv.delay(10);
|
||||
|
||||
curve = 0;
|
||||
for(uint16_t k = 0; k < sample_count + 1; 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 << "u_gs: " << u_gs << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
B15F& drv = B15F::getInstance();
|
||||
drv.init();
|
||||
|
||||
/*
|
||||
while(1)
|
||||
{
|
||||
for(uint16_t i = 0; i < 1024; i++)
|
||||
{
|
||||
drv.analogeAusgabe0(drv.analogeEingabe(5));
|
||||
//drv.delay(10);
|
||||
//drv.digitaleAusgabe0(drv.digitaleEingabe0());
|
||||
}
|
||||
}*/
|
||||
|
||||
uint16_t ba[1024];
|
||||
uint16_t bb[1024];
|
||||
drv.analogEingabeSequenz(1, &ba[0], 0, 0, &bb[0], 0, 1023, -1, 1023);
|
||||
|
||||
PlottyFile pf;
|
||||
pf.setUnitX("t");
|
||||
pf.setUnitY("V");
|
||||
pf.setDescX("Zeit");
|
||||
pf.setDescY("Spannung");
|
||||
|
||||
for(uint16_t i = 0; i < 1023; i++)
|
||||
{
|
||||
pf.addDot(Dot(i,i, 0));
|
||||
pf.addDot(Dot(i,i/2, 1));
|
||||
}
|
||||
pf.writeToFile("test_plot");
|
||||
kennlinieZweiterQuadrant();
|
||||
|
||||
// speichern und plotty starten
|
||||
pf.writeToFile("test_plot");
|
||||
int code = system("./plotty --in test_plot");
|
||||
if(code)
|
||||
{
|
||||
std::cout << "plotty konnte nicht gestarted werden" << std::endl;
|
||||
}
|
||||
std::cout << "Fehler beim plotty Aufruf" << std::endl;
|
||||
|
||||
std::cout << "Schluss." << std::endl;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue