for_developers:signal_probe_block
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| for_developers:signal_probe_block [2016/08/15 15:53] – [The csv file] gehrig | for_developers:signal_probe_block [2017/09/24 15:36] (current) – removed graf | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Signal probe block ====== | ||
| - | ===== How the signal probe block works ===== | ||
| - | The // | ||
| - | |||
| - | The measurement stops when the application is terminated or it can be stopped, when a certain safety level is reached. At the end, the measurements are written in a file with a csv compatible format. | ||
| - | |||
| - | The measured data is written in a buffer in RAM because writing in a file would influence the real time performance of the system. | ||
| - | |||
| - | ===== How to implement the // | ||
| - | To use the // | ||
| - | |||
| - | ==== Declaration ==== | ||
| - | Because only single signals and not vectors can be connected to the block, a //DeMux// block is also used in this example. For each signal type a different block has to be declared. In this example a block for 10 float-signals is declared. | ||
| - | |||
| - | In ControlSystem.hpp: | ||
| - | <code cpp> | ||
| - | ... | ||
| - | |||
| - | eeros:: | ||
| - | parallelscara:: | ||
| - | |||
| - | ... | ||
| - | </ | ||
| - | |||
| - | ==== Connection with signals ==== | ||
| - | The // | ||
| - | |||
| - | In ControlSystem.cpp: | ||
| - | <code cpp> | ||
| - | .. | ||
| - | |||
| - | // connect the signal to the DeMux | ||
| - | demux_SPB.getIn().connect(robotController.get_dacOut()); | ||
| - | |||
| - | // connect the DeMux to the signalProbeBlock | ||
| - | signalProbeDouble.getIn(0).connect(demux_SPB.getOut(0)); | ||
| - | signalProbeDouble.getIn(1).connect(demux_SPB.getOut(1)); | ||
| - | |||
| - | // name the signals | ||
| - | signalProbeDouble.setName(0, | ||
| - | signalProbeDouble.setName(1, | ||
| - | |||
| - | ... | ||
| - | |||
| - | // run the blocks | ||
| - | timedomain.addBlock(& | ||
| - | timedomain.addBlock(& | ||
| - | </ | ||
| - | |||
| - | ==== Write the buffered data to a file ==== | ||
| - | When the application is terminated, the data has to be written to a file. | ||
| - | |||
| - | In Main.cpp | ||
| - | |||
| - | <code cpp> | ||
| - | ... | ||
| - | |||
| - | std::cout << "start writing file ' | ||
| - | std:: | ||
| - | fileSPPC.open("/ | ||
| - | fileSPPC << controlSystem.pendulumController.signalProbePC.getMetaInfoStr(); | ||
| - | fileSPPC << controlSystem.pendulumController.signalProbePC.getDataStr(); | ||
| - | fileSPPC.close(); | ||
| - | std::cout << "file ' | ||
| - | |||
| - | while(safetySystem.getCurrentLevel().getId() == off) usleep(100000); | ||
| - | log.trace() << "SCARA Robot Control Application finished"; | ||
| - | return 0; | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | If the // | ||
| - | <code cpp> | ||
| - | ... | ||
| - | |||
| - | fileSPPC << controlSystem.pendulumController.signalProbePC.getMetaInfoStr(); | ||
| - | fileSPPC << controlSystem.pendulumController.signalProbePC.getDataStr(); | ||
| - | |||
| - | ... | ||
| - | </ | ||
| - | |||
| - | ==== Stop measurement in case of a level change ==== | ||
| - | The measurement can be stopped, when a certain safety level is reached. This can be useful, to find a reason for a emergency stop. In this example 1'000 additional measuring points are safed, after the safety level // | ||
| - | |||
| - | In SafetyProporties.cpp: | ||
| - | <code cpp> | ||
| - | ... | ||
| - | |||
| - | level(emergency).setLevelAction([this](SafetyContext* privateContext) { | ||
| - | static bool firstCall = true; | ||
| - | if (firstCall) { | ||
| - | firstCall = false; | ||
| - | controlSys-> | ||
| - | } | ||
| - | } | ||
| - | |||
| - | ... | ||
| - | </ | ||
| - | |||
| - | ===== The csv file ===== | ||
| - | The csv file is saved in a style, which easily can be opened with Excel or Matlab. | ||
| - | |||
| - | This is an example for two signals: | ||
| - | < | ||
| - | TS: Signal 0,Value: Signal 0,TS: Signal 0,Value: Signal 0, | ||
| - | 1.0, | ||
| - | 1.1002, | ||
| - | |||
| - | ... | ||
| - | </ | ||
for_developers/signal_probe_block.1471269227.txt.gz · Last modified: 2016/08/15 15:53 (external edit)