RPI Interface for project.controller
This is the interfacing library for the controller implemented in the project.controller repository. The interface is in C, for RaspberryPI using the wiringPI library.
Installation
Dependencies
sudo apt install build-essential git-core ruby ruby-ffi
- wiringPi (follow installation instruction from the project page)
Compile
make shared
Communication object
The Ruby Object SerialComm
allows a very simple communication with the device. When the object is created, it connects to the serial port specified as argument:
sc = SerialComm.new("/dev/ttyACM0")
the port is automatically closed when the GC frees the memory. The current information must be requested to the remote device with the sc.update()
method, and it will require some time to receive all the information (at least two loops of the controller, meaning 60ms).
The write operations are:
sc.t_set = 0.0
: temperature set pointsc.p_high = 0.0
: pressure top valuesc.p_low = 0.0
: pressure bottom pointsc.PI_kp = 0.0
: pressure PI control proportional gainsc.PI_ki = 0.0
: pressure PI control integrative gainsc.p_set = 0.0
: pressure current set pointsc.period = 0.0
: square wave pressure periodsc.duty_cycle = 0.0
: square wave pressure duty cyclesc.cycle = 0.0
: number of cycle performedsc.cycle_max = 0.0
: maximum number of cycle to performsc.toggle_chiller
: chiller toggle enabling bit for temperature controlsc.toggle_resistance
: resistance toggle enabling bit for temperature controlsc.toggle_actuator
: actuator toggle enabling bit for pressure control
The read operations are (as floating point values):
sc.t_meas
current measured temperaturesc.p_actuator_meas
: measured actuator pressurep_accumulator_meas
: measured accumulator pressurePI_kp
: current pressure controller proportional gainPI_ki
: current pressure controller integrative gaint_set
: current temeprature set pointp_set
: current pressure set pointu_pres
: current input from PI for pressureduty_cycle
: current duty cycle valuesc.cycle
: number of cycle performedsc.cycle_max
: maximum number of cycle to perform
(as boolean values)
sc.chiller
: chiller enabled for temperature controlsc.resistance
: resistance enabled for temperature controlsc.actuator
: actuator enabled for pressure control
(as code symbol)
sc.state
: execution state of the controllersc.error
: error code of the controller (error string insc.error_string
)
The EEPROM operations are
sc.save_config
: save configuration in the EEPROMsc.load_conf
: load configuration from the EEPROMsc.load_cycle
: load cycle value from the EEPROM (written automatically)
The Execution commands are:
sc.play
: run the cyclesc.pause
: pause the cyclesc.stop
: emergency stop
The example
The example main.rb
, with the SIL_SIM
option in the firmware, generates the following
output: