Is there a module that will allow communication between a Fez and a PC using the audio out and mic in ports? I know that serial USB would be cheaper or an FTDI chip or something, however I’m looking for information on the technique used, not the actual product.
I’ve seen this type of system before where a tool was underground in an oil well and battery powered. It would transmit the data via acoustic pulses into the tubing and using an accelerometer type acoustic pickup at the surface, they fed the signal to a sound card input on the PC and used this to decode the data transmission. I believe they used some form of FFT to pick out the signal from all the other vibrations and noise. I saw this system working many years ago.
Is this the type of thing you are looking to do?
Not for oil wells, but yes.
I assume you want to send from the fez to the pc.
you can use FSK.(frequency shift keying) you can generate the signal with a PWM hardware port. you could then sample on the pc, and as Dave said, do a FFT to determine frequency.
you would have to watch the input voltage to the pic.
and what about for the other direction, from the PC to to the Fez. Would FSK work on the Fez?
Somewhat on topic:
In the early 1980s, before home pcs, I recorded a demo of a new graphics workstation on VHS tape, and used a 1200 baud modem to record the mouse cursor movements (of the 1200 baud serial mouse) while recording the demo, on one of the VHS audio tracks.
I could then take the VHS tape to a trade show, and play it back, with the VHS video and one audio track piped to the workstation to be shown in a window on the workstation screen, and the other audio track fed back through a 1200 baud modem and to the workstation as mouse input, to control the cursor from the recorded audio. The effect was that the person giving the demo was inside the box on the screen, controlling the mouse outside of the box. The mouse “audio” was processed just like the original mouse movements, so the demo would cause the mouse to open windows, click buttons, run the entire demo and control the workstation… from vhs audio!
It was awesome.
I think it’s a lost art; hardware hacking.
A few years back we used DTMF tones to do this.
What sort of distance are you talking about?
Do you need to transmit data over a cable or other medium?
If cable, do you need to have power on the same cable?
I don’t think you can do FFT on the Fez in C# but it may be possible with C/C++ but I am not familiar with the requirements for processing power etc.
Cable, and no power.
I have a simple question then? Why audio when RS232 or other simple serial protocols would be more ideal for such a short distance or is this more about a project to prove the concept?
Normally the likes of FSK are used to send comms over long distances or or over power cables and would be a waste for short haul.
Because Laptops don’t have serial ports today, and USB to serial ports introduce 12 volt signals.
Edit: Its about proving a concept. I need to be able to control a motor with nothing more than the audio out from a laptop. That is is possible and simple is the proof of concept. I prefer digital, because it’s easier to understand, and TTL logic gates are readily available.
Use the USB to TTL converters instead. They can have 3.3 or 5.0V.
@ Dave McLaughlin - I cannot purchase anything new that would otherwise be unavailable locally. The only reason I mention a fez is to abstract that part of the system for clarity purposes. Also, I can obtain USB Audio adapters locally. Each adapter will give me 2 more I/O channels.
Backstory: I went to a presentation where the student spend 36K USD on a project which I thought could have been much cheaper. the majority of the funds was spend on the control system to connect a computer to a hydraulic pump. He spend most of his time just getting the the control board drivers to work on the computer. I tried to make a case for PWM control using a power amp and a signal from the audio out to control the pump. I think he took it hard. Now I need to have some sort of proof that using the audio port as an interface is not only viable, but preferable.
Ah so now I get the idea. With this information it is easier to understand your reason for asking how to use audio.
I have no experience of using it myself but if you can generate some sort of FSK tones from the PC at a suitable rate you could send this to a receiver that would decode the FSK. You will need some CRC in there as it will probably be noisy. You don’t want the motor moving to a wrong position.
For industrial control of motors I like to use Variable Speed Drives with build in protocols such as Modbus. They are almost bullet proof and safe. These are not expensive for smaller motors. I did one a few years ago with a 43Kw motor that drive a water pump. The VSD for this was only $4K.
That students $36K would be valid if we knew the size of the motor and the precision of control that was needed.
Sounds like a good concept you have and I hope you can find the solution and prove him wrong.
There are lots of analog communication systems that use nothing but audio tones to send data. Old school analog modems that worked over phone lines are one example, We use a variety of analog communication techniques to send data through the water to/from our oceanographic instruments. If you have a 2 meter cable, it will be much easier as you won’t have to deal with noise issues very much or probably at all. You can certainly do something fancy like FSK and the G120 and G400 are fully capable of doing the processing. The question is what bit rate will you be able to achieve, I would guess that 100s of bits per second might be achievable without too much effort. However, if you’re just trying to prove a point you can do something brutally simple like send a digital message composed of ASCII characters that are of course nothing more than digital ones and zeros. If you really want to use just the audio signals and the speaker output can drive the mic input directly (check the specs) you can do something like the following. On the transmit side, generate a tone burst by calculating a vector of integer values that describe one cycle of a 128 Hz sine wave using the sine function. Use 512 values for the cycle. Now build a longer vector of tone bursts to generate a message packet. Say you want to send an ASCII “A” hex 41 or binary 01000001. Concatenate 20 of your tone bursts to indicate the start of packet. Concatenate 10 zero values to separate the start of text tone from the first data bit. Concatenate 5 tone bursts to signal the MSB value of 1. Concatenate 10 zero values as a separator. Concatenate 10 tone bursts to indicate the next bit which is a zero. 10 zero values as a separator, 10 tone bursts for the next zero and so on until you’ve got all the bits encoded as tone bursts. Now concatenate 30 tone bursts to indicate the end of the packet. Now send the integer values to the speaker, one value every 1/512 of a second. Sample the mic on the receive side at least 1024 times per second. Now you can just count pulses or peaks to a) find the start of text character, b) recreate the ones and zeros until you c) find the end of text tone.
I picked some number like 128 Hz, 512 samples per cycle, 20 tone bursts for the start of text, etc. that seem conservative but you’ll probably have to fiddle with them. You can do the same thing with the ADC and DAC. You can also use the digital IO lines to do exactly the same thing with a 50 cent RS422 line driver and receiver.
It is kind of hard to explain this in a short post, if this sounds at all like what you’re looking for, feel free to ask more question or PM me.
@ Gene - Actually, I do understand.
Is it anywhere close to what you’re trying to accomplish?