MatLab Integration
Overview:
Matlab-VOLTTRON integration allows Matlab applications to receive data from devices and send control commands to change points on those devices.
DrivenMatlabAgent in VOLTTRON allows this interaction by using ZeroMQ sockets to communicate with the Matlab application.
Data Flow Architecture:
Installation steps for system running Matlab:
Install python. Suggested 3.6.
Install pyzmq (tested with version 15.2.0) Follow steps at: https://github.com/zeromq/pyzmq
Install Matlab (tested with R2015b)
Start Matlab and set the python path. In the Matlab command window set the python path with pyversion:
>> pyversion python.exe
To test that the python path has been set correctly type following in the Matlab command window. Matlab shoud print the python path with version information.
>> pyversion
To test that the pyzmq library is installed correctly and is accessible from python inside Matlab, type the following in Matlab command window and it should show pyzmq version installed.
>> py.zmq.pyzmq_version()
Copy example.m from volttron/examples/ExampleMatlabApplication/matlab to your desired folder.
Run and test Matlab VOLTTRON Integration:
Assumptions
Device driver agent is already developed
Installation:
Install VOLTTRON on a VM or different system than the one running Matlab.
Add subtree volttron-applications under volttron/applications by using the following command:
git subtree add --prefix applications https://github.com/VOLTTRON/volttron-applications.git develop --squash
Configuration
Copy example configuration file applications/pnnl/DrivenMatlabAgent/config_waterheater to volltron/config.
Change config_url and data_url in the new config file to the ipaddress of machine running Matlab. Keep the same port numbers.
Change campus, building and unit (device) name in the config file.
Open example.m and change following line:
matlab_result = '{"commands":{"Zone1":[["temperature",27]],"Zone2":[["temperature",28]]}}';
Change it to include correct device name and point names in the format:
'{"commands":{"device1":[["point1",value1]],"device2":[["point2",value2]]}}';
Steps to test integration:
Start VOLTTRON
Run Actuator
Run device driver agent
Run DrivenMatlabAgent with the new config file
Run example.m in Matlab
Now whenever the device driver publishes the state of devices listed in the config file of DrivenMatlabAgent, DrivenMatlabAgent will send it to Matlab application and receive commands to send to devices.
Resources
http://www.mathworks.com/help/matlab/getting-started_buik_wp-3.html