THE LEE COMPANY AN055 Smart Pump Module User Guide

June 22, 2024
THE LEE COMPANY

THE LEE-LOGO THE LEE COMPANY AN055 Smart Pump Module

THE LEE-COMPANY-AN055-Smart-Pump-Module-PRODUCT

Product Information
Specifications:

  • Product Name: Smart Pump Module (SPM)
  • Control Options: UART or I2C
  • Maximum Voltage: 48Vr.m.s.
  • Frequency Range: 20-22 kHz

Product Usage Instructions
Example Sketch for Controlling Power and Pressure:

Utilize the example sketch provided in the manual to understand how to control power and pressure using the SPM.

Frequently Asked Questions (FAQ):
Q: Can I control multiple SPMs with one microcontroller?
A: Yes, the I2C protocol allows multiple devices to be connected to the same bus, enabling control of multiple SPMs from one microcontroller.

 INTRODUCTION

. About this Technical Guide
The Smart Pump Module (SPM) can be controlled with either UART or I2C. The I2C communications protocol allows multiple devices to be connected to the same bus. This could enable controlling multiple SPMs from one microcontroller or connecting an SPM and an external sensor.
This guide shows how to use an Arduino Uno to control an SPM over I2C and consists of the following stages:

  • Connecting the Arduino Uno to the SPM
  • Full list of commands
  • Example sketch for controlling power and pressure

DISCLAIMER

This resource is provided “as is” and without any warranty of any kind, and its use is at your own risk. The Lee Company does not warrant the performance or results that you may obtain by using this resource. The Lee Company makes no warranties regarding this resource, express or implied, including as to non-infringement, merchantability, or fitness for any particular purpose. To the maximum extent permitted by law The Lee Company disclaims liability for any loss or damage resulting from use of this resource, whether arising under contract, tort (including negligence), strict liability, or otherwise, and whether direct, consequential, indirect, or otherwise, even if The Lee Company has been advised of the possibility of such damages, or for any claim from any third party.

HEALTH AND SAFETY

WARNING
The Disc Pump Driver PCB Voltage must not exceed 48Vr.m.s. (where for a typical square-wave drive Vr.m.s. ≈ Vpk) at frequencies between 20 and 22 kHz. It is the user’s responsibility to ensure that the Disc Pump Driver PCB is used and/or integrated within any product in a safe manner. Read the user manual prior to first operation and take note of all safety notices.

WARNING
Take care during use of the Disc Pump Drive PCB not to create short circuits between exposed conductive parts of the board. Short circuits may lead to malfunctioning and heating.

CONNECTION THE MICROCONTROLLER TO THE SPM

General wiring diagram

Connect the following:

  • SPM pin 1 (VCC) – 5V supply (Red)
  • SPM pin 2 (I2C SDA) – Microcontroller SDA pin (Purple)
  • SPM pin 3 (I2C SCL) – Microcontroller SCL pin (Light blue)
  • SPM pin 4 (GND) – GND (Black)
  • SPM pin 5 (Analog in) – Not connected
  • 10kOhm pull-up resistors to 3.3/5V on both the SDA and SCL lines. I2C operates on open drain and requires these pull-up resistors.

Connecting an Arduino Uno to the SPM

THE LEE-COMPANY-AN055-Smart-Pump-Module- \(4\)

Connect the following:

  • SPM pin 1 (VCC) – Arduino 5V pin (Red)
  • SPM pin 2 (I2C SDA) – Arduino SDA pin (Purple)
  • SPM pin 3 (I2C SCL) – Arduino SCL pin (Light blue)
  • SPM pin 4 (GND) – Arduino GND pin (Black)
  • SPM pin 5 (Analog in) – Not connected (Green)
  • Pull-up resistors to 5V on both the SDA and SCL lines. I2C operates on open drain and requires these pull-up resistors.

FULL LIST OF COMMANDS

For an up-to-date list of commands, I2C message structure, I2C clock speed and pull-up resistor values, please consult “TG003: Serial PCB Communications Guide”. The guide also includes which commands need to be int and which ones should be float.

EXAMPLE SKETCH FOR CONTROLLING POWER AND PRESSURE

The most up-to-date version of the following code example is available on the Lee Ventus GitHub repository https://github.com/the-lee-company
The functions for sending and receiving I2C commands and the functions for setting up manual power control and PID pressure control can be found in:

  • include “lee_ventus_spm_i2c.h”

  • The macros for register IDs and default SPM I2C address can be found in:
  • include “lee_ventus_register.h”

