PSpice Simulated with Arduino-Driven Sensors

By Greg Roberts, EMA Design Automation

 

Have you ever wanted to simulate a design with existing hardware? 

 

Sure you can create a stimulus of what you expect from the hardware then simulate in PSpice®, but sometimes there’s no substitute to the real thing.  Ideally what engineers want is a blend of virtual and physical prototyping—something possible in PSpice.  Since many IoT innovators use inexpensive development boards to develop their idea, I thought it would be instructive to show how one can develop new hardware in OrCAD® and PSpice, then integrate the simulation with real sensors driven by an Arduino board(link is external).

 

In the picture below, the Arduino Uno is connected to a small breadboard with a few sensors as input and a LED as output.

 

                                           

 

The schematic for this design (below) is based around a symbol for the Arduino Uno with pins for its analog and digital I/O.  To create new hardware for simulation, you can just add parts to the OrCAD Capture design and wire them to the Arduino symbol.  In my example, two of the sensors— the tilt sensor and the thermal sensor—are just for input to display in a Probe window.  The optical sensor, or Detector, is reading the value of the photo resistor, running it through the circuitry I’m designing—which for my simple example is mainly just an op amp—and then driving a LED on the breadboard.

                                          

 

 As you can see in the picture below, when I run the simulation, I can see how my interactions with the sensors affect my simulation:

                                         

 

  • Each time I tilt the board beyond a threshold, I see the green trace drop from 1V to 0V
  • I can block the LED lighting the photo resistor and see the yellow trace drop from about 2V to about 0.5V
  • I can hold the thermal sensor staring at the three-second mark to heat it up from my fingers and see the light blue trace slowly increase in voltage.
  • The red trace verifies that my LED output does not change.

 

The key to making this work with PSpice is the relatively new device model interface or DMI capability.  DMI replaces the old Device Equations Developer’s Kit (DEDK) feature that allowed customers to modify the PSpice intrinsic models to create new models.  DMI is a better, more flexible solution allowing engineers to create new models in C/System C/C++ independent from the internal PSpice models.  This Arduino example utilizes the DMI capability to create a model for the Arduino Uno schematic symbol in our design to give function to the pins we are using.  The basic implementation of the model is to connect our PSpice design to the Arduino board through Arduino’s serial link.  This allows us to see inputs from the board and drive outputs to the board.

 

Using DMI this way is not exclusive to an Arduino board.  Because the interface is written in C, other development boards can be accessed in a similar fashion. So if you’re designing your next great product with Raspberry Pi(link is external) or a BeagleBone(link is external), rest assured you too can design and simulate your custom hardware with PSpice.

 

You can view this demonstration live by watching the video below.

                                           

                                                     

Workflows

PSpice Simulation

Categories

Learn OrCAD
What's New