b15f/control/examples/pegel/main.cpp

50 lines
1 KiB
C++
Raw Normal View History

2019-03-26 08:57:01 +00:00
#include <iostream>
2019-03-29 10:12:31 +00:00
#include <cmath>
2019-05-15 13:39:16 +00:00
#include <b15f/b15f.h>
#include <b15f/plottyfile.h>
2019-03-26 08:57:01 +00:00
2019-06-07 09:02:46 +00:00
/*
* Inkrementiert DAC 0 von 0 bis 1023 und speichert zu jeder Ausgabe den Wert von ADC 0 in einem Puffer.
* Die Funktion ADC 0 abhängig von DAC 0 wird als Graph geplottet.
*/
2019-05-16 09:03:49 +00:00
const char PLOT_FILE[] = "plot.bin";
2019-03-28 10:11:19 +00:00
2019-05-15 14:35:47 +00:00
int main()
2019-03-26 08:57:01 +00:00
{
2019-04-03 07:34:22 +00:00
2019-03-26 08:57:01 +00:00
B15F& drv = B15F::getInstance();
2019-03-29 07:32:11 +00:00
PlottyFile pf;
2019-03-27 09:33:16 +00:00
2019-05-22 08:32:51 +00:00
uint16_t buf[1024];
2019-03-28 10:11:19 +00:00
2019-05-23 13:08:54 +00:00
const uint16_t count = 1024;
2019-04-03 06:40:14 +00:00
const uint16_t delta = 1;
2019-05-23 13:08:54 +00:00
const uint16_t start = 0;
2019-03-28 10:11:19 +00:00
pf.setUnitX("V");
2019-05-15 14:35:47 +00:00
pf.setUnitY("V");
2019-03-28 10:11:19 +00:00
pf.setUnitPara("V");
2019-05-15 14:35:47 +00:00
pf.setDescX("U_{OUT}");
pf.setDescY("U_{IN}");
pf.setDescPara("");
2019-03-28 10:11:19 +00:00
pf.setRefX(5);
2019-05-15 14:35:47 +00:00
pf.setRefY(5);
pf.setParaFirstCurve(0);
pf.setParaStepWidth(0);
2019-03-28 10:11:19 +00:00
2019-05-23 13:08:54 +00:00
const uint8_t curve = 0;
2019-04-03 07:34:22 +00:00
2019-05-23 13:08:54 +00:00
drv.analogSequence(0, &buf[0], 0, 1, nullptr, 0, start, delta, count);
2019-05-15 14:35:47 +00:00
2019-05-23 13:08:54 +00:00
for(uint16_t x = 0; x < count; x++)
2019-05-15 14:35:47 +00:00
{
2019-05-22 08:32:51 +00:00
std::cout << x << " - " << buf[x] << std::endl;
pf.addDot(Dot(x, buf[x], curve));
2019-05-15 14:35:47 +00:00
}
2019-03-29 07:32:11 +00:00
// speichern und plotty starten
2019-05-23 13:08:54 +00:00
pf.writeToFile(PLOT_FILE);
2019-05-16 08:49:30 +00:00
pf.startPlotty(PLOT_FILE);
2019-03-28 10:11:19 +00:00
}