Sending and receiving I2C commands

Sending integer command

  • //command to write an integer value to the SPM
  • //returns if the write was successful or not
  • bool spm_i2c_write_int16(int i2c_address, int register_id, int16_t
  • value_to_write)
  • {
  • int response;
  • uint8_t *ptrToInt;
  • ptrToInt = (uint8_t *)&value_to_write; //split the value into MSB and LSB
  • Wire.beginTransmission(i2c_address); //start write process- send address
  • Wire.write(register_id); // send register ID byte
  • Wire.write(ptrToInt[0]); // LSByte of int16_t
  • Wire.write(ptrToInt[1]); // MSByte of int16_t
  • response = Wire.endTransmission();
  • if (response != 0) {
  • Serial.println(“Error during write to spm”);//error report
  • return false;
  • }
  • return true;

Sending float command

  • //command to write a float value to the SPM
  • //returns if the write was successful or not
  • bool spm_i2c_write_float(int i2c_address, int register_id, float value_to_write)
  • {
  • int response;
  • uint8_t *ptrToFloat;
  • ptrToFloat = (uint8_t *)&value_to_write;//split the value into 4 bytes
  • Wire.beginTransmission(i2c_address); //start write process- send address
  • Wire.write(register_id); // send register ID byte
  • Wire.write(ptrToFloat[0]); // send LSByte of int16_t
  • Wire.write(ptrToFloat[1]); // send 2nd LSByte of int16_t
  • Wire.write(ptrToFloat[2]); // send 3rd LSByte of int16_t
  • Wire.write(ptrToFloat[3]); // send MSByte of int16_t
  • response = Wire.endTransmission();
  • if (response != 0) {
  • Serial.println(“Error during write to spm”);//error report
  • return false;
  • }
  • return true;
  • }
  • 6.2.2. Receiving integer command
  • //command to read a float value to the SPM
  • //returns -32,768 if there is an error
  • int16_t spm_i2c_read_int16(int i2c_address, int register_id)
  • {
  • //write the request to the SPM to report value (See SPM comms guide)
  • int response;
  • Wire.beginTransmission(i2c_address);//start write process- send address
  • Wire.write(128 + register_id); //Register ID byte (+128 to set the MSB to 1
  • per SPM Comms guide)
  • response = Wire.endTransmission();
  • if (response != 0)
  • {
  • Serial.println(“Error 1 during read from spm”);
  • return -32768;
  • }
  • Wire.requestFrom(i2c_address, 2);//request 2 bytes of data encoding the
  • response from the SPM
  • if (Wire.available() < 2)
  • {
  • Serial.println(“Error while reading SPM measurement”);//error report
  • return -32768;
  • }
  • int16_t value;
  • byte byteArray[2];
  • for(int i = 0; i < 2; i++)//read the two bytes
  • {
  • byteArray[i] = Wire.read();
  • }
  • //construct the int16_t value from the two bytes
  • uint8_t *ptrToInt;
  • ptrToInt = (uint8_t *)&value;
  • ptrToInt[0] = byteArray[0];
  • ptrToInt[1] = byteArray[1];
  • return value;
  • }
  • 6.2.3. Receiving float command
  • //command to read an integer value to the SPM
  • //returns -32,768 if there is an error
  • float spm_i2c_read_float(int i2c_address, int register_id)
  • {
  • //write the request to the SPM to report value (See SPM comms guide)
  • int response;
  • Wire.beginTransmission(i2c_address);
  • Wire.write(128 + register_id); //Register ID byte (+128 to set the MSB to 1
  • per Comms guide)
  • response = Wire.end Transmission();
  • if (response != 0)
  • Serial.println(“Error 1 during read from spm”);//error report
  • return -32768.0;
  • }
  • Wire.requestFrom(i2c_address, 4);//request 4 bytes of data encoding the
  • measurement
  • if (Wire.available() < 4)
  • {
  • Serial.println(“Error while reading SPM measurement”);//error report
  • return -32768.0;
  • }
  • float value;
  • byte byteArray[4];
  • for(int i = 0; i < 4; i++)//save the 4 bytes into an array
  • {
  • byteArray[i] = Wire.read();
  • }
  • //convert the bytes into a float and return
  • uint8_t *ptrToFloat;
  • ptrToFloat = (uint8_t *)&value;
  • ptrToFloat[0] = byteArray[0];
  • ptrToFloat[1] = byteArray[1];
  • ptrToFloat[2] = byteArray[2];
  • ptrToFloat[3] = byteArray[3];
  • return value;
  • }

Manual power control example

  • include <Arduino.h>

  • include <Wire.h> // Arduino library for I2C

  • include “lee_ventus_spm_i2c.h”

  • include “lee_ventus_register.h”

  • // example function to set the SPM settings to do manual power control
  • // use register REGISTER_PUMP_ENABLE to enable the pump
  • // use register REGISTER_SET_VAL to set the pump power (<1000mW)
  • void spm_i2c_setup_manual_power_control(int i2c_address)
  • {
  • //pump off
  • spm_i2c_write_int16(i2c_address, REGISTER_PUMP_ENABLE,0);
  • //streaming off
  • spm_i2c_write_int16(i2c_address, REGISTER_STREAM_MODE_ENABLE,0);
  • //manual mode
  • spm_i2c_write_int16(i2c_address, REGISTER_CONTROL_MODE,MODE_MANUAL);
  • //target power source (0 = set val register 23)
  • spm_i2c_write_int16(i2c_address, REGISTER_MANUAL_MODE_SETPOINT_SOURCE
  • ,SOURCE_SETVAL);
  • //register 23 (power target). Set to zero initially
  • spm_i2c_write_float(i2c_address, REGISTER_SET_VAL,0); }
  • void setup()
  • {
  • Serial.begin(9600); //initialize serial communication
  • Serial.println(“SPM I2C demo”);
  • Wire.begin(); // join i2c bus (address optional for master)
  • }
  • void loop()
  • {
  • // —————————————————————————
  • // Manual control example
  • // —————————————————————————
  • Serial.print(“\n\nMANUAL POWER CONTROL”);
  • //set to manual power control
  • spm_i2c_setup_manual_power_control(SPM_DEFAULT_I2C_ADDRESS);
  • //and enable pump
  • spm_i2c_write_int16(SPM_DEFAULT_I2C_ADDRESS, REGISTER_PUMP_ENABLE, 1);
  • //cycle through different power levels
  • for (int target_power = 100; target_power <= 1000; target_power += 100)
  • {
  • spm_i2c_write_float(SPM_DEFAULT_I2C_ADDRESS, REGISTER_SET_VAL, target_power);
  • delay(100);
  • Serial.print(“\nTarget power: “);
  • Serial.print(target_power);
  • Serial.print(“mW”);
  • //read the power level and pressure
  • for(int j=0; j<4; j++)
  • {
  • float measured_power, measured_pressure;
  • measured_power = spm_i2c_read_float(SPM_DEFAULT_I2C_ADDRESS,
  • REGISTER_MEAS_DRIVE_MILLIWATTS);
  • measured_pressure = spm_i2c_read_float(SPM_DEFAULT_I2C_ADDRESS,
  • REGISTER_MEAS_DIGITAL_PRESSURE);
  • Serial.print(“\nPower: “);
  • Serial.print(measured_power);
  • Serial.print(“mW, “);
  • Serial.print(“Pressure: “);
  • Serial.print(measured_pressure);
  • Serial.print(“mbar”);
  • delay(500);
  • }
  • }
  • //disable pump
  • spm_i2c_write_int16(SPM_DEFAULT_I2C_ADDRESS, REGISTER_PUMP_ENABLE, 0);
  • }

The Arduino IDE Serial Monitor output of the program should look like:

