Home / microfluidic application note / Setup: microfluidic flow control / Elveflow SDK Tutorial Part 1: Setting Up Your Environment on the OB1
Microfluidics application note

Elveflow SDK Tutorial Part 1: Setting Up Your Environment

The purpose of this Jupyter Notebook is to work as a quick guide to the SDK development with the Elveflow products. The process is shown using a OB1 Pressure Controller with a FS5D Flow Sensor, but it works also for any other Elvesys product.

Before starting with this introduction, make sure you have read all the documentation related to your purchased products. Disregarding that information could increase the risk of damage to the equipment, or the risk of personal injuries. In case you don’t have a copy, you can download all the documents from our website.

The content of this chapter of the tutorial is the following:

  1. System setup
  2. SDK files
  3. Instrument configuration
  4. Sensor addition
  5. System calibration
  6. Main execution routine

1.1 Installation

1.1.1 Tested system

This tutorial has been written and tested using Windows 10, 64bits, Python 3.8.8, Jupyter Notebook 6.3.0 in October, 2021. The pressure controller is an OB1 MK3+ and the flow sensor a FS5D.

1.1.2 SDK Files

1.2 System Test

1.2.1 Instrument configuration

Once the SDK has been correctly installed, it is also necessary to configure it to work with the desired system. If you previously installed the ESI, an application called NI MAX should have been installed as well. It is needed to check the exact name of the device.

How? First, connect your device to the power supply, connect its USB cable to the computer you are using and turn it on. After that, go to Windows search bar and type ‘NI MAX’ without the quotes. It should appear as the first result as you can see in the following figure:

nimax

Then, just unzip the left tabs: ‘My System > Devices and Interfaces > …’ like you can see as follows.

nimax2

If you don’t have more National Instrument’s devices connected to your computer, the only result should be the OB1 Pressure Controller (or the one that you try to configure). Click on it and write down its Serial Number. You will need it for your custom software to interact with the device. In this example, the device Serial Number is 01BECD3F.

The next step is to know the arrangement of pressure regulators that your system has, because our OB1 can be customized to have the right pressure setup for the client. In order to identify them, you can check it on the OB1 User guide, at the installation chapter.

Each regulator value has a different encoding value. The correspondance is the following:

I am raw html block.
Click edit button to change this html

Regulator Types Table
Regulator type (by range) Code
Non-installed 0
(0, 200) mbar 1
(0, 2000) mbar 2
(0, 8000) mbar 3
(-1000, 1000) mbar 4
(-1000, 6000) mbar 5
#
# Initialization of OB1 ( ! ! ! REMEMBER TO USE .encode('ascii') ! ! ! )
#
Instr_ID = c_int32()
print("Instrument name and regulator types are hardcoded in the Python script")

# See User Guide to determine regulator types and NIMAX to determine the instrument name 
# error = OB1_Initialization('01BECD3F'.encode('ascii'),3,2,0,0,byref(Instr_ID)) 
error = OB1_Initialization('01CF6A61'.encode('ascii'),2,3,4,4,byref(Instr_ID)) 

# All functions will return error codes to help you to debug your code, for further information refer to User Guide
print('error:%d' % error)
print("OB1 ID: %d" % Instr_ID.value)
Sensor Types Table
Sensor type Code Sensor type Code
None 0 Press 340 mbar 8
Flow 1-5 muL/min 1 Press 1 bar 9
Flow 7 muL/min 2 Press 2 bar 10
Flow 50 muL/min 3 Press 7 bar 11
Flow 80 muL/min 4 Press 16 bar 12
Flow 1000 muL/min 5 Level 13
Flow 5000 muL/min 6 Custom 14
Press 70 mbar 7

Note. Level sensor type stands for all types of level sensor such as bubble detector.

The following is the encoding of the possible resolution bits:

Resolution Codes Table
Resolution Code Resolution Code
9 bits 0 13 bits 4
10 bits 1 14 bits 5
11 bits 2 15 bits 6
12 bits 3 16 bits 7
# Add one digital flow sensor with water calibration (OB1 MK3+ only), all information to declare sensors are described in the User Guide
# error = OB1_Add_Sens(Instr_ID, 2, 4, 1, 0, 7, 0)
# (CustomSens_Voltage_5_to_25 only works with CustomSensors and OB1 from 2020 and after)

# To test the pressure sensors
error=OB1_Add_Sens(Instr_ID, 1, 10, 0, 0, 7, 0)
error=OB1_Add_Sens(Instr_ID, 2, 10, 0, 0, 7, 0)
error=OB1_Add_Sens(Instr_ID, 3, 10, 0, 0, 7, 0)
print('error add digit flow sensor:%d' % error)

1.1.4 System calibration

Here you can choose, essentially, one of the three available options: default, load and new. The calibration consists of an array which stores the actual values associated to your instrument.

