Shop OBEX P1 Docs P2 Docs Learn Events
Bell 202 Modem (1200-baud AFSK) Object — Parallax Forums

Bell 202 Modem (1200-baud AFSK) Object

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2015-01-19 05:57 in Propeller 1
I've just posted a Bell 202-compatible modem object to the OBEX (publicly visible soon in the Signal Generation and Processing section, under the heading "Modem, Bell 202"). With this object and a few external components, you will be able to communicate data via an audio channel (hardwired, AFSK FM, etc.) at 1200 baud half duplex.

This modem software converts serial binary data to frequency-shifted audio, such that a "0" is a full cycle of 1200 Hz sinewaves, and a "1" is about 1.83 cycles of 2200 Hz sinewaves. This is the modulation part of "modem". At the receiving end, the audio is demodulated back into binary data:

attachment.php?attachmentid=59083

The modulator makes use of the Propeller's built-in sine table, along with a counter's DUTY output, which is lowpass filtered to yield an analog signal. A simple audio output circuit can be constructed as follows:

attachment.php?attachmentid=59084

The schematic includes an optional multiplexed push-to-talk circuit (transistor and two resistors) that will work with many radio transceivers.

The demodulator makes use of a counter on the input, either as a delta-sigma A/D converter or as a simple threshold detector. Here is a schematic that is used with the latter detection mode:

attachment.php?attachmentid=59085

The input, either clipped square waves from the circuit above or actual sinewaves from the A/D, is sliced and diced using a combination of software-defined mixers, Fourier analysis, lowpass filters, and comparators to reconstruct the original binary data. Here's a block diagram of what the software does:

attachment.php?attachmentid=59086

You will notice that there are three programmable parameters: Offset, Hysteresis, and Noise Level. These can be tuned in real time for the most reliable reception. To aid in this tuning, I've included a Windows-compatible host program which, along with a companion Spin program, will allow you to optimize the demodulator's performance. Here is a screen shot of the program in action:

attachment.php?attachmentid=59087

The colored dots plot the instantaneous filter outputs against each other. Red dots are "1"s; green dots, "0"s; yellow dots, in the hysteresis band. Anything above the diagonal white line is signal; below it, noise. The bargraph plots the relative number of comparator outputs counted for each bit. The idea is to balance this number to zero using the SLICE (offset) slider. The panel on the right shows the demodulated output, which can be compared with the transmitted data for accuracy.

This is just a sketchy description of the modem object and what it does. There's much more in the PDF documentation accompanying the object in the OBEX. Hopefully, this will turn out to be useful for things like telemetry, remote control, and similar apps. This is just a simple modem, too. There's much more that can be done, for example, with things like forward error correction to make data transfer over noisy channels more reliable.
________________________________________

This whole project was inspried by Ken Gracey's post on wireless data communication using 2-meter HT radios. When I suggested to him that the Propeller could perform the modem functions, he leapt at the idea, lent me a pair of radios, and suggeted I get a ham license so I could make it happen. So I got my license, wrote some code, and here it is. None of this would have happened without the encouragement and support that's become a Parallax hallmark. Thanks, Ken!
________________________________________

I can't leave this without saying more about amateur radio in general. When I was a teen, I had a ham license. Back then, it was one of the few outlets available for those with an electronic techie bent. Personal computers were still a distant dream, like flying cars. Of course, all that has changed in the intervening years. Computers quickly caught my fancy, and I let the ham license lapse. (I never did like "rag chewing" and was in it more for the technical thrill than — shudder — talking to anyone.) Before this project came along, I never gave ham radio another thought. Frankly, it seemed to be the domain of old farts who yearn for the warm glow of vacuum tubes over anything more modern. (Unfortunately, some of the current ham radio magazines do little to dispel this point of view. After all, how many articles about ARC-5s do we really need?)

But forget all those preconceived notions! On the contrary, my experience with the modem project has revealed that a wealth of fun, high-tech opportunities await anyone who takes the (minimal) trouble of getting a ham license. It really is the entr
449 x 176 - 9K
386 x 123 - 5K
341 x 131 - 3K
800 x 358 - 31K
800 x 575 - 170K
«134

