Serial Timeout Strange Issues


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Posts
    24

    Default Serial Timeout Strange Issues

    Hey all,
    I am having a strange issue that has been driving me crazy for a couple weeks. Today I figured out how to recreate my problem.
    I have 1 chip sending a serial signal and one receiving. The sender is a PIC16f684 and the receiver is the PIC16f84. I am using the serin2 and serout2. The serout2 works fine but when i have a timeout in the serin2 that is longer than the delay in the sender program, the program hangs up on the serin2 statement. What I mean by this is i had the sender chip counting and sending the result through serial to the receiver. The sender sends the serial and then i have a pause in an infinite loop. If the timeout length in serin2 is shorter than time between the serout2 commands then the serin2 hangs up.

    The end goal is to have a chip refresh servos every 20 ms with angles received through serial. If the sender takes too long i want the sender to wait till the receiver is ready then send but I need the receiver to be able to timeout and refresh the servos.

    Thanks,

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: Serial Timeout Strange Issues

    Any noise on the line will cause the time out to be reset. Is this an RF project?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2011
    Posts
    24

    Default Re: Serial Timeout Strange Issues

    No both chips are on the same board about 2 inches apart with a wire going through a 1k resistor to the other chip. How do I filter out the noise, if any, without filtering out the signal?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: Serial Timeout Strange Issues

    Noise should not be the problem then.

    Post your code and we will see if there is anything there.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default Re: Serial Timeout Strange Issues

    I am guessing you are powering the pics from the same supply as the servo. A little electric motor like that can generate some serious voltage (back EMF) and distribute it back into the power supply. I would power them seperately and tie the grounds all at a single place.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jun 2011
    Posts
    24

    Default Re: Serial Timeout Strange Issues

    No the servos and chips have seperate power supplies with connected ground as I ran into that problem before
    Here is my code

    Receiver

    Define osc 4
    trisa = %000000
    trisb = $00
    low portb
    t1pulse var byte[6]
    t1pulse[0] = 90
    t1pulse[1] = 90
    t1pulse[2] = 90
    t1pulse[3] = 90
    t1pulse[4] = 90
    t1pulse[5] = 90
    porta.1 = 1
    porta.2 = 0
    trisa.3 = 1

    Main:
    porta.2 = 0 'turns on a transistor that brings pin on sender high
    'to stop it from sending the serial

    pulsout portb.3,t1pulse[0] + 60 'pulsout for servos
    pulsout portb.2,t1pulse[1] + 60
    pulsout portb.1,t1pulse[2] + 60
    pulsout portb.4,240 - t1pulse[3]
    pulsout portb.5,240 - t1pulse[4]
    pulsout portb.6,240 - t1pulse[5]

    porta.2 = 1 'turns transistor on to bring sender pin low to
    'tell sender to send

    Serin2 porta.3,84,15,Comfail,[wait ("@"), str t1pulse\6] 'if timeout length
    ' is longer than the time between the sends
    'on the sender, this line hangs up and chip
    'acts weird like turning porta.2 on but not
    ' sending the pulses or turn on servo pins
    ' and never turn off

    porta.2 = 0 'tell sender to stop sending

    goto main 'loop to main

    Comfail: 'if sendin timesout, go here.
    Porta.2 = 0 'tell sender to stop sending
    goto main 'goto main

    The sender does some calculations and sends an array of size 6 through a pin and doesn't do anything else with that pin, just serout2 and then continues on with the program. If the time it takes the sender to send is longer than the timeout the receiver doesn't work correctly.

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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