element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
In Reach! – Ultrasonic Sensor Sensing Challenge
  • Challenges & Projects
  • Design Challenges
  • In Reach! – Ultrasonic Sensor Sensing Challenge
  • More
  • Cancel
In Reach! – Ultrasonic Sensor Sensing Challenge
Forum SwishMaster - #3 - Connecting USSM to Arduino
  • News
  • Forum
  • Projects
  • DC
  • Files
  • Members
  • More
  • Cancel
  • New
Join In Reach! – Ultrasonic Sensor Sensing Challenge to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 1 reply
  • Subscribers 40 subscribers
  • Views 51 views
  • Users 0 members are here
  • ultrasonic sensor
  • design challenge
  • SwishMaster
  • tdk
  • TDK waterproof sensors
  • Ultrasonic Sensor Sensing Challenge
  • In Reach
  • TDK USSM Plus-FM
  • TDK USSM1.0 PLUS-FS
Related

SwishMaster - #3 - Connecting USSM to Arduino

amgalbu
amgalbu 3 days ago

As I said in my previous post, the SwishMaster device will be based on an Arduino 33 BLE Sense, which connects to two USSMs by means of level shifters. The overall hardware architecture is shown in the following picture

image

However, after checking parts availability in my components shelf, I switched the an Arduino Nano 33 IoT

Connecting the USSM

As shown in the diagram above, I am going to use a level shifter to connect the USSM IO data line to the Arduino board. In particular, I chose a bidirectional level shifter converter made by Adafruit, which is made by four identical channels. Each channel features the following circuit

image

Here LV (low-voltage) side is connected to a IO on the Arduino board, and the HV (high voltage) side is connect to the USSM IO data line. Regarding the MOSFET pins, 

  • the gate (G) is tied to the LV power supply (in my case, 3.3V)
  • the source (S) is connected to the Arduino IO pin
  • the drain (D) is connected to the USSM IO data line

The principle of operation for thsi circuit is

  • when both sides (LV1 and HV1) are high, the voltage on the source is equal to the voltage on the gate, and the MOSFET is not conducting. Hence, HV1 is pulled-up to the voltage of the HV power supply
  • when LV1 is pulled-down, the MOSFET furms on because the voltage between gate and source is 3.3 V. The drain is pulled-down as well, so the low state is propagated to HV1
  • when HV1 is pulled-down, the MOSFET’s body diode (intrinsic diode between drain and source) conducts slightly, pulling the source (LV side) a little below 0.7 V. This drop causes the MOSFET to turn on, and the low state is propagated to LV1

According to Adafruit documentation, the maximum voltage on the HV side is 10V. This statement puzzles me, because the BSS138 states that the maximum drain-source voltage is 50 V. Anyway, just to be on the safe side, I will power the USSM with 10V, since such a voltage is still within the specifications.

Another problem with the breakout board is the 10K pullup resistor (or, at least, this is my explanation). This resistor is bit too strong and prevents the signal to get close to the ground when the sensor imposes a low state on the data line. This condition is shown in the following screenshots of the signals captured by the oscilloscope (red signal is the signal on the LV side, yellow is the signal on the HV side)

image

The signal from USSM is read correctly by Arduino, but, in my opinion, the voltage of the low state is too close to the threshold between low and high states. As a matter of fact, according to the Microchip SAMD21G18 datasheet, a low state is detected when voltage is below 0.99 V... 

The simplest solution is to remove or short-circuit the pull-up resistor on the breakout board and add an external pull-up resistor of maybe 15K or more. At the moment, I will keep on working without any changes because I fear damaging the board. I will make this change after I have a working prototype

Reading USSM data

To interface with the USSM, I will leverage the Arduino library provided by TDK and can be downloaded from this link.

You can install the library from the Arduino IDE by clicking Sketch -> Include library -> Add .ZIP library

image

Here is an example of usage of the library. In my case, I just need to measure distance in centimeter. The example TDK_USSM_multiple_cm implements exactly what I need for this project

#include <TDK_USSM.h>


//-- Sensors Pinmap Sensors
#define N_SENSORS 2
const int IoPins[N_SENSORS] = {14, 16}; // Trigger/Echo Pin of Ultrasonic Sensor

// Note: Echo Pins could be same as Trigger pin if a bidir level shifter is used.

TDK_USSM TdkUssm(IoPins, N_SENSORS); //Initialize Sensor Pins

//-- Setup
void setup()
{
  Serial.begin(115200);
}

//-- Runtime.
void loop()
{
 while(1)
 {
   for(int i=0; i<N_SENSORS; i++)
   {
     Serial.print( TdkUssm.GetDistanceCm(i) ); // Prints Distance in cm of sensor i.
     Serial.print(" ");
     delay(100);
   }

   Serial.println(); // Terminate single capture line
   delay(2);
 }
}

I just changed N_SENSORS (from 4 to 2) and IoPins to match the pins used on my board.

The original version of the library did not compile, so I had to make a little change to the file Arduino/Libraries/TDK_USSM_Ultrasonic_Sensor-1.0.2/src/tdk_ussm_defs.h

The change is shown in the following code snippet

/*! \ingroup tdk_ussm
 * \brief Measurement Data Structure.
 */
typedef struct
{
    uint16_t id; // <-- original code was uint8_t id
    uint8_t lsb;
    uint8_t nbit;
    uint32_t val;
    const char *name;
    const char *description;
    const eLUTStruct *lut;
} eParameterElement;

First test

And here is the terminal output after the above test code have been downloaded and run

image

Next steps

I am going now to implement the firmware to calculate the ball parabola, show results on a local LCD screen, send data out through BLE and so on and so on.

  • Sign in to reply
  • Cancel
  • DAB
    DAB 3 days ago

    Nice update.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube