PDA

View Full Version : No Modem response



jimboho
- 3rd November 2004, 11:40
Hello,
I am fairly new to programming PIC's and I have run into a complete wall. I am trying to interface a modem with a 16LF84A. The modem module I am using is a SLM2405 made my Wintec. It has a Silicon Labs chip set(SI2403) . I connection via the serial(UART) mode. According to the data sheet if I send the "AT" command I shoud recieve an "OK" from the modem. I am pretry sure the "AT" command is getting to the modem but I am not getting anything back from it. I have also connected an LCD to Display the recieved data from the modem. The modem uses a 3.3v supply and didgital input., so I am using a LP PIC and running the whole system on 3.3V . I have th LCD connected to PortA qnd the modem connected to PortB. The following is the code I am using.
[code]
'

' PIC: 16LF84A (low voltage)
' LCD connections
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
'
' RXD PortB.6
' TXD PortB.7
' RESET PortB.5

Include "modedefs.bas" ' Include serial modes

LF CON 10 ' Line feed constant
RXD VAR PORTB.6 'recive data pin
TXD VAR PORTB.7 'transmit data pin
RESET VAR PORTB.5 'reset pin
SRIN VAR byte[2] 'array to hold modem tx data



SRIN[0]=0 'init SRIN byte to zero
SRIN[1]=0 'init SRIN byte to zero
pause 1000

loop: Lcdout $fe, 1 ' Clear LCD screen
Lcdout $fe,$80
Lcdout "Reseting Modem"

'Reset Command. reset pin must be held low for 300ms then return
'to high state within 5ms.
low reset
pause 300
high reset

pause 1000
Lcdout $fe, 1 ' Clear LCD screen
Lcdout $fe,$80
Lcdout "Sending"
Lcdout $fe,$C0 ' Move curser to second line
Lcdout "serout command"

serout2 TXD,813,["AT"] 'Send AT command to modem
pause 200
serin2 RXD,813,3000,cont,[STR SRIN\2] 'Recieve 2 bytes from modem
cont:
Lcdout $fe, 1 ' Clear LCD screen
Lcdout $fe,$80
Lcdout "recieved: ",#SRIN[0],#SRIN[1] 'Display results from Modem

finish:
goto finish
[\code]
I hope I have covered everything and my question is clear, if I have missed something please let me know.
any help would be greatly appreciated.
thanks

Jim

Dave
- 3rd November 2004, 12:10
Hello Jimboho, I see a problem in that you are always sending the "AT" command.

loop1:
serout2 TXD,813,["AT"] 'Send AT command to modem
pause 200
goto loop1

Get rid of the "goto loop1" and you should receive some data. Also I beleive you need to send a cariage return as part of the "AT" string as such...

serout2 TXD,813,["AT",13] 'Send AT command to modem

Hope this helps.

Dave Purola,
N8NTA

jimboho
- 3rd November 2004, 12:21
OOPS thanks for catching that Dave,
I posted the wrong code.
here is the correct code


' PIC: 16LF84A (low voltage)
' LCD connections
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
'
' RXD PortB.6
' TXD PortB.7
' RESET PortB.5

Include "modedefs.bas" ' Include serial modes

LF CON 10 ' Line feed constant
RXD VAR PORTB.6 'recive data pin
TXD VAR PORTB.7 'transmit data pin
RESET VAR PORTB.5 'reset pin
SRIN VAR byte[2] 'array to hold modem tx data



SRIN[0]=0 'init SRIN byte to zero
SRIN[1]=0 'init SRIN byte to zero
pause 1000

loop: Lcdout $fe, 1 ' Clear LCD screen
Lcdout $fe,$80
Lcdout "Reseting Modem"

'Reset Command. reset pin must be held low for 300ms then return
'to high state within 5ms.
low reset
pause 300
high reset

pause 1000
Lcdout $fe, 1 ' Clear LCD screen
Lcdout $fe,$80
Lcdout "Sending"
Lcdout $fe,$C0 ' Move curser to second line
Lcdout "serout command"
serout2 TXD,813,["AT",13] 'Send AT command to modem
pause 200
serin2 RXD,813,3000,cont,[STR SRIN\2] 'Recieve 2 bytes from modem
cont:
Lcdout $fe, 1 ' Clear LCD screen
Lcdout $fe,$80
Lcdout "recieved: ",#SRIN[0],#SRIN[1] 'Display results from Modem

