The control interface is the main element and the “brain” of the hardware platform. This interface contains the RIP control algorithm (fuzzy-PD controller presented in the previous section), communicates with other interfaces via I2C serial bus and connects to PC via RS232 serial port for the process monitoring.
After the initialization of the I2C and RS232 serial communication modules in the Atmel microcontroller of the control interface is implemented a main loop which contains the following features:
-request and read data from the measurement interface containing the current values of the angular positions and velocities of the inverted pendulum and pivot arm;
- update the fuzzy controller parameters (scaling gains for the input and output variables of the fuzzy system) using the configuration panel and the internal analog-to-digital converters;
- calculating the current command using the fuzzy control algorithm;
- transfer command data message to the command interface for driving the RIP mechanical system;
- sending the data through the RS232 serial port to the monitor application implemented on the PC.
Including these features microcontroller takes approximately lO ms to execute the main loop of the program. Serial package received from the measurement interface via I2C bus contains four variables (integer data type) corresponding to the real process outputs. These are used to determine the inputs of the fuzzy controller and to monitor the process. The inputs are processed by fuzzy algorithm to determine the command signal. This command signal will represent the duty cycle of the PWM signal provided to the driver circuit and so the power supplied to the dc motor is controlled. The command signal is saturated to a maximum value of 8-bit (meaning the lOO% duty cycle of the PWM signal) and then is transmitted to the control interface in the command data message, which also contains the byte for the rotational direction of the DC motor.