Using Cbmex on OSX

Note: This method of using cbMEX is not officially supported by Blackrock Microsystems, but it is put here for reference.

This article covers the method for allowing cbmex, our online Matlab interface, to function on OSX operating systems. For more information on cbmex and our Matlab libraries, please refer to the user manuals section of our website.

On the OSX computer, configure the instrument port to the following address:
IP: (the last number here can be anything between 1-16 not already on the network)

Attached to this article is a .zip file that contains the necessary files and libraries for cbmex to work on OSX. Instructions for use of these files can be found below.

Inside the zipped file you will find three files.


The first one is the mex file that is cbmex that we will be using to interface with the NSP. The other two are libraries that we want Matlab to correctly use. There is a good chance that Matlab will be referring to the wrong location to look for these file, the following instructions will outline how to place them where Matlab can find them.

From finder, navigate to the following folder:


Place both QtCore and QtXml into this folder. They should not be in there initially, so you will not need to overwrite anything, but you will need administrator access (PS: MacOS 10.11+ has SIP protecting lib folder. You can disable the SIP by following this instruction). Once these are placed, you should be able to attempt to open cbmex by first placing it in the Matlab path and then attempting cbmex('open'). At this point one would get memory errors because Mac allows much less memory in these spaces than Windows; the best way to adjust these is in terminal. Open up terminal and type the following commands:

sudo sysctl -w kern.sysv.shmmax=33554432
sudo sysctl -w kern.sysv.shmall=4194304

Attempt to change max.sockbuf:

sudo sysctl -w kern.ipc.maxsockbuf=8388608

At this point, cbmex should be ready to open. Go to Matlab and use the following command:

cbmex('open','receive-buffer-size',6291456,'inst-addr', '', 'inst-port', 51001, 'central-addr', '', 'central-port', 51002)

This is the open command of cbmex, and after you have opened the interface, all other commands can be used normally.