serout


Closed Thread
Results 1 to 11 of 11

Thread: serout

  1. #1
    Join Date
    Jun 2006
    Posts
    40

    Angry serout

    Hi,
    Anyone out there can help me solve this problem ? i have been trying to get my pic 16F84 to control an external 33.6k serial modem.
    The modem work fine with hyperterminal. But it doesn't work with PIC.

    PortB.1 is connected to pin10 of MAX232 ( TTL in ) and MAX232 pin7 ( 232 out ) is connected to pin 3 of modem DB9.
    Pin 4 & 6 of DB9 is shorted ( DTR & DSR ).
    Pin7 & 8 of DB9 also shorted ( RTS & CTS )

    CODE SAMPLE :

    TRISB=%00000000 'PortB.0 & PortB.1 = output
    Dialing VAR PORTB.0 'Set PortB.0 as Dialing indicator
    Tx VAR PORTB.1 'Set PortB.1 as Transmit signal to modem
    PORTB=%00000000

    Pause 1000
    MAIN :

    High Dialing
    SerOut Tx,t300,[65,84,72,49] ' Off Hook ATH1
    Low Dialing
    End


    What is the catch ????

  2. #2
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Try...
    Include “modedefs.bas”

    The Mode names (e.g. T2400) are defined in the file MODEDEFS.BAS.
    To use them, add the line:
    Include “modedefs.bas”
    to the top of the PicBasic Pro program. BS1DEFS.BAS and
    BS2DEFS.BAS already includes MODEDEFS.BAS. Do not include it again
    if one of these files is already included. The Mode numbers may be used
    without including this file.
    Last edited by rhino; - 18th March 2007 at 18:33.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  3. #3
    Join Date
    Jun 2006
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    modedefs.bas is included but still doesn't work...

    i also tried :
    1. inverted TTL N300 to N2400
    2. change Define Char_pacing 1000 to 10000

    however it still not working...

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,529


    Did you find this post helpful? Yes | No

    Default

    Hi,
    What is the clock frequency and what do you use as the clock source? For serial communication to be reliable you really should use a X-tal. What baudrate did you set Hyperterminal to when testing the modem? 300baud?

    /Henrik Olsson.

  5. #5
    Join Date
    Jun 2006
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    I use 4MHz resonator. i did use the same type of resonator before when i did a serial comm project between 2 remote PIC 16F84 at 1200baud.

    In Hyperterminal, i tried 300 baud, 1200 baud and 2400 baud. All working fine. The only difference i noticed with this baud rates is the speed and it is obvious when i type AT&V.
    A modem should detect the baud rate automatical isn't ?

    mychangl

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,529


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Generally you should be fine with the resonator. Are you sure that the PIC is running? Blink a LED a few times at the beginning of the program to make sure. And if you can, try with a X-tal just to be sure.

    You do have the PIC's ground and the modems ground connected don't you? The modem ground should be on PIN 5 in the DB9 but you didn't mention that in your original post.
    I have no knowledge of AT commands so I can't help with that but assuming it's correct have you tried:
    Code:
    SerOut Tx,t300,["ATH1"] ' Off Hook ATH1
    Also, is it possible that the modem needs a linefeed and/or carrage return at the end of the command?

    /Henrik Olsson.

  7. #7
    Join Date
    Jun 2006
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    the LED is blinking. i even put LED to monitor the serial output, it is flickering. Modem ground is connected to PIC gnd.

    neither
    SerOut Tx,t300,["ATH1"]
    SerOut Tx,t300,["ATH0"]
    SerOut Tx,t1200,["ATH1"]
    SerOut Tx,t2400,["ATH1"]
    SerOut Tx,t9600,["ATH1"]

    work, i not sure about line feed or carriage.There is no information about linefeed and carriage found in any modem articles, even hyperterminal doue not require that..

    Anyway, let me try

  8. #8
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Something to try - see if you can get your pic to talk to hyperterminal (using your max232 setup as is). This might help you determine if the problem is closer to the PIC side or closer to the modem side.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  9. #9
    Join Date
    Jun 2006
    Posts
    40


    Did you find this post helpful? Yes | No

    Thumbs up

    Thanks guys. i got the code....

    it should has carriage return ( 13 ) after the command.

    SerOut Tx,t9600,[65,84,72,49] ' Off Hook ATH1'
    SerOut Tx,t9600,[13]

    now i am looking into more functions eg connect to other modem...

    Thx a lot !
    Cheeeeers

  10. #10
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,529


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Glad to hear you got it going!
    A little tip: Put the carriage return on the same line as the 'command'
    Code:
    SerOut Tx,t9600,[65,84,72,49,13] ' Off Hook ATH1, CR
    Should work the same and you'll save a couple of bytes for each instance. Also Serout....["ATH1",13] should work the same but makes the code easier to understand, to me atleast....YMMV.

    Good luck with the project!

    /Henrik Olsson.

  11. #11
    Join Date
    Jun 2006
    Posts
    40


    Did you find this post helpful? Yes | No

    Cool

    That is just the beginning...
    ["ATH1",13] work fine ! Thanks for all your suggestion.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26
  5. Replies: 11
    Last Post: - 13th July 2005, 19:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts