Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 18th December 2008, 03:50 AM   #1
Default PIC 18F2550 and MT8888 DTMF Transceiver

Does anyone have any experience with interfacing an MT8888 DTMF transceiver to a PIC controller? Basically I have been having fits trying to get the timing correct to output a tone. Any help at all would be appreciated.

Thanks, Don:
dbachman is offline  
Old 18th December 2008, 04:13 PM   #2
Default

I need to be able to send the 4 bit code representing a number and have the MT8888 produce the tone . Also, I would need to decode the incoming tone to the MT8888 and send the 4 bit code to the PIc.

Thanks, Don
dbachman is offline  
Old 18th December 2008, 04:16 PM   #3
Default

Post your schematic and code.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is online now  
Old 18th December 2008, 08:39 PM   #4
Default

This is how it is wired and here is some code I have tried.

Code:
OSCCON = $60 ' Set up internal oscillator


x var byte
dtmf var byte

CS var portb.4 'Enable or disable MT8888
RD var portb.5 'Read Microprocessor input
WR var portb.6 'Write Microprocessor input
RS var portb.7 'Register Select

data @1,8,7,0,7,3,7,5
TRISB = %00000000
portb = %11000000
portb = %10100000
portb = %10100000
portb = %10101000
portb = %10100000
portb = %11000000 
pause 10
Send_DTMF:
portb = %10101101 'Send Control Register A
portb = %10100000 'Send Control Register B

portb = %10100110 'Send digit = 7
 
portb = %10100100 '    Send digit = 5



Goto Send_DTMF
Attached Thumbnails
PIC 18F2550 and MT8888 DTMF Transceiver-pic.jpg  
dbachman is offline  
Old 19th December 2008, 11:28 PM   #5
Default

Blueroomelectronics,

I posted my code and schematic the other day - now what?
dbachman is offline  
Old 20th December 2008, 05:49 AM   #6
Default

Quote:
Originally Posted by dbachman View Post
This is how it is wired and here is some code I have tried.
Code:
Send_DTMF:
portb = %10101101 'Send Control Register A
portb = %10100000 'Send Control Register B
portb = %10100110 'Send digit = 7
portb = %10100100 '    Send digit = 5
I'm not familiar with PIC basic but:
You need to setup the D0-D3, RSO and CS pins first while maintaining WR and RD high. Then you wait a minimum of 45ns. Then you toggle WR low for a minimum of 150ns and then high again to write data to the MT8888. Then you wait a minimum of 100ns. Then you can repeat with the next command. You are trying to do all this with one 8bit write to portB which isn't the same and won't work. You'll also have to read the STATUS register in the MT8888 to see if it is ready to accept new data. ie: You must give time for the DTMF tone to be played before you command it to send the next one.
__________________
Inside every little problem, is a big problem trying to get out.

Last edited by kchriste; 20th December 2008 at 05:59 AM.
kchriste is offline  
Old 20th December 2008, 06:22 PM   #7
Default

Quote:
You need to setup the D0-D3, RSO and CS pins first while maintaining WR and RD high.
What do I do with RS0? I thought it was just used in conjunction with RD and WR to set up the control registers A and B.

Do I set CS low to enable the MT8888? and leave it low?

I am looking at the datasheet 'Typical control sequence for burst mode applications' and I don't see CS in there at all however, it is used in the write timing diagram. I guess I just need to know how you would set up the above quote in a statement or two.

Thanks for jumping in, Don
dbachman is offline  
Old 20th December 2008, 10:37 PM   #8
Default

Quote:
Originally Posted by dbachman View Post
What do I do with RS0? I thought it was just used in conjunction with RD and WR to set up the control registers A and B.
When setting up the control registers or read the status register, you set RS0 high.
When sending or receiving a DTMF digit, you set RS0 low.
Quote:
Do I set CS low to enable the MT8888? and leave it low?
Yes, you could tie it low to ground permanently in this application. It is typically used when interfacing the MT8888 to a microprocessor's data buss where there are multiple devices on the same buss. When it is high, D0-D3, RSO, WR & RD have no effect.
Quote:
Thanks for jumping in, Don
No problem.
__________________
Inside every little problem, is a big problem trying to get out.
kchriste is offline  
Old 21st December 2008, 12:28 AM   #9
Default

I am going to try this, how do you think it looks?

Code:
OSCCON = $60 ' Set up internal oscillator

CS var portb.4 'Enable or disable MT8888 tied to ground
RD var portb.5 'Read Microprocessor input
WR var portb.6 'Write Microprocessor input
RS var portb.7 'Register Select

TRISB = %00000000 'Set portb to output
portb = %11000000
portb = %10100000
portb = %10100000
portb = %10101000
portb = %10100000
portb = %11000000 
pause 10

Send_DTMF:
portb = %10101101 'Set up Control Register A
pause 1 'Wait 1 millisecond
portb = %10100000 'Set up Control Register B
pause 1 'Wait 1 millisecond
portb = %01100000 'Set WR, RD high CS and RS0 and rest of portb low
pause 1 'Wait 1 millisecond
portb = %00000110 'Send digit = 6
pause 10 'wait 10 milliseconds
low WR   'Take portb pin 6 low
pause 10 'wait 10 milliseconds
high WR   'take portb pin 6 high

Goto Send_DTMF 'loop forever
 
End
I am not sure about the MT8888 initialization (datasheet page 4-101) do I need this?
It says to do this 100ms after power up.

Quote:
portb = %11000000
portb = %10100000
portb = %10100000
portb = %10101000
portb = %10100000
portb = %11000000
Thanks again, Don
Attached Thumbnails
PIC 18F2550 and MT8888 DTMF Transceiver-pic-enc-dec1.jpg  

Last edited by dbachman; 21st December 2008 at 02:08 AM.
dbachman is offline  
Old 21st December 2008, 02:31 AM   #10
Default

Quote:
Originally Posted by dbachman View Post
I am going to try this, how do you think it looks?
It's not going to work. I suggest that you create a subroutine for writing commands to the MT8888. Syntax will be wrong, but this is the idea:

Code:
sub WriteControlRegister(command)
   command = command AND 0x0F 'Mask off upper 4 bits with Logical AND
   portb = command OR %11100000 'Set upper 3 bits with Logical OR and send to portb
   pause 1 'Wait 1 millisecond (may not be needed)
   low WR   'Take portb pin 6 low
   pause 1 'Wait 1 millisecond (may not be needed)
   high WR   'take portb pin 6 high
end sub
Then all you need to do is:
Code:
WriteControlRegister(%1101) 'Write to Control Register A (tone out, DTMF, IRQ, Select Control Register B)
WriteControlRegister(%0000) 'Write to Control Register B (burst mode)
You should also write a routine to read the status register, read the Rx data register, and write the Tx data register as these will be common tasks which you'll do a lot.
__________________
Inside every little problem, is a big problem trying to get out.
kchriste is offline  
Old 21st December 2008, 05:10 AM   #11
Default

Hi KChriste,

I think I can figure out how to make and call a subroutine once I get to the point of getting the MT8888 to reliably produce a tone. Unless, you think subroutines would be the best way from the outset. I was just trying to get the thing to produce a tone and then structure the program to read from a data statement.

Is this:
Quote:
command = command AND 0x0F 'Mask off upper 4 bits with Logical AND
portb = command OR %11100000 'Set upper 3 bits with Logical OR and send to portb
The same as this:

Quote:
portb = %10101101

or

portb = %10100000
Depending on which one of these is called

Quote:
WriteControlRegister(%1101) 'Write to Control Register A (tone out, DTMF, IRQ, Select Control Register B)
WriteControlRegister(%0000) 'Write to Control Register B (burst mode)
What is the reason I can't just write - portb = %10101101?

Here is maybe a start:

Code:
OSCCON = $60 ' Set up internal oscillator

CS var portb.4 'Enable or disable MT8888 tied to ground
RD var portb.5 'Read Microprocessor input
WR var portb.6 'Write Microprocessor input
RS var portb.7 'Register Select

TRISB = %00000000 'Set portb to output
command var byte
data @4,%1101,%0000'Data starting at position #4
data @6,8,7,0,7,3,7,5

WriteControlRegister:
       command = command & $0F 'Mask off upper 4 bits with Logical AND
       portb = command | %11100000 'Set upper 3 bits with Logical OR and send to portb
       pause 1 'Wait 1 millisecond (may not be needed)
       low WR   'Take portb pin 6 low
       pause 1 'Wait 1 millisecond (may not be needed)
       high WR   'take portb pin 6 high
Return

WritetransmitRegister:
       command = command & $0F 'Mask off upper 4 bits with Logical AND
       portb = command | %11100000 'Set upper 3 bits with Logical OR and send to portb
       pause 1 'Wait 1 millisecond (may not be needed)
       low WR   'Take portb pin 6 low
       pause 1 'Wait 1 millisecond (may not be needed)
       high WR   'take portb pin 6 high
 return
       
SetupAandB:
for x = 4 to 5
read x, command 'Read data statement starting at location #4 and put in command
gosub writecontrolregister
next x
gosub Setuptransmitregister



Setuptransmitregister:
for x = 6 to 12
read x, command 'Read data statement starting at location #6 and put in command
gosub writetransmitregister
next x

End
Thanks, Don

Last edited by dbachman; 21st December 2008 at 09:00 PM.
dbachman is offline  
Old 21st December 2008, 07:04 PM   #12
Default

Quote:
Originally Posted by dbachman View Post
Unless, you think subroutines would be the best way from the outset.
I highly recommend that you do so. It will make writing our code much easier to understand and you will be less prone to making mistakes. Once the SUBs are written, you'll no longer have to think about the hardware interface with the MT8888 much. ie: you won't have to remember to toggle WR every time you write a nibble to the MT8888.
Quote:
What is the reason I can't just write - portb = %10101101?
Because this:
Code:
WriteControlRegister(%1101) 'Write to Control Register A (tone out, DTMF, IRQ, Select Control Register B)
WriteControlRegister(%0000) 'Write to Control Register B (burst mode)
Is equal to this:

Code:
   portb = %11101101
   pause 1 'Wait 1 millisecond (may not be needed)
   portb = %10101101  'Take portb bit 6 low
   pause 1 'Wait 1 millisecond (may not be needed)
   portb = %11101101  'take portb bit 6 high
  ' Small delay here due to routine above returning

  ' and the routine below being called.
   portb = %11100000
   pause 1 'Wait 1 millisecond (may not be needed)
   portb = %10100000  'Take portb bit 6 low
   pause 1 'Wait 1 millisecond (may not be needed)
   portb = %11100000  'take portb bit 6 high
As you can see, using SUBs will make your code easier to maintain, understand and take up less code space.
__________________
Inside every little problem, is a big problem trying to get out.
kchriste is offline  
Old 22nd December 2008, 02:54 PM   #13
Default

I am having a bit of trouble with the MT8888 as it wants to oscilliate and produce a tone even while it is diconnected from power. Sounds kind of strange but it is still hooked up to the pic. I have completely erased the pic and disconnected it from the MT8888 but when I connect it back up it produces a tone. Before I couldn't get it to make a peep and now it wont shut up. Maybe the cheap solderless board I'm using.

Don
dbachman is offline  
Old 23rd December 2008, 03:03 AM   #14
Default

Remember that the MT8888 is a CMOS device and has built in protection diodes on the inputs which connect to Vdd and Vss. If one or more of the inputs is held high, then the MT8888 will be powered via the protection diode on the input pin.
It could also be a breadboard problem.
__________________
Inside every little problem, is a big problem trying to get out.
kchriste is offline  
Old 26th December 2008, 08:00 PM   #15
Default

Hi Kchriste,

I don't want to seem like I am slacking on writing this code, but I haven't gotten very far with what I have done. I was wondering if you could show me a snippet that produces a tone just to make sure everything I have wired is working ok. I ordered a few more MT8888's just in case I fried this one.

Thanks Don
dbachman is offline  
Reply

Tags
dtmf, mt8888, pic, transceiver

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
18f2550 programming (HW) lez Micro Controllers 4 1st November 2009 10:44 AM
18F2550 ADC troubleshooting theo92 Micro Controllers 0 12th December 2008 01:37 PM
18F2550 USB on VB Express 2008 serkanc Micro Controllers 4 18th May 2008 02:04 PM
18f2550 and cypress FX2 programmer?? patroclus Micro Controllers 15 17th July 2006 09:23 AM
18f2550 programming (SW) lez Micro Controllers 4 6th June 2006 12:45 PM



All times are GMT. The time now is 06:11 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker