User Tools

Site Tools


for_developers:signal_probe_block

This is an old revision of the document!


Signal probe block

How the signal probe block works

How to implement the signalProbeBlock

To use the signalProbeBlock code has to be implemented at three different places. If the measurement should be stopped by a level change of the safety system, some lines of code have to be added to the safety system.

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:

...
 
eeros::control::DeMux<2,double> demux_SPB;
parallelscara::SignalProbeBlock<10, double, bufferSize> signalProbeDouble;
 
...

Connection with signals

The signalProbeBlock can be connected like every other block. If a vector signal should be probed, a DeMux block is needed.

In ControlSystem.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, "Robot Controller DAC 0");
signalProbeDouble.setName(1, "Robot Controller DAC 1");
 
...
 
// run the blocks
timedomain.addBlock(&demux_SPB);
timedomain.addBlock(&signalProbeDouble);

Write the buffered data to a file

When the application is terminated, the data has to be written to a file.

In Main.cpp

...
 
	std::cout << "start writing file 'signalProbePC.csv'" << std::endl;
	std::ofstream fileSPPC;
	fileSPPC.open("/tmp/signalProbePC.csv");
	fileSPPC << controlSystem.pendulumController.signalProbePC.getMetaInfoStr();
	fileSPPC << controlSystem.pendulumController.signalProbePC.getDataStr();
	fileSPPC.close();
	std::cout << "file 'signalProbePC' written" << std::endl;
 
	while(safetySystem.getCurrentLevel().getId() ==  off) usleep(100000);
	log.trace() << "SCARA Robot Control Application finished";
	return 0;
}

If the signalProbeBlock is contained in an other block, following lines can be used:

...
 
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 emergency is called.

In SafetyProporties.cpp:

...
 
	level(emergency).setLevelAction([this](SafetyContext* privateContext) { 
		static bool firstCall = true;
		if (firstCall) {
			firstCall = false;
			controlSys->signalProbeDouble.stopLogging(1000);	// nrOfMeasurementsAfterStop = 1'000
		}
	}
 
...

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,3.66,1.0,5.812,
1.1002,3.72,1.1002,5.92,

...
for_developers/signal_probe_block.1506260186.txt.gz · Last modified: 2017/09/24 15:36 by graf