If you previously proceeded with a calibration process, you can load it from the Calib_path that you must previously specify. Otherwise, if you want to run a calibration process, ensure that ALL channels are properly closed with adequate caps. You can find more detailed instructions about the calibration procedure at the OB1 User Guide.

Calib = (c_double*1000)() # Always define array this way, calibration should have 1000 elements

while True:
    answer = input('select calibration type (default, load, new ) : ')
    Calib_path = 'C:\\Users\\Public\\Desktop\\Calibration\\Calib.txt'
    if answer == 'default':
        error = Elveflow_Calibration_Default (byref(Calib),1000)
        break
        
    if answer == 'load':
        error = Elveflow_Calibration_Load (Calib_path.encode('ascii'), byref(Calib), 1000)
        break
        
    if answer == 'new':
        OB1_Calib (Instr_ID.value, Calib, 1000)
        error = Elveflow_Calibration_Save(Calib_path.encode('ascii'), byref(Calib), 1000)
        print('Calib saved in %s' % Calib_path.encode('ascii'))
        break
Command Functions Table
Command Function Description
set_p OB1_Set_Press() Manually set a pressure at a desired channel.
get_p OB1_Get_Press() Manually get the pressure reading from a desired channel.
get_sens OB1_Get_Sens_Data() Manually get the value of any sensor.
exit None Exit the main loop.
while True:
    answer=input('what to do (set_p, get_p, get_sens, or exit) : ')
    if answer=='set_p':
        set_channel=input("select channel(1-4) : ")
        set_channel=int(set_channel) # convert to int
        set_channel=c_int32(set_channel) # convert to c_int32
        set_pressure=input("select pressure (-1000 to 8000 mbars) : ")
        set_pressure=float(set_pressure) 
        set_pressure=c_double(set_pressure) # convert to c_double
        error=OB1_Set_Press(Instr_ID.value, set_channel, set_pressure, byref(Calib),1000) 
        
    if answer=="get_sens":
        data_sens=c_double()
        set_channel=input("select channel(1-4) : ")
        set_channel=int(set_channel) # convert to int
        set_channel=c_int32(set_channel) # convert to c_int32
        error=OB1_Get_Sens_Data(Instr_ID.value,set_channel, 1,byref(data_sens)) # Acquire_data=1 -> read all the analog values
        print('Press or Flow ch', set_channel.value,': ',data_sens.value)
    
    if answer=='get_p':
        set_channel=input("select channel(1-4) : ")
        set_channel=c_int32( int(set_channel) ) # convert to c_int32
        get_pressure=c_double()
        error=OB1_Get_Press(Instr_ID.value, set_channel, 1, byref(Calib),byref(get_pressure), 1000) # Acquire_data=1 -> read all the analog values
        print('error: ', error)
        print('ch',set_channel,': ',get_pressure.value)

    print( 'error :', error)
    
    if answer=='exit':
        break
what to do (set_p, get_p, get_sens, or exit) : set_p
select channel(1-4) : 1
select pressure (-1000 to 8000 mbars) : 300
error : 0
what to do (set_p, get_p, get_sens, or exit) : get_sens
select channel(1-4) : 2
Press or Flow ch 2 :  123.98571679255377
error : 0
what to do (set_p, get_p, get_sens, or exit) : get_sens
select channel(1-4) : 1
Press or Flow ch 1 :  255.49368963149433
error : 0
what to do (set_p, get_p, get_sens, or exit) : get_sens
select channel(1-4) : 3
Press or Flow ch 3 :  -24.7761020828564
error : 0
what to do (set_p, get_p, get_sens, or exit) : set_p
select channel(1-4) : 1
select pressure (-1000 to 8000 mbars) : 0
error : 0
what to do (set_p, get_p, get_sens, or exit) : exit
error : 0

The output can be something like the following:

what to do (set_p, get_p, get_sens, or exit) : get_sens
select channel(1-4) : 2
Press or Flow ch 2 :  4.724137931034483
what to do (set_p, get_p, get_sens, or exit) : exit
error : 0
Want to run a similar experiment? Feel free to contact us at: contact@elveflow.com
Elveflow team at work

    How can we help you?




    We will answer within 24 hours

    By filling in your info you accept that we use your data.

    Contact
    How can we help you?
    Quoteor technical request Job application Job
    application
    Collaboration or partnerships Collaborations
    or partnerships
    Customer support Customer
    support
    Others questions Other

      Get a quote




      We will answer within 24 hours

      By filling in your info you accept that we use your data.

      Contacting for
      a job application?
      We are happy that you are interested in Elveflow. You can apply to our open jobs or send us your open application on WelcomeToTheJungle. Over here!

        Collaborations




        We will answer within 24 hours

        By filling in your info you accept that we use your data.

          Need customer support?







          I hereby agree that Elveflow uses my personal data

          We will answer within 24 hours

            How can we help you?




            We will answer within 24 hours

            By filling in your info you accept that we use your data.