finish:
goto finish

oh, by the way, how do you keep the code snipets formatted?

thanks

mister_e
- 3rd November 2004, 16:05
one thing i suspect is your pause 200 line. remove and let us know.




to keep code formated read this
http://www.picbasic.co.uk/forum/misc.php?s=&action=bbcode

you'll use code between brackets

so this will look like this


loop VAR BYTE
killsw VAR BYTE
a VAR BYTE

start:
While killsw
for loop=1 to 112
a=a+1
next
wend
goto start:



what an unusefull code from myself brain :)

as i see you place the slash in the wrong side in your first post. must be /code between bracket instead of \code between bracket.

regards

jimboho
- 4th November 2004, 04:35
ok,
I removed the pause 200 line and changed it to the following


serout2 TXD,3313,["AT",13] 'Send AT command to modem
serin2 RXD,3313,2000,cont,[SRIN[0]] 'Recieve 2 bytes from modem


I changed the #of bytes recieved to 1 because the modem manuf. returns a "O" instead of "OK" when an AT commant is given. before my serin2 would time out. After changing it to 1 byte it no longer times out, but I dont recieve an "O" I am getting 255 returned.

any ideas?
Jim

mister_e
- 4th November 2004, 04:59
o.k, i'm may be wrong in some place but is it suppose to be an 300 baud,1200,2400 baud comm

