Thursday, May 27, 2010

Enterprising undergrad engineering students can achieve a lot if given the right set of tools. Once you level up to designing some complex circuits, a signal generator and an oscilloscope would definitely go a long way in helping you in debugging your projects. I bought my first oscilloscope (Acute DS1202 200MHz PC based) for INR 37,500 after accumulating my salary for 4 months at my first job. But I always wished I has an access to an oscilloscope as a student. It seems that now days there is a low cost option for students to use: the PCs sound card.
Most modern motherboards have an onboard Audio Codec Chip which is used to accept and output sound, you can find atleast 3 audio jacks labeled Microphone, Line In and Line Out on the back side of your CPU Cabinet. You can then use specialized freeware/shareware applications which can turn your PC into an Oscilloscope/Signal Generator. Here are screen shots of some of these:

There is also a concern that you may exceed the input voltage range and blow up the sound codec chip on your motherboard, so for that one can buy a cheap USB Audio Controller. These cost somewhere around Rs. 325 in India and so you won't feel that bad when you blow it up! These USB Audio Controllers show up as a standard Audio Controller in Windows Device Manager and can be used like a standard sound card. They are actually ment for use with VoIP applications like Skype, but we can surely use them for different purposes. Here are photos of two of these:

So all you need to do to capture a signal is use a wire with 3.5mm mono audio lead at its end plugged into the microphone jack. If your audio controller has a "line in jack", you can capture two signals on the left and right channels. To use line-in you will require a 3.5mm stereo lead (instead of mono lead for microphone). The speaker out can be used as a dual channel signal generator when coupled with the proper software (e.g. Soundcard Oscilloscope 1.32 linked to above)

I guess it is also possible to re-purpose bluetooth headsets available now days into low bandwidth wireless oscilloscopes - how cool would that be? You can pair up bluetooth headsets (including those equipped with A2DP) with your windows based PCs running BlueSoleil. Should try that out one of these days.

There is another piece of cool software that one should be aware of: imagine you are in an aircraft (or a train) traveling to someplace and you have lots of time to kill. If you have friends/family traveling with you, then all of you can watch a movie on a laptop - the only problem would be to have multiple set of headphone. Rather than loading a single headphones jack with multiple headphones using a Y-splitter, you can plugin multiple USB audio controllers into your laptop and use Virtual Audio Cable to replicate audio stream to multiple devices. In case you decide to do this, you will also have to adjust the audio/video delay for this - all extra processing causes the video and audio to fall out of sync. If you are using the latest version of VLC media player, you can adjust the audio delay (with respect to video) using "j" and "k" keys - or you can try this. Virtual Audio Cable can also be used to record audio streams from various application (eg Youtube flash video being played from within Firefox, or music played while playing a game, or your conversation while talking to someone on Skype).

Bring a GSM cellphone near some low grade audio equipment and you can hear some very irritating noises. GSM or Global System for Mobiles uses FDMA, TDMA and SDMA for providing network access to multiple users. This each achieves as follows: Base Transceiver Stations within Cells (a fundamental unit of geographical areacovered by the GSM service provider) surrounding a given cell will all use frequencies different from each other (Frequency Division Multiple Access). The maximum amount of power transmitted by BTS as well as mobile units within a given cell is limited and so cells separated by a considerable geographical area can both reuse the same frequency for transmission (Space Division Multiple Access). And finally within a given cell, mobile units will use Time Division Multiple Access so that man users can be served by the same Base Transceiver Station. Of course different frequencies are used for uplink and downlink. Depending on the country, GSM operates in 800MHz to 900MHz or 1800MHz to 1900MHz bands.

With regards to TDMA, a GSM multiframe lasts 120 milliseconds consists of 26 frames. each of these frames itself last 4.61538 milliseconds and have 8 timeslots each. During a simple conversation, each of these is allotted to a different user - so a cell phone (in an active call) sends a burst of data every 4.61538 milliseconds which results in a 217 Hertz pulse waveform which lies in the audible range and gets coupled into unshielded audio circuits operating in the vicinity of the cell phone.

Of course if you bring an oscilloscope probe near a cellphone and make a call, you can observe these bursts too:

The horizontal scale is 20 milliseconds, you can note that the time between two bursts is approx 4.6 milliseconds. The above waveforms have been captured on a Tektronix TDS3044B Digital Phosphor Oscilloscope with 350MHz bandwidth. While I was trying to get a proper waveform for the 217Hz noise, I ended up capturing some vivid patterns on the scope. These too were captured while the cellphone was on an active call. Note that these waveforms have been improperly captured and cannot be used to deduce much useful information about the signal:

I was also able to capture a clean waveform of the noise induced by a cell phone in a nearby landline telephone - note that the duration of 4.6 milliseconds between two successive bursts is clearly seen. The signal was captured by touching the probes directly to the two wires of the telephone lines.

