Complex-valued (quadrature) Signal Generator
by SteveMann in Workshop > Science
3517 Views, 5 Favorites, 0 Comments
Complex-valued (quadrature) Signal Generator
Introduction to wearable computing (wearable radar, wearable sonar, etc.) and robotics with a complex-valued signal generator
Make your own complex-valued signal generator and oscilloscope for less than $10
Teaching at MIT, Stanford, and University of Toronto, I've developed a number of labs that give students the fundamentals of engineering.
One thing we often need is a complex-valued signal generator, i.e. a signal generator that has "real" and "imaginary" outputs, also known as "in-phase" and "quadrature" (90-degrees out-of-phase) outputs.
We use this for wearable sonar and wearable radar sensing devices and systems, as well as motor controllers to teach principles like Human-Machine Learning (ACT + LEM).
Context:
For this lab you will make your own wearable complex-valued signal generator and wearable oscilloscope.
You will assemble and use a simple small size computer you can wear or build into personal devices such as the seeing aid for the blind that you will make for Lab 2 (next Instructable). This system will also form the basis for the electric vehicle of future labs (future Instructables).
For Lab 1, we will make the following:
- Wearable computer system;
- Complex-valued signal generator;
- Multi-channel oscilloscope.
Complex-valued electrical signals:
In order for an electric signal to be progressive (i.e. to have only positive frequency components) at must be complex-valued. In particular, the imaginary part of the signal is equal to the Hilbert transform of its real part. The Fourier transform of such a complex-valued signal is zero for frequency components that are less than zero.
An example of such a signal is when the real part is a cosine wave and the imaginary part is a sine wave. In this example, cos(2πfc) + i sin(2πfc) = exp(i2πfc), where fc is the carrier frequency of the wave, e.g. for a radio signal, radar signal, sonar signal, or the like. This is also true for rotation of a motor. A progressive signal will rotate a motor in a specific direction.
By convention, we say that a signal of positive frequency rotates counter-clockwise in the Argand plane (Argand diagram).
We encourage the student to illustrate this by connecting the signal generator to a stepper motor (i.e. a 2-phase motor) so that it turns in a specific direction. Reversing the two inputs (i.e. the role of cosine and sine) reverses the direction of the motor. When cosine and sine are reversed:
sin(2πfc) + i cos(2πfc) = cos(2πfct - π/2) - i sin(2pfct - π/2) = exp(iπ/2) exp(-i2πfct), i.e. turning in the opposite direction.
The complex-valued signal generator is helpful in teaching these fundamental concepts.
Obtain Materials
These three features will be implemented on an Atmel ATmega328 microcontroller
such as one having the form factor of "Arduino Nano". Cost $2.36 from banggood, or $4.72 from Amazon Prime (in sets of 3).
Bill of Materials:
You will require the following parts, plus a breadboard and some wire to connect them:
- Microcontroller, e.g. form factor of Arduino Nano;
- Potentiometer (abbreviated "pot" and also sometimes called "variable resistor" or "rheostat", especially in contexts where only 2 of its 3 terminals are used, although here in this lab, we're going to use all 3 terminals!);
- Capacitor (also sometimes called "condensor", especially in older literature);
- Power supply such as a 9-volt transistor battery or a multicell battery holder and cells for it, or you can just use a USB battery or USB computer and have it tethered;
- Output filters.
Choose a potentiometer of reasonable value, e.g. somewhere from about
1000 ohms up to about 10,000 ohms. If you choose a value that is too high, it will allow the circuit to be too sensitve to interference or external "noise". If you choose a value that is too low, it will use too much power and run the battery down faster than necessary. Potentiometers come in three main categories: type "A" ("Audio" which means it is logarithmic, or "log", since human perception such as hearing, is logarithmic), type "B" which is linear, or type "C" which is reversed logarithmic. These letters often appear with the resistance markings on the device, e.g. a 10k log pot, which is typical of what is used in the volume control of a portable transistor radio, might bear a marking like "10k A". A 10k linear pot might bear a marking like "10k B".
The capacitor is not totally necessary. What it does is filter or smooth the result so that you don't get a "scratchy" variation from the noise of the potentiometer sliding along. Choose a reasonable value. Any value from about 1 microfarad to about 100 microfarads will work quite nicely.
Total cost of all the above parts, approx. $5 from Bangood, or approx. $10 from Amazon Prime (in sets).
Wire Up the Parts
Connect the components as shown above.
Power is from USB (tethered to computer or from USB battery), or, alternatively, use the 2 upper-right pins, VIN (30) and GND (29) powered from a 9v transistor battery or other similar battery pack.
It is best not to power from both sources (e.g. 5v and 9v) at the same time!
Program the Device
Write a short computer program to facilitate the signal generator.
It should read from A0 (Analog input 0) a number from 0 to 1023 wince this is 10 bits (2^10 possible values), and use this to control the frequency.
Frequency is the reciprocal of the period. The signal generator should operate from 1 CPS (Cylce Per Second), also referred to as 1 Hz (Hertz), and it should increase to whatever the maximum value you can achieve is. Use a logarithmic scale for ease of operation. This is done by either purchasing a logarithmic (e.g. type "A" or "Audio" potentiometer), or by using a type "B" (linear) potentiometer together with computer programming that converts this value to its antilogarithm (e.g. so that equal angles of rotation give an output frequency of 1 CPS, 10 CPS, 100 CPS, and so on).
Your signal generator must provide a complex-valued output. In order to facilitate this, you will use two outputs. Choose outputs that facilitate PWM (Pulse Width Modulation), so that you can apply a filter to get analog output. The simplest form of filter is a capacitor, as with your potentiometer, but choose the value appropriately for the highest frequency you're trying to render.
First implement a complex-valued square wave output that goes up to 40,000 CPS (40kHz). Your square wave should look like the waveform shown in the picture above.
You will later use this for lab 2, as the basis of a wearable sonar seeing aid for the blind.
Secondly implement a complex valued CiS (Cosine i Sine) wave, as shown above.
You will also implement an oscilloscope (also known as "oscillograph")
function so that you can plot, in real time, electrical signals. A small portable or wearable oscilloscope is useful in daily life. As an example application, many years ago, in my childhood, I made a small wearable oscilloscope so that I could watch my electrocardiogram (the electrical waveform from my heart) in real-time while I was exercising. I also watched my EEG (brainwaves) and used this for biofeedback. My students and I founded a company (InteraXon) based on this work, and this technology helps thousands of people eliminate stress and improve the quality of their lives.
In this lab you can use your oscilloscope to view the output of another student's signal generator, and vice-versa, so you can test your results.
Implement the oscilloscope function by reading analog inputs and sending back over serial (USB) to the host computer to plot there.
External links:
http://e2e.ti.com/support/archive/stellaris_arm/f/...
https://electronics.stackexchange.com/questions/17...
See also "90 Degree Phase shift between two PWM signals".
Going Further
Implement a proper (separate) DAC.
Show us something interesting and useful with the signal generator. Example: connect it to a stepper motor to show it turning the motor.
If you don't have an oscilloscope handy, simply connect two LEDs, for example, red for the real part, and yellow or green for the imaginary part.
Wave the circuit back-and forth, or flick your eye gaze across them, and you can see, by way of persistence-of-exposure, the waveform. Alternatively, make a long-exposure photograph of the board moving across a table, and you can see the relationship between the red (real) and yellow or green LED.
Here a student has wired a stepper motor with the indicator lights for real and imaginary, and in another example, the indicator lights for four points equally spaced around the circle in the complex plane, i.e.:
1, i, -1, and -i.
Add a 3rd output for 3 phase, or additional outputs for polyphase control of various kinds of motors.
Here a student has used 3 outputs to control a three-phase motor. In this case we have 3 points around the unit circle of the complex plane, in which they are spaced 120 degrees apart.
In 1918, Fortescue presented the concept of the "symmetrical components transform" which expresses three phase power in terms of a positive-frequency component, a negative frequency component, and a DC ("homopolar") component. This is akin to the 3-point DFT (Discrete Fourier Transform), and allows us to understand electric motors in an interesting way.