This Instructable is to fulfill a requirement for the documentation portion of the microcomputer interfacing project at Utah State University.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Background
An oscilloscope is used to display and measure a voltage signal that is plotted against time. An oscilloscope in XY mode plots a signal against another signal sort of like a parametric equation. This project uses an oscilloscope in XY mode to display images produced by a sound file.
Step 2: Original Idea
The original idea for the project was to convert an old Cathode Ray Tube (CRT) television set into an XY oscilloscope and use that to display the images. This can be done by disconnecting the deflection coils. When you disconnect the horizontal coils a vertical line appears, and when you disconnect the vertical coil, a horizontal line appears. All I had to do was connect the audio source to the deflection coils and I would have an XY oscilloscope. Unfortunately, I ran into several problems.
Step 3: Problems Encountered
One of the problems I encountered was the safety features. The TV was able to detect that it’s deflection coils had been disconnected and would not turn on. This is to prevent the electron beam from burning a hole in the phosphor on the screen. I measured the resistance of the coils and placed a resistor across it. The resistor immediately burned in half because of the high voltages. I tried again using a higher rated resistor, but that didn’t work either. I read some forums online about how another set of deflection coils could be hooked up to the original TV, so I found another TV and hooked up it’s deflection coil to mine. The impedance wasn’t the same so it didn’t turn on. After some more research I found that older TVs did not have the safety feature and didn’t care if it’s deflection coils were disconnected. I was able to find a TV produced in 2000 that seemed to work. I was able to get some simple shapes on the screen, but anything more complicated than a circle would be heavily distorted. Eventually this TV stopped working and it kept blowing fuses.
I was able to find a small TV that was made in 1994. This TV worked pretty well, but I wasn’t able to get the correct orientation of the image, even when I switched the signals in every combination. It also had the same problems as the other TV and would not produce complicated images. After a lot of research I found out that problem was that I was trying to produce a vector image on a raster display. A raster display is a screen that scans horizontally very quickly and then vertically at a slower rate. A vector display uses lines to produce images. I found tutorials on how to convert a raster display to a vector display, but the process was dangerous and would take a long time.
Step 4: Solution
After all of these problems, I was able to find a pretty simple solution; an XY oscilloscope emulator program that took audio as an input. Once I found this program, I switched from focusing on creating an oscilloscope to creating a way to produce an audio file from an image to display on an oscilloscope.
Step 5: Edge Detection and Matlab Program
Here is a basic flowchart of my program. It starts out with an image that is loaded into the EdgeDetect.m MATLAB program. This program converts it to a gray-scale image and then detects the edges in the image. The XY coordinates of the detected edges are placed into two arrays which are converted into a sound file.
Step 6: Example: Instructables Robot
Here is an example of the process with the instructables robot. First download an image of the instructables robot and save it as "image.png" into your MATLAB working folder (same place as "EdgeDetect.m"). Make sure the image doesn't have anything you want to be detected or it could add a bunch of unnecessary coordinates into your sound file. Run the EdgeDetect program and the image will be converted to gray-scale, and have it's edges detected and stored as a sound file named "vector.wav". Next open up the sound file in Audacity or another sound editing program. Open up your oscilloscope emulator program (link in previous step), set the sample rate to 192000 Hz, press start, click the microphone button, and select the line in option. In Audacity press "shift + spacebar" to play the sound file in a loop. The image should appear on the oscilloscope emulator.
Step 7: Troubleshooting/Example Files
As I developed this program I had to adjust some settings in the program. Here are some things to double check if it is not working:
-Make sure your audio output is being fed into your line in on your computer and that you have 2 separate (left & right) audio channels
-If the image is not being read by the MATLAB program you may need to edit it in paint and save it as a different format.
-On line 61 of the code, be sure to include the numbers from the edge detect screen. The program usually puts a rectangle around the whole thing which you can cut out by changing it from "i=1:length(B)" to "i=2:length(B)". Also, if you have specific numbers that you want to include, but don't want to include them all, you can use square brackets to get specific numbers: "[ 1 3 6 10 15 17]"
-If the image looks shaky and the parts are all over the place you may need to reduce the number of samples by adjusting "N" on line 76. The simpler the image the lower N can be, but it should be higher if the image is complex. For the robot I used N=5.
-You can also adjust "Fs" on line 86. The higher the sampling rate the better the image will look, but some sound cards will not be able to handle higher sampling rates. Modern songs have a sampling rate around 320000 Hz.