Skip to content

Example 03: Multiplexed signal readings

Alexander Spiridonov edited this page Oct 12, 2016 · 21 revisions

Additional documentation for an example supplied with the KeyDetector library that demonstrates how to encode digital signal into single analog line and decode it using library.

About

This is more of a real life example. Imagine you want to control your project with wireless controller, such as, for example, PS3 DualShock 3 or Navigation Controller. You decided to use USB Host Shield Library 2.0 with compatible USB Host shield for your Arduino and a Bluetooth dongle. There are quite a bit of documentation out there on how to achieve that, and a basic example that comes with USB Host Shield Library 2.0. Now, what if for some reason you decided to divide your project into two parts (or modules): Control module, responsible for interaction with PS3 controller, and Main module, which will hold primary logic of your sketch? This may be an option in case, for example, when there are simply not enough space left for your own primary sketch after including USB Host Shield Library 2.0. Or you just prefer modular systems with somewhat independent modules, which can be upgraded independently from one another.

So you’re left with two modules that need to be somehow connected in order for Main module to receive data from Control module. If you find yourself in a situation with limited pin-budget, you may want to multiplex control signals from digital buttons of your controller (connected to Control module) into single analog line. That way you’ll be able to connect modules with (almost) only one wire (not counting power and GND wires as well as any other analog signals you may want to transmit from the controller, such as stick coordinates).

In this example we’ll see how to encode (or multiplex) digital signals into analog signal as well as how to decode (or demultiplex) it back on the receiving end using KeyDetector library. Additionally we’ll transmit signals form analog stick of the PS3 controller with the use of PWM to analog conversion.

Note: in order to proceed with this example it’s highly recommended that you’ll get familiar with how to use USB Host Shield Library 2.0 and how to set it up to operate with Bluetooth connected controller.

Parts List

  • Arduino equipped with ATmega328 controller (UNO, Pro, Pro Mini, etc.); Arduino Pro Mini (ATmega328/3.3V/8MHz) was used in the example
  • USB Host Shield compatible with aforementioned Arduino; USB Host Shield for Arduino Pro Mini was used in the example
  • Controller (PS3 DualShock 3, Navigation Controller or compatible)
  • Compatible Bluetooth dongle; HAMA H-104890 was used in the example
  • Arduino UNO or compatible
  • Two 10kOhm resistors
  • Four 20kOhm resistors
  • Two 1MOhm resistors
  • Two 100nF capacitors

Multiplex

3-bit DAC

Low-pass RC filter

Sketch

Demultiplex

Sketch

Complete schematic and breadboard

Schematic

Breadboard

Run

Clone this wiki locally