Comments

  • mparkmpark Posts: 1,305
    edited 2009-03-04 07:35
    Very cool!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-04 08:05
    Oh, you are a smart cookie Phil, congratulations, very well done. I also like your diagrams and supporting PC software, nicely finished. I will have to try this out on the phone lines.

    BTW, what software did you use for the Monitor software?

    *Peter*
  • DavidMDavidM Posts: 626
    edited 2009-03-04 09:00
    Hi Phil,

    This is excellent, I need this exact thing for my project. I will be following this thread very closely,

    regards

    Dave M
  • Cluso99Cluso99 Posts: 18,066
    edited 2009-03-04 10:08
    WOW smile.gif I used to design and code modems using AMD, Rockwell and SSI chips. I never expected to see a Prop do this - Amazing stuff - well done smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps:· SixBladeProp, TriBladeProp
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz
  • HannoHanno Posts: 1,130
    edited 2009-03-04 10:19
    Great work Phil! Thanks for releasing this object. This is a huge step for the Propeller- discrete modem chips are quite expensive in small quantities.
    Hanno
  • HannoHanno Posts: 1,130
    edited 2009-03-04 10:37
    Caller ID uses Bell 202 modulation. Who's going to build the first Propeller Caller ID device? Any reason why this wouldn't work?
    Hanno
  • william chanwilliam chan Posts: 1,326
    edited 2009-03-04 13:12
    Phil,

    How about adding a hybrid schematic for connecting to a 2 wire PSTN phone line?
    Where is the DTMF detector and generator object? cool.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
  • Cluso99Cluso99 Posts: 18,066
    edited 2009-03-04 13:37
    Transformers were small and made by Etal (UK) and were not that expensive in the 90's.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps:· SixBladeProp, TriBladeProp
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Beau SchwabeBeau Schwabe Posts: 6,545
    edited 2009-03-04 15:21
    Phil Pilgrim (PhiPi),

    Very nicely done!

    Your front end up to the low-pass filter is very close to what I did with·the Audio Spectrum Analyzer.· I haven't looked at your code, because I did not see it in the OBEX yet, but I assume you can adjust the frequencies to something other than 2200Hz and 1200Hz if you wanted to?· I'm thinking this might be applicable to short distance "spread spectrum·communication" with IR,·if you can also increase the number of channels or "audio voices"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-03-04 15:59
    Is there nothing the Propeller can't do!?!!

    Phil, great object! Now to find an excuse to use it somewhere. [noparse]:)[/noparse]

    Second that DTMF stuff! Be fun to convert my PropBBS stuff over to this.
    This circuit just became a mandatory addition to my Proputer. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Check out: Protoboard Introduction , Propeller Cookbook 1.4 & Software Index
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • rjo_rjo_ Posts: 1,825
    edited 2009-03-04 16:01
    Phil,

    I think I have the worst cell phone service on the planet... half of every word, noise chunks, the whole nine yards.
    Am full up at the moment, but planning to put your system to a REAL test.

    Where can I buy the kit?

    Thanks,

    Rich
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-03-04 16:07
    Now APRS (Automatic Postion Reporting System) is going to be easy with the Prop. Thanks.
  • TreeLabTreeLab Posts: 138
    edited 2009-03-04 16:18
    This is brilliant Phil!

    To follow up on Jay's post, do you know what additional layers would be required to support outgoing and/or incoming APRS?

    Homing in on a balloon flight with a hand-held unit that would compare current position of the operator (via a GPS) with the transmitted coordinates (via RadioPhil) looks feasible now.

    Cheers!
    Paul Rowntree
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2009-03-04 16:50
    @Rich,

    You're sorta joking about buying a kit, right? Don't say stuff like that, because the little business guy inside starts thinking about what I can sell you. This app doesn't require much, as you can see from the schematic. Just a few passives and a transistor, along with a medium to transmit and receive tones (phone line, radios, etc.). Phil cautions against the use of FRS, but it'll do the job, too. There are some restrictions, but you can figure them out.

    @Jay,

    You got that right! 2-meter APRS all the way - that's the plan for my PropBot since Phil made the whole thing accessible to a programming ding-dong like me.

    @Paul,

    Phil's project has some error-checking built into the signal conditioning, but multiple send/confirm/checksum type of operations are necessary. There's no limit to what people may want to do in this regard. My approach for APRS would be simple: send the same thing three times - get the right data twice? If you combine Phil's work with Cam Thompson's Float32 object you can now do APRS with distance and heading calculations. I don't think this would be so easy in other processors, but these guys have packaged up tidy objects that are useful with high-level programming.

    Thanks Phil!

    Ken Gracey
  • rjo_rjo_ Posts: 1,825
    edited 2009-03-04 17:06
    Ken...

    I wasn't joking except for the fact that Phil does all of this incredible stuff and never goes that extra step to put it all in a bag and
    offer it up to the great unwashed masses[noparse]:)[/noparse]

    This kit, I would buy, because if I want to test it, I would want to understand it completely, and most importantly because I would want to build it right[noparse]:)[/noparse]

    I will remind you that in the beginning, I couldn't get Chip's video to work and that requires 4 resistors and a ground line[noparse]:)[/noparse]
    3 tries ... and I only managed to get it to sort of work by adding some potentiometers.

    On the other hand... the little video kit from SpinStudio was really fun to put together and works perfectly. Mindless activity for a mindless moment[noparse]:)[/noparse] AND once you put a kit on sale... it is permanent advertising for the concept and for the Propeller. Otherwise it all becomes a link that no-one can find. What are the chances that a newbie to this site will see this thread three months from now? But if it is on a site somewhere as a kit... it will always be found by googling it.

    Rich
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-03-04 17:59
    I had to abandon my ballon project because it was getting too expensive. I have the radios, but I'm just not impressed with the state of amateur radio electronics, and couldn't stand the though of paying another $100 - $200 dollars for TNCs/APRS transmitters. I was going to just launch with just a cell phone, but that would involve staying close to civilization. After the continental flight ditched in the Hudson near me, I abandoned the project. With Phil's code, I can now make my own hardware, and define the computer–ground hardware protocol the way I want, and launch somewhere far from LGA and JFK.

    I'm committed to another project now, but I'll revisit the ballon when I'm done. Hopefully someone will have written an APRS layer by then, if not, I'll tackle it.
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2009-03-04 18:03
    Rich,

    You have addressed a real communication problem we have (and a support problem/product opportunity as you identified): amazing apps get buried in these forums and never resurface. Having a kit for sale would give it continued presence on our web site. I think we already have the parts in stock, and they're inexpensive, so let me see what I can do.

    I truly appreciate the ideas.

    Ken Gracey
    Parallax, Inc.
  • Sniper KingSniper King Posts: 221
    edited 2009-03-04 18:05
    Now we just have to work out the aprs protocols and aprs in a very very small package becomes a cool reality.· Did you know there is a DIGIpeater on·the space station that uses 1200 baud bell 202 FSK?· Imagine talking wirelessly to your projects (very low bandwidth and limited more to commands) thousands of miles away using the space station as your satellite.· I don't know, maybe an autonomous sailboat??? (http://forums.parallax.com/showthread.php?p=748701)·

    Very Very Cool Phil!



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·- Ouch, thats not suppose to be hot!··


    Michael King
    Application Engineer
    R&D

    ·
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2009-03-04 18:07
    Wow, (again). I'm looking forward to the pdf and trying it out.

    An ARC-5? (For those that don't know, it was a navy surplus transmitter that was popular with DIY hams.) I found a 2007 ARRL handbook on a bargain table, and have it on my shelf near my yellowed 1979 copy. It's a great reference, and I might add, substantially updated! Other ARRL publications are good too. I still have a copy of the surplus conversion manual that I used for an ARC-13 back in the day.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-03-04 18:32
    Michael, there's a few APRS transmitter out there with onboard RF and GPS. With a QFP Prop, Lassen Copernicus GPS with chip antenna, ~300 mW onboard transmitter, and RF jack, you could make a really small low-power high-alt (>60,000) tracker.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-04 19:04
    Thanks, guys! Jeff Martin has emailed me that the object is now publicly visible on the OBEX. Thanks, Jeff!

    Now to answer some questions:

    Peter, the monitor software is written in Perl. If anyone's interested, I could post the source. It's no big secret, except for a total lack of comments.

    William, here is a document I found online that shows several hybrid circuits. I plan to try one as soon as some "real work" on my desk gets done. Radio Shack carries transformers that ought to work for this, although they're not center-tapped, which rules out a few of the circuits presented. As I emphasized in the documentation, though, you need a Part 68 approved DAA to connect anything to the public phone system. A simple transformer is not sufficient.

    William, DTMF generation would be an easy addition to make. DTMF detection is a bit more difficult, since you now have eight frequencies to detect instead of just two. But there's an algorithm (the Goertzel algorithm) that would be more appropriate for this than the I/Q mixers I employed for the AFSK. It's on my list to try.

    Beau, it should not be difficult to change either the baud rate (within reason) or the modulation frequencies. There will be a point, though, where additional frequencies will consume more time to demodulate than is available in one sub-bit time. I've also been thinking about the IR issue but am leaning more towards orthogonal codes for multiplexing — something like CDMA.

    Rich, there is a board in the works that's mentioned in the PDF (Propeller Backpack). I've attached a photo below. (It's the little board rubberbanded to the battery pack.) It contains a Propeller and all the passives and PTT circuitry mentioned in the document, along with some video circuitry. More on this later...

    Jay, Paul, I have no idea about APRS. I guess I've got some reading to do!

    It has occurred to me that 8-bit ASCII is pretty wasteful of valuable bandwidth for sending simple alphanumeric data. I may do a mod for Baudot code, which should improve throughput substantially, although the shifting required is a bit scary over an unreliable data channel. (If you've ever seen a Western Union teletype stuck in the wrong shift, you'll know what I mean.) Forward error correction is very intriguing, too. At these slow baudrates, you want to make the initial transmission as bullet-proof as possible, in order to save handshaking and multiple channel turnarounds, which have a huge overhead. There's also the AX.25 protocol used for amateur packet networks.

    So much to do! smile.gif

    -Phil
    800 x 606 - 76K
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2009-03-04 22:13
    This could have great applications for radio links. The N8VEM and propeller PockeTerm also has a wireless connection to other boards, and these use RF modules that have an onboard microcontroller that takes the RS232 and sends it out the other end cleanly. I'm using 1200 baud at 433 Mhz (interesting comments about the space station) because it goes a lot further than higher baud rates. The thing is that these modules cost 10x the price of an equivalent raw RF module, for the same amount of power. You can't feed raw RF into a uart because white noise will eventually trigger a byte output, even when one wasn't sent.

    As heater manages to squeeze more and more instructions into the CP/M project, one could envisage having another cog devoted to running modem software into a raw RF module, and hence save another $20. CP/M itself *might* be fast enough to process audio signals with a dedicated A to D chip and 8Mhz or more on the clock. But it wouldn't be able to do anything else. This is where the multiple cog concept of the propeller really shines.
  • Cluso99Cluso99 Posts: 18,066
    edited 2009-03-05 04:27
    To connect to the PSTN (telephone network) you are correct in requiring license. But for testing, with o phone off-hook, a simple transformer will work. I will try and dig out my DAA circuit (used on my 33.6Kb modems) which was approved (with the rest of the modem circuit) for connection to Australian and New Zealand PSTN networks.

    Alternately, if the required online power is less than (90mA from memory) you can draw this from the line (if the only one on the line) and opto isolate the 1200 baud serial side. This would be a much simpler circuit - no transformer. It will be too expensive to have it certified, given the return on investment. :-(

    There is a packet modem (Pactor) used by the boating fraternity (and amateurs?) on HF Radio. APRS is also mentioned. It sells for >$1000. A replacement for this would be fatastic, but it uses compression and forward error correction. Originally started at 1200 baud. http://www.scs-ptc.com/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps:· SixBladeProp, TriBladeProp
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-03-05 13:44
    For anyone wanting to use Phil's code for APRS, this is the document you'll need. I'd take it up, but I'll be working on a different project for a while.
  • TreeLabTreeLab Posts: 138
    edited 2009-03-05 16:52
    Jay, was there a document attached to your message?

    The Tucson radio group (http://www.tapr.org/) has extensive docs on coding APRS directly using PIC systems, sometimes with a modem chip. They have quite a strong hardware orientation too. The code is generational, so sometimes it is hard to find the original source, but the group is quite helpful. I tried to do this with a prop, but did not get much more than static out. The CRC beat me, as did some of the compression issues. Obviously, this forum attracts a better breed of coders than I !

    As Jay pointed out, if the radio link is solid and you are willing to roll your own code on the receiver, there is no fundamental need to use APRS packet protocols.

    Cheers!
    Paul Rowntree
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-05 17:16
    Paul,

    The word "this" in Jay's message is a link to the PDF. It took me several tries, since the ftp site was busy. APRS appears to be a layer on top of AX.25. Here is a link to the AX.25 protocol stuff, for anyone who wants to wade through it.

    I agree that for simple position reporting, there are surely less complicated ways to do it. But they probably wouldn't be compatible with the wealth of real-time mapping software that's available.

    -Phil
  • The CrimpsterThe Crimpster Posts: 7
    edited 2009-03-10 18:28
    Thanks for creating this object Phil! My university is receiving two Parallax Quad Rovers and I've starting working on some communication protocols that we can use once those bots take off on their own. I haven't dug too deeply into your code, so you may have already answered this... Does your transmit method check the frequency for active transmissions before it begins to transmit? I suppose all it would take to add that is a check of the signal method's 31 and 19 bits, if they are both clear then the frequency would be open.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-10 20:52
    No, the transmit routine doesn't do any checking before transmitting. It's difficult to check for a carrier from the audio side, since it may not be modulated. While the 31/19 check would indicate whether another AFSK station is transmitting, and may also work with any modulated carrier if you take enough samples, an unmodulated carrier could cause enough audio quieting to make it indistinguishable from the squelch.

    Some radios can inhibit transmission if they detect a carrier strong enough to break squelch. The Yaesu VX-2R, for example, has a "busy channel lockout" setting which blocks PTT initiation if another station is transmitting. But it won't inform you that it's done so, except that the red "transmit" light won't come on. It may be possible to kludge a sensor onto the LED to see if it turns red after triggering the PTT. The same LED also lights green when a carrier has been detected during receive. Again, a sensor could be kludged onto it to detect a busy channel before activating PTT. Both are rather inelegant solutions, and I wish there were something better...

    -Phil
  • The CrimpsterThe Crimpster Posts: 7
    edited 2009-03-11 01:41
    Thanks Phil,

    I hadn't thought about that lockout feature, that'll work for now. I'll be operating on the digital simplex portion of the 2 meter band and Arizona's frequency coordinator should have a chunk specifically marked for digital modes only, I'll see how the 31/19 check works for that.

    I came up with another question while I was setting up a test circuit...

    Which method of demodulation would you suggest we use?

    I used the "thresholding" method to test with and I seemed to get pretty good results. Is there a big benefit to the A/D method?

    -Sean KD0EHH
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-11 03:51
    Sean,

    You'd just have to try it with your radio. Also, unless you can solder the feedback resistor very near the Prop chip, the A/D method may be more trouble than it's worth. Finally, while using the A/D method, I've cranked up the speaker volume high enough to get clipping (equivalent to thresholding), with no apparent decrease in reliability. Looking at it theoretically, I suppose the mixers are efficient enough at filtering out the square waves' odd harmonics that the latter do little to interfere with detection.

    -Phil
Sign In or Register to comment.