Serial Timeout Strange Issues


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    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.

  2. #2
    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.

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

    Default Re: Serial Timeout Strange Issues

    Here is a shot in the dark.
    You have not posted any config fuses in your code so I am free to assume you are allowing your code to use the Default configs which are located in the 16F84.inc file found in your PBP root directory.
    This is the default MPASM config:
    __config _XT_OSC & _WDT_ON & _CP_OFF
    and here is the PM default config:
    device pic16F84, xt_osc, wdt_on, protect_off
    it defaults to WDT_ON, I think your code is hanging waiting and the WDT resets and the follies begin. You should early in your PIC programming career learn how to set them in your code so there are no surprises.
    It is explained in this thread:
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Last edited by Archangel; - 8th June 2011 at 09:13. Reason: add
    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.

  4. #4
    Join Date
    Jun 2011
    Posts
    24

    Default Re: Serial Timeout Strange Issues

    I tried turning off the watchdog timer and it didn't change. Thanks for the sggestion.

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

    Default Re: Serial Timeout Strange Issues

    Ok, well different theory,
    try using a pullup resistor and change mode from 84 to 32852, it is still 9600 True but with open collector instead of driven high.
    Try adding
    DEFINE CHAR_PACING 1000
    in transmitter code.
    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

    I added a 10k resistor between the +5 PIC source and the serial wire and changed the 84 to 32852 and it is getting more motion than before but not much more. the servos are all over the place for a biut but then they do what I want for a little. I have 3 serial wires going from the transmitter to 3 receiver chips that control the servos and they are all wired the same just going to different pins on the transmitter. Sometimes two out of three will do as described before but the third for some reason doesn't do anything. I verified on an oscope that the transmitter is sending data and for it to send that means the receiver is giving the signal to receive, it just isn't receiving because the servos are staying at their set default of 90 degrees which I programmed in to the receivers in case the transmitter stops.
    To me it seems the receivers are sending the go ahead, the transmitter is sending, but the receivers aren't receiving.

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

    Default Re: Serial Timeout Strange Issues

    Tell us about the power supplies and what you have done to suppress any noise from the power supply going to the PIC. You should have (MUST ?) a bypass capacitor right between the PICs power pins, you should have the servos on their own supply and I would recommend a nice fat 10 µF or larger Cap to pick up Low Freq spikes as well, Make sure the pics are not browning out when they run, all serial wires should be at the very least twisted, shielded is better but probably overkill, be aware fluorescent lights can cause misbehavior too. If all else fails try setting things up at a slower baud rate and if that works increase it until it fails, other things to check are, how sure are you about the actual oscillator speeds, are you using crystals, resonators or just R/C oscillators?

    EDIT; Oh and Dave pointed this out a while back from the data sheet . . .
    Note: When using resonators with frequencies
    above 3.5 MHz, the use of HS mode rather
    than XT mode, is recommended.
    HS mode
    may be used at any VDD for which the
    controller is rated.

    EDIT2: Define osc 4 MUST BE ALL UPPERCASE LETTERS . . . DEFINE OSC 4
    Last edited by Archangel; - 10th June 2011 at 04:50. Reason: add
    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.

Members who have read this thread : 0

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