User Tools

Site Tools


tools:logger_cs:start

This is an old revision of the document!


Logging Signals in the Control System

Usually the control system runs with a rather high frequency, that is, its period is low. If you want to log signals in the control system it is advisable to use a much lower frequency in order not to clog the output stream. This can be accomplished by defining a periodic function with the desired frequency and add it to the executor.

  Lambda l1 ([&] () { });
  Periodic perLog("periodic log", 1, l1);
  perLog.monitors.push_back([&](PeriodicCounter &pc, Logger &log){
    log.info() << controlSystem.myBlock.getOut().getSignal();
  });
 
  // and further down the code
  executor.add(perLog);

This will output the output of a chosen block once per second. The lambda function is necessary so that the periodic task knows what to do, though it actually does nothing, as the function is empty.
For more complete examples see examples/controlsystem/BlockTest2 and examples/controlsystem/BlockTest3.

One must keep in mind that the periodic task which runs the control system and the periodic task which does the logging are actually running in parallel. This might lead to complication as soon as more complex signals are involved. For this reason, it might be preferable to choose the following solution.

  TimeDomain td("time domain CS", 0.001, true);  // this is the time domain for the control system running with 1kHz
  Periodic perCS("periodic CS", 0.001, td);  // this is the periodic task running the time domain
  executor.add(perCS);  // add the control system task to the executor.
  perCS.after.push_back(perLog);  // add the logging task to the task list running after the control system task

Now, the logging will be done after the control system task has finished running.

tools/logger_cs/start.1493149731.txt.gz · Last modified: 2017/04/25 21:48 (external edit)