Aversive/Modules/devices/control system

De Wikidroids


Control system generic architecture

The control_system module aims to provide a very generic and portable architecture for programming control loops. The whole control system is portable, because it is separated from the IO functions. It can be compiled as it is on nearly every architecture.

It's basic structure is very simple : a feedback loop with 3 filters : Asserv diagram.png

The process is an external value that is controlled (process_in) and measured (process_out) in order to attach the feedback loop.

The feedback loop is composed of 3 filters that are dynamically reconfigurable, and optionnal.


Here is the filter interface spec.

There are currently 3 available filters:

  • PID A generic PID loop filter
  • Ramp This generates a trapezoidal consign. Generally used in speed control loops.
  • Quadramp This generates a position profile respecting a given trapezoïdal speed profile.
  • Quadramp Derivate Same as above, but for a speed consign instead position
  • Biquad a generic RII & RIF filter.


struct  cs { 
	s32 (*consign_filter)(void *, s32); 
	void * consign_filter_params;
	s32 (*correct_filter)(void *, s32);
	void * correct_filter_params;

	s32 (*feedback_filter)(void *, s32);
	void * feedback_filter_params;

	s32 (*process_out)(void *);
	void * process_out_params;

	void (*process_in)(void *, s32);
	void * process_in_params;

	s32 consign_value;
	s32 error_value;
	s32 out_value;

This structure contains all the informations for a control loop to be able to work. The filters informations are contained separately, but are pointed by this structure.


The interface is simple but pwoerfull : it could accomodate two styles

  • all function call : use cs_manage() as call, and cs_set_consign() for the consign. This is tdeal for interfacing directly to the scheduler.
  • I/O done by passing arguments : use cs_do_process() as call

void cs_init(struct cs * cs) 

This initialises the structure. Here it is absolutely necessary to initialize properly, because of the function pointers contained ! Please note that a filter function pointer set to NULL bypasses this filter.

void cs_set_consign_filter(struct cs * cs, s32 (*consign_filter)(void *, s32), 
		void * consign_filter_params) 
void cs_set_correct_filter(struct cs * cs, s32 (*correct_filter)(void *, s32), 
		void * correct_filter_params) 
void cs_set_feedback_filter(struct cs * cs, s32 (*feedback_filter)(void *, s32), 
		void * feedback_filter_params) 
void cs_set_process_in(struct cs * cs, void (*process_in)(void *, s32), 
		void * process_in_params) 
void cs_set_process_out(struct cs * cs, s32 (*process_out)(void *), 
		void * process_out_params) 

Set filters and I/O functions.

s32 cs_do_process(struct cs * cs, s32 consign)

This function performs the loop control system. This function has to be called periodically. Performs following operations :

  • saves the current consign in the structure
  • applicatres the consign filter (if used)
  • reads process_out
  • filters the process_out
  • substracts the filtered process_out and the filtered consign >> error_value
  • applicates correction filter
  • gives output to process_in
  • saves output to structure
  • returns output value
void cs_manage(struct cs * cs) 

Same execution, but this one could be called by the scheduler (no inout by pasing values)

s32 cs_get_out(struct cs * cs) 
s32 cs_get_error(struct cs * cs) 
s32 cs_get_consign(struct cs * cs)

Getting the last values of the out, error, or consign

void cs_set_consign(struct cs * cs, s32 v) 

Sets a consign value witout calling the do_process

Boîte à outils