for_developers:signal_probe_block
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
for_developers:signal_probe_block [2017/09/24 15:36] – [How the signal probe block works] graf | 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 ===== | ||
- | |||
- | ===== How to implement the signalProbeBlock ===== | ||
- | 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, | ||
- | |||
- | ... | ||
- | </ |