OK,
the if-then-part must work !
Just insert this before:
password[0]="1"
password[1]="2"
...
password[7]="8"
and write, what happens !
OK,
the if-then-part must work !
Just insert this before:
password[0]="1"
password[1]="2"
...
password[7]="8"
and write, what happens !
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
I did as you suggested. I hard coded the the password and then sent it thorugh the if then statements and nothing happened, until I press 2 buttons on the phone, and then the menu message played. It will just wait until two buttons, any buttons, are pushed. Wierd huh. This is how I program the chip. Before I actually program the chip, I always erase it, then program it. Here is the snippet of code I used:
@ device pic16F876A, hs_osc, wdt_on, lvp_off, protect_off
include "MODEDEFS.BAS"
define OSC 20
adcon1=7
trisa.0 = 1
trisa.1 = 0
trisa.2 = 0
trisa.3 = 0
trisb = %11111111
trisc = %00000000
'_________pic to mc145436a assignments______________________
dtmf_ready VAR PORTA.0 'pin 12 (DV)
select_dtmf VAR PORTA.1 'pin 3 (Enamble)
reset VAR PORTA.2 'pin 5 (GT)
DT0 VAR PORTB.4 'pin 2 (D1)
DT1 VAR PORTB.5 'pin 1 (D2)
DT2 VAR PORTB.6 'pin 14 (D4)
DT3 VAR PORTB.3 'pin 13 (D8)
ce var portA.3 'pin from isd chip
'____________________variables____________________ ______
dtmf VAR byte ' Stores most recent DTMF digit
dtmf1 var byte
password var byte[8]
codeword var byte[8]
codeword1 var byte[8]
c var byte
e var byte
'___________________Initial Conditions__________________
start:
pause 100
ce = 1
reset = 1
select_dtmf = 0
c = 0
e = 0
loop:
iF dtmf_ready = 1 Then
goto welcome
else
goto loop
endif
welcome:
portc = %00000000
pause 20
ce = 0
pause 20
ce = 1
pause 2000
c = 0
Entry:
pause 100
password[0] = "1"
password[1] = "2"
password[2] = "3"
password[3] = "4"
password[4] = "5"
password[5] = "6"
password[6] = "7"
password[7] = "8"
Pause 1000
password_check:
if password[0] <> "1" then error
if password[1] <> "2" then error
if password[2] <> "3" then error
if password[3] <> "4" then error
if password[4] <> "5" then error
if password[5] <> "6" then error
if password[6] <> "7" then error
if password[7] <> "8" then
goto error
else
goto menu_message
endif
user_password:
if password [0] <> codeword [0] then error
if password [1] <> codeword [1] then error
if password [2] <> codeword [2] then error
if password [3] <> codeword [3] then error
if password [4] <> codeword [4] then error
IF password [5] <> codeword [5] then error
if password [6] <> codeword [6] then error
if password [7] <> codeword [7] then error
goto menu_message
error:
e = e + 1
if e>= 2 then
portc = %10010001
pause 20
ce = 0
pause 20
ce = 1
pause 3000
goto start
else
c = 0
portc = %00001000
pause 200
ce = 0
pause 200
ce = 1
pause 4000
goto loop
endif
menu_message:
portc = %00010010
pause 20
ce = 0
pause 20
ce = 1
menu:
if dtmf_ready = 0 then menu'waits for number to be depressed
gosub GetDtmf 'gets number
branch dtmf1,[menu_message,led1,led2,led3,led4]
Another thing that is interesting, is that after the menu message is done playing, I press a "0" as to send it back to paly the menu message again, but it goes to the top and plays the welcome message again. Thanks a lot for the help. This thing is annoying the hell out of me.
Travin
I don't think you are looking for help....
The code is just unreadable,
we dont know what your "GetDTMF" or "DTMF1" is...
What starts after the branch-command ?
I think the stearing of the mc1..... and the isd..... is wrong or incomplete. There are pause-statements more than needed... the mc1.... isn't resetted after the first keypress....
Why should I write any further ?
Be shure, I'm able to write all the code, but I don't know the hardware and wiring.
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
I apologize for patronizing you. I didn't post the extra code because it is the same as before I thought. I mearly did as you had mentioned. I will not ask for your help anymore. Thanks for the help you have given me up to this point. You have pointed me in the right direction. I will continue to post my updates, in an effort maybe to help others. Thanks.
Travin
Hi Travin,
dont be shocked by me !
dont stuck your head into the sand....
I want to give you help to reach the goal, but you have to learn !!!!
I think there are some gadgets in your circuits, we don't know...
You have no problem in the if-then-part, you have a problem in the communication and timing with your mc- and isd-parts !
You try to write lousy code to talk to them. You have to write subroutines which communicate in the only right way with the chips and you have to use them in your little programm !
I don't think your little problem need such a lot of postings...
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
I guess I am just confused here. The led subroutines are merely a visual aid for the debuggin process. I have about 10 different program written for this contraption. I started with each section of the main program until it worked correctly. Then I moved to the next section and so forth. When I put them all together, they don't work. Like for instance, in the previous post, the branch command didn't work. The led didn't blink on and off for 3 seconds. I know this routine is good. Also, I shouldn't have to push a button twice to go from the if then statements of the password comparison to the menu_message, but it will just sit there until I press two buttons. I know that is no where in the code so I am confused as to why it is like that. Thanks for the help, and I am not uposed to learning. I do a couple of questions for you, in your code you wrote, you have this:
Lookup dtmf-"0",[%10101001,....... My question is what is -"0" for?
Also,
dtmf = 0:dtmf.0=DT0:dtmf.1=DT1:dtmf.2=DT2:dtmf.3=DT3
LookUp dtmf,["_1234567890*#"],dtmf how does the lookup table know which number has been decoded by using this sequence: dtmf.0=DT0:dtmf.1=DT1:dtmf.2=DT2:dtmf.3=DT3
Travin
Last edited by Travin77; - 29th May 2006 at 00:23.
Originally Posted by Travin77
It's a trick !?!
You have:
an ASCII-character (a digit "0"..."9") inside the variable "dtmf"
You want to get:
a bitpattern for the isd-chip.
Solution:
I used the lookup-command to index an bit-pattern. If I subtract the numerical äquivalent of "0" (IMHO 048 dezimal) from the ASCII-character in dtmf, I get an index-number 0..9. The lookup-command gets the bitpattern out of the list (10 patterns) and put it into the portC.
Read it like:Originally Posted by Travin77
Clear all bits in dtmf
Get the bit out out DT0 and put it into dtmf.0
Get the bit out out DT1 and put it into dtmf.1
Get the bit out out DT2 and put it into dtmf.2
Get the bit out out DT3 and put it into dtmf.3
So, the 4 bits are puzzled to the variable ! (index-number)
The lookup-command gets an ASCII-character for this number and stores it into the variable.
You love to work with ASCII-characters. It's not bad, but you have to convert sometimes from index-number to ASCII-character and back.
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
I assume here that when you say index number you mean a binary repesentation of that number. Does this make the pic run smother? By the way, I finally got your code to compile. It won't announce the digits as they decode not will it announce the array after the 8 digits are input. Still trying to make the program work like I need it to.
Thanks
Travin
Last edited by Travin77; - 29th May 2006 at 21:07.
I found the problem. The isd chip is not playing the error or menu message. I put a led in those routines. I know now that the program is getting through them I guess I am not interfacing with the isd chip correctly. Back to the manual. Thanks for the help bigwimpus. If anyone knows how to properly interface to a isd chip (25120) and wouldn't mind sharing there knowledge, this bald guy would appreciate it. thanks again.
travin
Last edited by Travin77; - 30th May 2006 at 03:49.
Bookmarks