there's a simple way to verify if you receive an OK from.
serin2 RXD,3313,[WAIT("OK",SRIN[0]]

SRIN[0] will have the next value send after OK.

you may also try
serin2 RXD,3313,[WAIT("O",SRIN[0]]

this will wait for O, you should have K in SRIN var.

let me know what is bout now

regards

jimboho
- 4th November 2004, 08:27
well I tried adding the wait but it did not help, it just timed out.
It may be my modem, I beleieve I have every thing connected correctly. I have one question about RTS and CTS when using an UART interface. is it required to use them? I am leaving those pins open on the modem, could this pe the root of my problem?

thanks again

Jim

Luciano
- 4th November 2004, 10:26
On reset baud rate = 19200 !?!???

See link below.


Regards,


Luciano


http://www.wintecindustries.com/oem/download/print_modem.pdf


On reset, the DIP Modem defaults to command mode and accepts AT commands at a default serial UART rate of 19.2 kbps. After the device is configured, the outgoing modem calls can be made by way of the ATDT# (tone dial) or ATDP# (pulse dial) command. If the handshake is successful, the modem replies with response codes and immediately enters into data mode. The ATO command can also be used to enter data mode. In data mode, AT commands are no longer accepted. The DIP Modem reverts to command mode if the modem connection is terminated, or through the use of +++ escape sequence.

jimboho
- 5th November 2004, 02:20
The data sheet for the modem says that if a pin26 on the modem is pulled low with a resistor <=10K it will put the modem into autobaud mode. I assume the 2400 baud that I am sending at should be ok, am I right in this thinking?

Jim

mister_e
- 5th November 2004, 02:41
Is by any chance you have an 20MHZ crystal to test it at 19200 BAUD? but also you must have a PIC who's able to run @ 20MHZ.

Auto Baud detect... might work also. but since i've never do it before, i can't tell anything about that.. My assumption is autodetect will work for signal wich goes from PIC to the MODEM... but for the data from MODEM to PIC must be set by another way or it's always 19200 baud

BTW i found something about GSM phone here... maybe there's something to help you in.
http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=219


regards

Luciano
- 5th November 2004, 10:40
Connect your modem to the serial port of your PC.
Do your testing with Hyperterminal or similar program.
Start without autobaud mode, with DTE rate set to 19200.
Once you are able to comunicate at 19200 then try to enable
autobaud mode with the pulldown resistor and use a different
DTE rate with Hyperterminal.

Important!

Make sure you use RS-232 level translator (MAX232 type) between the RS-232 serial port of your PC and the TTL serial port of the Si2403.

Regards,

Luciano

* * * * * * *
Terminal program:
(No setup, only one EXE file).

Terminal v1.9b 20040714.

Where to download:

http://bray.velenje.cx/avr/terminal/

* * * * * * *

Luciano
- 5th November 2004, 16:35
One more idea:

* * *

(From the manual of the compiler).

In some cases, the transmission rates of SEROUT2 instructions may present characters too quickly to the receiving device. It may not be desirable to use an extra pin for flow control. An optional Pace can be used to add character pacing to the serial output transmissions. This allows additional time between the characters as they are transmitted. The character pacing allows a delay of 1 to 65,535 milliseconds between each character transmitted.

* * *

Maybe too quickly for the autobaud feature of your modem. Try to use the option PACE of the serout2 command.

Or just for a quick test instead of the PACE option:

serout2 TXD,396,["A"] 'Send A to modem
pause 100
serout2 TXD,396,["T"] 'Send T to modem
pause 100
serout2 TXD,396,[13] 'Send <CR> to modem
pause 100

Remember that autobaud is enabled only in command mode. When you go in data mode autobaud is disable.

Regards,

Luciano

jimboho
- 6th November 2004, 10:58
OK,
I tried connecting the modem to my serial port on my PC via a MAX232 and did not have any luck all I got through the terminal windo was some garbage. One thing I was thinking ok, (Im not a Electronics Guy) is it possible that the modem is getting some of it's power through the 48V of the phone line? I have not had the phone line hooke up through most of my testing? I do have a 20MHZ Crystal and tried hookinig it up to my 16F84A but can't get it to work(can't even make a LED flash). The data sheet says it can go up to 20MHZ.
I am going to try the single character statments as suggest by
Luciano.

thanks

Jim

mister_e
- 6th November 2004, 19:45
>I do have a 20MHZ Crystal and tried hookinig it up to my 16F84A but can't get it to work(can't even make a LED flash). The data sheet says it can go up to 20MHZ.


what is exactly the p/n on your PIC... PIC16F84A-20 ??

if not, it will never run @20Mhz.

In case you have PIC16F84A-20, you must add this line a the begining of your program

DEFINE OSC 20 ;tell PBP that you run @20MHZ

You also must configure your prgrammer to set Oscillator Fuse to HS mode.

Luciano
- 7th November 2004, 12:10
Hi Jim!

Call the Wintec Technical Support for help and consider purchasing the evaluation board for your modem.

Regards,

Luciano

* * * *
Modem evaluation board:

http://www.wintecind.com/oem/slm_modem.html#EB

A companion evaluation board is available for evaluating the functionality of the Wintec SLM embedded modems.

* * * *

Wintec Customer Service

4280 Technology Drive,
Fremont, CA 94538

Tel: (510)-360-6386
Fax: (510)-623-7943
E-mail: [email protected]

Hours: Monday - Friday 9:00 am - 5:00 pm PS


Wintec Technical Support

4280 Technology Drive,
Fremont, CA 94538

Tel: (510)-360-6210
Fax: (510)-623-7943
E-mail: [email protected]

jimboho
- 11th November 2004, 02:51
Hi All,
Well I finally got the modem to work with the max232 and the serial port. I also got it to accept AT commands from the pic and it returns "OK" when send it "AT". However I am having more problems (go figure). When I send the AT command "ATI6" I should get a "2403” response, which I get when hooked up to the serial port on my PC. When hooked up to the PIC all I get is a bunch of numbers which I can't find any discernable pattern to. I know when I read the "OK" back from the "AT" command I have to strip off 4 bytes before I get to the "OK". Is it possible that
I need to strip off more bytes for the "ATI6" command I read in 10 bytes and didn't see anything like I should be getting. I will post the 10 bytes I received from the modem may one of you can see something I didn't. Or if any one else has any Ideas that would be great.

regards

Jim

mister_e
- 11th November 2004, 05:58
What is your baud rate? crystal used for PIC? what are the results from PIC?

Can you provide the whole code you're using?