PID pressure control example

  • include <Arduino.h>

  • include <Wire.h> // Arduino library for I2C

  • include “lee_ventus_spm_i2c.h”

  • include “lee_ventus_register.h”

  • // example function to set the SPM settings to do PID pressure control

  • // use register REGISTER_PUMP_ENABLE to enable the pump

  • // use register REGISTER_SET_VAL to set the target pressure

  • void spm_i2c_setup_PID_pressure_control(int i2c_address)

  • {

  • //pump off

  • spm_i2c_write_int16(i2c_address, REGISTER_PUMP_ENABLE,0);

  • //streaming off

  • spm_i2c_write_int16(i2c_address, REGISTER_STREAM_MODE_ENABLE,0); /

  • /PID mode

  • spm_i2c_write_int16(i2c_address, REGISTER_CONTROL_MODE ,MODE_PID);

  • //PID setpoint source (0=Set val (register 23), 1=Analog A, 2=Analog B, 3=

  • Analog C

  • spm_i2c_write_int16(i2c_address, REGISTER_PID_MODE_SETPOINT_SOURCE

  • ,SOURCE_SETVAL);

  • //PID measurement source (0=Set val (register 23), 1=Analog A 2=Analog B, 3=

  • Analog C, 4=Flow sensor, 5= digital pressure sensor

  • spm_i2c_write_int16(i2c_address, REGISTER_PID_MODE_MEAS_SOURCE

  • ,SOURCE_DIGITAL_PRESSURE);

  • //PID ‘P=5’

  • spm_i2c_write_float(i2c_address, REGISTER_PID_PROPORTIONAL_COEFF,5); /

  • /PID ‘I=10’

  • spm_i2c_write_float(i2c_address, REGISTER_PID_INTEGRAL_COEFF,10);

  • //PID ‘D=0’ Advisable to keep this at zero

  • spm_i2c_write_float(i2c_address, REGISTER_PID_DIFFERENTIAL_COEFF,0); /

  • / register 23 (PID target). Set to zero initially

  • spm_i2c_write_float(i2c_address, REGISTER_SET_VAL,0);

  • }

  • void setup()
    {

  • Serial.begin(9600); //initialize serial communication

  • Serial.println(“SPM I2C demo”);

  • Wire.begin(); // join i2c bus (address optional for master)

  • }

  • void loop()

  • {

  • // —————————————————————————

  • // PID pressure control example

  • // —————————————————————————

  • Serial.print(“\n\nPID PRESSURE CONTROL”);

  • Serial.print(“\nWaiting for pressure in the system to die down…”);

  • delay(5000); // wait for the pressure in the system to die down

  • //set to PID pressure control

  • spm_i2c_setup_PID_pressure_control(SPM_DEFAULT_I2C_ADDRESS);

  • //and enable pump

  • spm_i2c_write_int16(SPM_DEFAULT_I2C_ADDRESS, REGISTER_PUMP_ENABLE, 1);

  • //cycle through different pressure levels

  • for (int target_pressure = 100; target_pressure <= 250; target_pressure += 50)

  • {

  • spm_i2c_write_float(SPM_DEFAULT_I2C_ADDRESS, REGISTER_SET_VAL,

  • target_pressure);

  • delay(100);

  • Serial.print(“\nTarget pressure: “);

  • Serial.print(target_pressure);

  • Serial.print(“mbar”);

  • //read the power level and pressure

  • for(int j=0; j<10; j++)

  • {

  • float measured_power, measured_pressure;

  • measured_power = spm_i2c_read_float(SPM_DEFAULT_I2C_ADDRESS,

  • REGISTER_MEAS_DRIVE_MILLIWATTS);

  • measured_pressure = spm_i2c_read_float(SPM_DEFAULT_I2C_ADDRESS,

  • REGISTER_MEAS_DIGITAL_PRESSURE);

  • Serial.print(“\nPower: “);

  • Serial.print(measured_power)

  • Serial.print(“mW, “);

  • Serial.print(“Pressure: “);

  • Serial.print(measured_pressure);

  • Serial.print(“mbar”);

  • delay(500);

  • }

  • }

  • //disable pump

  • spm_i2c_write_int16(SPM_DEFAULT_I2C_ADDRESS, REGISTER_PUMP_ENABLE, 0);

  • }

The Arduino IDE Serial Monitor output of the program should look like:

ADDITIONAL SUPPORT

The Lee Company Website  http://www.theleeco.com/discpumps  provides advice on:

  • Getting Started
  • Applications
  • Development Process
  • Downloads (including datasheets, application notes, case studies and 3D models)
  • Frequently Asked Questions

The Lee Company is happy to discuss next steps beyond prototyping, including system design. If you would like to discuss this with us, or for any other additional support, please contact your Lee Sales Engineer.

REVISION HISTORY

Date Version Change
04/06/24 R240604 Reformat
30/03/2023 r230330 Added general wiring diagram
03/02/2023 r230207 Document created.

References

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

THE LEE COMPANY User Manuals

Related Manuals