Shop OBEX P1 Docs P2 Docs Learn Events
DTMF Out on the SX — Parallax Forums

DTMF Out on the SX

skynuggetskynugget Posts: 172
edited 2010-05-12 16:11 in General Discussion
has anyone ever gotten the sx28 to make dtmf tones in sx/b?

i found some VP AppNote about it, but its a bit over my head, lol


thanks!

Comments

  • John CoutureJohn Couture Posts: 370
    edited 2010-04-26 19:53
    If I may humbly suggest that the SX is not well suited to that type of activity. DTMF means that you have to produce two PRECISE tones at the same time. The SX can do it but you would burn far fewer brain cells by using something like a DTMF transciever and having the SX control it That way the SX is doing the heavy lifting of calculations, monitoring inputs, sending status messages, etc.

    Take a look at the datasheets for:

    MT8889C - Integrated DTMF Transciever (about $5?)
    TCM5089N - Touchtone Generator (Jameco 32803, $5)
    LM567 - Tone Decoder ($1) Althought you can wire several of these together to interpret DTMF signals, this is probably more useful for detecting a single tone.
    CM8880 - PDIP20 DTMF Transciever
    CD22202 - DTMF decoder
    TelTone 8870 - http://www.boondog.com/tutorials/dtmf/dtmf.htm#Parts


    Just a suggestion.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-04-27 00:21
    I can think of a way and the DTMFing is·probably all it'll be doing, can't/won't say for sure at this point.· [noparse][[/noparse]Strobe data for me, baby.]· I need to use an op-amp and some resistors, too.· It'll be "square waves" out.·

    Don't worry, John Couture, because you can still help with the INTERRUPT.
  • skynuggetskynugget Posts: 172
    edited 2010-04-27 13:24
    thanks john couture, im trying to make an auto dialer with as few parts as possible. if it can be done on a bs2, the sx should surly be able to!

    pj allen, i would think square wave would throw out to much trash for a dtmf decoder to interpret.

    here's the src and doc from the vp library, I'm thinking it can be modified to run in the interrupt. I guess i should finally start learning assembly.

    Post Edited (skynugget) : 4/27/2010 2:02:35 PM GMT
  • YendorYendor Posts: 288
    edited 2010-05-03 19:28
    The sx should be able to easily do this with the pitch vp in software and minimal RC hardware.

    http://forums.parallax.com/showthread.php?p=741247

    2 notes to generate dtmf in the interrupt should be easy to implement - just a small increase to your interrupt.· I think Jon actually did a polyphonic version in the thread.

    I've been able to do up to 4 simultaneous notes playing music the same time, using a similar concept.· I'm sure·more can be done, as most of the interrupt·I was using·to calculate note·durations for each track.

    Use the filter circuit·(RC) shown in the piezo buzzer to smooth out the square wave.

    Let us know if you have any questions and/or how it goes!
    ·
  • skynuggetskynugget Posts: 172
    edited 2010-05-04 18:43
    ok all, heres what i got so far... they sound like dtmf tones, but a lil off.

    so far I've just been able to compare between a bs2's dtmfout using the PDB internal amp/speaker

    pritty soon ill be able to get to a buddies scope and figure out whats up.

    thanks for everyone's help thus far!

    here is zee code, and pitch sheet
  • YendorYendor Posts: 288
    edited 2010-05-04 19:02
    Cool

    I didn't look at your code closely, but I saw you're dividing the pitch count by 2 in your excel sheet. Can you elaborate?

    I did some calculations yesterday, and you should be able to get the pitches under 0.15% accuracy (there's only 1 pitch thats 0.14%, the rest are lower) but can't remember if it was at 20MHz or 50MHz.

    The phone system specs has a variation of at least 1%, so you should be able to get pretty darn close.
  • skynuggetskynugget Posts: 172
    edited 2010-05-04 19:34
    ah, i saw in the previous thread that jonnymac used a 4us (instead of 8us) interrupt cycle for better accuracy. It sounded like a good idea, so i just coppied his sheet, and plugged in the dtmf frequencies.
  • YendorYendor Posts: 288
    edited 2010-05-04 19:52
    I haven't studied his code, but as the duration is the same just use two of the code that's in the original post.· 50MHz will definately get you more accuracy.· Just as an example:

    DTMF_ISR:
    IF PitchFlag1 = 1 THEN ' ok to play?
    IF MyPitchCount1 = PitchCount1 THEN ' see if ready to toggle waveform
    Piezo1 = ~Piezo1 ' togggle waveform
    MyPitchCount1 = 0 ' reset waveform
    ELSE
    INC MyPitchCount1 ' inc counter
    ENDIF
    ENDIF

    IF PitchFlag2 = 1 THEN ' ok to play?
    IF MyPitchCount2 = PitchCount2 THEN ' see if ready to toggle waveform
    Piezo2 = ~Piezo2 ' togggle waveform
    MyPitchCount2 = 0 ' reset waveform
    ELSE
    INC MyPitchCount2 ' inc counter
    ENDIF
    ENDIF

    Post Edited (Yendor) : 5/4/2010 8:05:01 PM GMT
  • skynuggetskynugget Posts: 172
    edited 2010-05-04 21:43
    in the post jonnymac had some code with 3 tone generators and an rx_ uart. i basically just trimmed out the uart and the 3rd generator.

    i got a chance to check the output freqs on my mickey mouse frequency counter. here is what i came up with

    WDATA 179 ' Freq: 697Hz Counts at 694hz
    WDATA 162 ' Freq: 770Hz Counts at 766hz
    WDATA 147 ' Freq: 852Hz Counts at 844hz
    WDATA 133 ' Freq: 941Hz Counts at 933hz

    WDATA 103 ' Freq: 1209Hz Counts at 1201hz
    WDATA 92 ' Freq: 1336Hz Counts at 1315hz
    WDATA 86 ' Freq: 1477Hz Counts at 1436hz

    i tried tweaking the values to get them any closer, but the values on the sheet seem to be the closest...
    back to the drawing board, doh!
  • YendorYendor Posts: 288
    edited 2010-05-04 22:34
    here's a data sheet that supports +/- 1.5 % tolarance

    http://www.datasheetarchive.com/datasheet-pdf/020/DSA00351816.html

    your 694 to 697 is 0.4%, well within tolarance.

    You can also reduce the interrupt cycle time for even more accuracy, just watch out for overflows

    ·
  • skynuggetskynugget Posts: 172
    edited 2010-05-04 23:42
    thanks yendor, duh i was doing my math wrong, so far i think all my tones are within .9% now. 1336hz = 92 and it all fits!
  • YendorYendor Posts: 288
    edited 2010-05-05 00:10
    Excellent, glad we can help, and I hope it's finally working for you. If not, post your results, and me or someone will help out with the code. I was about to give it a try to get it working for you.

    Also your counters are less than a byte, so you really don't have to use words. The code was based on the midi baud rate using a 200 cycle time. if that is all what your doing with you interrupt, you can reduce the cycles, increasing your frequency accuracy. Just make sure you update your calcuatios to reflect, and note the RTCC overflows. If you approach in this way, you can do # cycle counts or you can cheat by using the SxSim, and check mark the Check RTCC box. if you don't get an error message for a while, you're good to go.

    Your next assignment is to duplicate caller id [noparse]:o[/noparse])
  • skynuggetskynugget Posts: 172
    edited 2010-05-06 16:23
    it works! i found a cm8880 based decoder , and it lights off every digit! ill post the code once its clean, thanks everyone


    UPDATE:

    here it is, all cleaned up, and ive added a simple "dial" routine for dialing strings.

    special thanks to Yendor and JonnyMac one more time!

    and as always, if you make it better, pleas share with the rest of the class.

    Post Edited (skynugget) : 5/6/2010 6:59:40 PM GMT
  • pjvpjv Posts: 1,903
    edited 2010-05-07 03:47
    Hi All;

    Been away from the SX forum pretty much since the EOL announcement, and have largely shifted over to the Propeller. There I'm doing things in assembler because the SX made me comfortable with that, and someday perhaps I'll learn SPIN.

    Anyhow, this DTMF issue rang a familiar pulse with me as I had been doing SX work in that domain a long time ago.

    I wrote a dual channel tone generator that made two sine waves, and was able to digitally vary the phase between them. As you know, summing two sine waves of the same frequency generates a single sine wave of the same frequency but with an amplitude being a function of the phase.

    Anyhow all of this led to me entering a Parallax contest in 2004/05 and used this code to demonstrate some other things. That software would be very easy to adapt to your needs of two sine waves at different frequency. The code was pretty simple. Looking back at the Parallax (old 2004/5) contest entries (I have two entries listed that year, so look for the correct one if you are interested), butt found that the formal write-up and code sections were no longer available.

    If you are interested, I'd be prepared to dig out some of my archives from 10 years ago when I wrote that code, and post it here.

    It is written in assembler, so if SX/B is a must, you'll have to do your own conversion.

    Cheers,

    Peter (pjv)
  • skynuggetskynugget Posts: 172
    edited 2010-05-08 00:38
    yeah peter, id love to see it.
  • John CoutureJohn Couture Posts: 370
    edited 2010-05-09 16:23
    Another alternative to using an SX for DTMF is the TP5088 DTMF Generator Chip from National Semiconductor.· PDIP 14, about $4.·

    Source:http://wulfden.org/TheShoppe/misc.shtml

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • YendorYendor Posts: 288
    edited 2010-05-10 18:36
    I apologize for steering you the wrong way skynugget.

    It may have to do with being square waves rather than sine waves.

    [noparse][[/noparse]edit] below is Peter's dual sinewave info.

    Post Edited (Yendor) : 5/10/2010 6:43:54 PM GMT
  • skynuggetskynugget Posts: 172
    edited 2010-05-10 22:24
    thanks for the help yendor,
    finally built my phone interface, and it seems the phone company doesn't like the tones as much as my dtmf decoder does. looks like square waves aren't going to work. hopefully i can wrap my head around peters code. thanks for posting!
  • pjvpjv Posts: 1,903
    edited 2010-05-12 04:52
    Yendor;

    Thanks for finding that contest entry of mine. I had not yet located my archive files, and now I don't need to. I hope it had been of some use or interest to you.

    If skynugget decides to try and study it he'll be pleasantly surprised by its simplicity.

    Cheers,

    Peter (pjv)
  • skynuggetskynugget Posts: 172
    edited 2010-05-12 16:11
    Ok! Now I'm getting somewhere!
    I was able to port over the VP DTMF demo, and now I've got some DTMF on the scope! on one pin!

    thanks again everyone.

    UPDATE: here is the final code, telco approved! thanks again everyone. i suppose you could also use it for any frequency you can clock, the math to get the value is in the code.

    Post Edited (skynugget) : 5/16/2010 9:15:43 PM GMT
    2048 x 1536 - 310K
Sign In or Register to comment.