Visha Electronics carries a very low cost FM transmitter kit based around BF494 NPN Bipolar Junction Transistor. The kit has a condenser microphone to pickup sound. A variable capacitor is also present to tune the transmission frequency anywhere in the 88-108 MHz range. The transmitted signals can be picked up by any stand radio receiver. A simple receiver circuit can also be built, like the one shown here.

SPI is a serial link standard used between chips. Now days most microcontrollers have an on board SPI block. SPI link is made of atleast one master and one slave. The link is composed of four wires:

SCLK - Serial Clock, always provided by the Master

MOSI - Master Out Slave In, Data (from master to slave)

MISO - Master In Slave Out, Data (from slave to master, clock still has to be provided by master)

nSS - Slave Select, usually the Chip Select signal for the slave.

Sensors, ADC/DAC, memory and many other devices had slave SPI interfaces. Some examples of SPI compatible ICs/Devices:-

Accelerometers (ADIS16201)

4-20mA current control (AD420)

Flash Memory (EN25T80)

Nokia 6610 Colour Graphical STN LCD (PCF8833)

Nokia 3310 Monochrome Graphical LCD (PCD8544)

EEPROM (25AA640)

SD Card

10BASET Ethernet Controller (ENC28J60)

Many microcontrollers - like AT89S52 and all the AVR devices available from Atmel - are programmed via SPI.

Here is a screen shot of SPI signals captured as a master sends a byte to a slave:

All signals captured are from microcontroller (master) to slave deviceChannel 4: nSSChannel 2: SCLKChannel 3: MOSIIn this particular case, each data bit is clocked in by the slave device at the falling edge of the clock. Some slaves sample the data at the rising edge.

Here is another example of SCLK (Channel 1 Yellow) and MOSI (Channel 2 Blue). It shows the transmission of 6 bytes of the string "Hello,"i.e. The ASCII codes, left to right in the waveform:0x48 (01001000)0x65 (01100101)0x6C (01101100)0x6C (01101100)0x6F (01101111)0x2C (00101100)

Wednesday, May 26, 2010

Here are some photos and waveforms from a PSK generation lab practicals. All undergraduate students pursuing engineering in electronics and its allied fields get a chance to do it at least once during their four years.The process of PSK generation in a lab is as follows:

Generate a sinusoidal carrier wave from a signal generator. Call it Signal A

Use an operational amplifier to shift the phase of Signal A by a fixed amount : usually 90 degrees in case of Binay Phase Shift Keying. Call this Signal B.

Apply Signal A and Signal B to the two inputs of a 2:1 analog multiplexer.

Apply the data signal to the select line of the analog switch. The output of the analog switch will be the required PSK signal. The data signal is a simple digital signal with two states 1 and 0 i.e. 0 and +5V. This can be emulated using a 555 Timer wired to generate a simple square wave. The analog switch will select Signal A or Signal B depending on the logic level of this data signal thereby outputting a sine wave which abruptly changes phase as the bit value changes.

Tuesday, May 25, 2010

HART is a digital industrial automation protocol which has been in use for quite some time now. It uses "Continuous Phase" Frequency Shift Keying to transmit data over the same wires (a pair of wires - one for each direction of flow of current) which had been used for 4-20 mA current loop signaling. bit 1 is represented by a sinusoid at 1200 Hz and bit 0 is represented by a sinusoid at 2200 Hz. The signal has an amplitude of 1mA peak to peak (current signaling):

Top: HART Signal Below: Data Transmitted

The HART Packet consists of a sequence of fields each consisting of varying number of bytes:

Various fields of HART Packet sent from Master to Slave

Each byte is it self a standard UART frame sent out at 1200 bps in 8-O-1 format. So a PC equipped with a serial port can act as a master simply by using a HART modem and appropriate application:

A HART Modem (black device with white sticker on right) from MACTek. The PCB shown here is used to sniff the data being sent from the PC to the modem.

Windows Application - VIATOR Check utility that came with the MACTek HART Modem.

Of course one can use good ol' DOS prompt too to send data out the serial port using simple commands.

And finally here are a the captured waveforms of a HART frame being transmitted:

Measuring the frequencies for Bits 1 (1200 Hz) and 0 (2200Hz). FFT of the signal clearly shows peaks at these two frequencies:

And finally one can use Serial Monitor from HHD Software to monitor the data being sent out the serial port by any Microsoft Windows based application running on your PC. Here are some screen shots:

Saturday, May 22, 2010

Oscilloscopes are fun. And I like collecting stuff. So inevitably this led me to start collecting "waveforms" of common signals propagating in and between the various electronic equipment that run our lives.First up is a simple square wave captured on a Tektronix TPS2024 oscilloscope. The square wave is taken from the oscilloscope itself and is actually meant for probecalibration/compensation. The square wave is 1KHz 5volt peak to peak. The animated GIF file below shows the square wave at each step as the time division knob is moved . I always wanted to make such an animation - sort of satisfies our inherent kiddish desires to play with knobs and buttons and move them/bang on them randomly madly!