Serious Serial Situation Setbacks...


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2007
    Location
    Near Chicago,Illinois USA
    Posts
    3

    Default Serious Serial Situation Setbacks...

    Sorry I thought it would be a catchy title.... maybe not....

    But really now, I want to say thanks in advance for any/everyone whom may assist me in my dilema.

    My project is really kind of simple. All I'm looking to do is control a robot (two small dc motors) to drive it like a tank/bulldozer. Using relays I can reverse the motor direction and have made it operate with pushbutton switches. I have two 16F84A's, PBP, and an Epic Programmer. I can compile/program the chips to test I/O and everything worked fine until I tried to establish serial comms. Eventually I intend to make the comms wireless but for now I have them hardwired together. I'm pretty confident in the hardware aspect of the project. My code compiles/programs fine but when I power up the majic never happens. I get erratic behavior on the recieving end (like a high speed chattering on the relays) and there is sometimes a response to changing the inputs but nothing close to being considered operational.

    I have tried every baud rate in the PBP manual and have also added/removed qualifiers but I've had no change in operation.

    My limited experience has led to a temporary roadblock which hopefully one of you can help me pass. I fear my error is something spelled out clearly in a reference I haven't came across yet. I have done a lot of looking around but cannot figure out what I'm doing wrong. Hopefully my post isn't to trivial due to my short commings.

    Again thanks for any assistance!!!

    Dan



    Here is my code for the tx:

    Include "modedefs.bas" ' Include serial modes
    INPUT PORTB.2 ' Right Forward output
    INPUT PORTB.3 ' Right Reverse output
    INPUT PORTB.4 ' Left Forward output
    INPUT PORTB.5 ' Left Reverse output
    OUTPUT PORTA.0 ' Serial Output Pin
    A0 VAR BYTE
    DEFINE OSC 4


    loop:


    ' -----(READ ALL THE INPUTS)----- '

    IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 0) THEN ' "STOPPED"
    SEROUT PORTA.0 , T2400 ,[1]
    ELSE
    endif
    IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) THEN ' "RR ONLY"
    SEROUT PORTA.0 , T2400 ,[2]
    ELSE
    endif
    IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 0) THEN ' "RF ONLY"
    SEROUT PORTA.0 , T2400 ,[3]
    ELSE
    endif
    IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 0) THEN ' "LR ONLY"
    SEROUT PORTA.0 , T2400 ,[4]
    ELSE
    endif
    IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 0) THEN ' "LF ONLY"
    SEROUT PORTA.0 , T2400 ,[5]
    ELSE
    endif
    IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 0) THEN ' "RF AND LF"
    SEROUT PORTA.0 , T2400 ,[6]
    ELSE
    endif
    IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 0) THEN ' "RF AND LR"
    SEROUT PORTA.0 , T2400 ,[7]
    ELSE
    endif
    IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) THEN ' "RR AND LF"
    SEROUT PORTA.0 , T2400 ,[8]
    ELSE
    endif
    IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) THEN ' "RR AND LR"
    SEROUT PORTA.0 , T2400 ,[9]
    ELSE
    endif

    GOTO LOOP;

    END
    __________________________________________________ ______

    Here is my code for the rx:

    Include "modedefs.bas" ' Include serial modes
    OUTput PORTB.0 ' Right Forward output
    OUTput PORTB.1 ' Right Reverse output
    OUTput PORTB.2 ' Left Forward output
    OUTput PORTB.3 ' Left Reverse output
    input PORTA.0
    A0 VAR BYTE
    DEFINE OSC 4

    LOOP:

    SERIN PORTA.0 , T2400 ,A0

    if A0 = 1 then STOPPED ' "STOPPED"
    if A0 = 2 then RR_ONLY ' "RR ONLY"
    if A0 = 3 then RF_ONLY ' "RF ONLY"
    if A0 = 4 then LR_ONLY ' "LR ONLY"
    if A0 = 5 then LF_ONLY ' "LF ONLY"
    if A0 = 6 then RF_AND_LF ' "RF AND LF"
    if A0 = 7 then RF_AND_LR ' "RF AND LR"
    if A0 = 8 then RR_AND_LF ' "RR AND LF"
    if A0 = 9 then RR_AND_LR ' "RR AND LR"
    goto loop;

    '-------Read the Serial Data and decode into motion control --------'


    STOPPED: ' "STOPPED"

    PORTB.0 = 0 'Right Forward output
    PORTB.1 = 0 'Right Reverse output
    PORTB.2 = 0 'Left Forward output
    PORTB.3 = 0 'Left Reverse output

    GOTO LOOP;

    RR_ONLY: ' "RR ONLY"

    PORTB.0 = 0 'Right Forward output
    PORTB.1 = 1 'Right Reverse output
    PORTB.2 = 0 'Left Forward output
    PORTB.3 = 0 'Left Reverse output

    GOTO LOOP;

    RF_ONLY: ' "RF ONLY"

    PORTB.0 = 1 'Right Forward output
    PORTB.1 = 0 'Right Reverse output
    PORTB.2 = 0 'Left Forward output
    PORTB.3 = 0 'Left Reverse output

    GOTO LOOP;

    LR_ONLY: ' "LR ONLY"

    PORTB.0 = 0 'Right Forward output
    PORTB.1 = 0 'Right Reverse output
    PORTB.2 = 0 'Left Forward output
    PORTB.3 = 1 'Left Reverse output

    GOTO LOOP;

    LF_ONLY: ' "LF ONLY"

    PORTB.0 = 0 'Right Forward output
    PORTB.1 = 0 'Right Reverse output
    PORTB.2 = 1 'Left Forward output
    PORTB.3 = 0 'Left Reverse output

    GOTO LOOP;

    RF_AND_LF: ' "RF AND LF"

    PORTB.0 = 1 'Right Forward output
    PORTB.1 = 0 'Right Reverse output
    PORTB.2 = 1 'Left Forward output
    PORTB.3 = 0 'Left Reverse output

    GOTO LOOP;

    RF_AND_LR: ' "RF AND LR"

    PORTB.0 = 1 'Right Forward output
    PORTB.1 = 0 'Right Reverse output
    PORTB.2 = 0 'Left Forward output
    PORTB.3 = 1 'Left Reverse output

    GOTO LOOP;

    RR_AND_LF: ' "RR AND LF"

    PORTB.0 = 0 'Right Forward output
    PORTB.1 = 1 'Right Reverse output
    PORTB.2 = 1 'Left Forward output
    PORTB.3 = 0 'Left Reverse output

    GOTO LOOP;

    RR_AND_LR: ' "RR AND LR"

    PORTB.0 = 0 'Right Forward output
    PORTB.1 = 1 'Right Reverse output
    PORTB.2 = 0 'Left Forward output
    PORTB.3 = 1 'Left Reverse output

    GOTO LOOP;


    END

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


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Haven't looked much at your code yet, just the standard question first:
    Do you use a proper X-tal on both the sending and receiving PIC's, not a ceramic resonator, and, if yes, are you sure it's 4Mhz?

    /Henrik Olsson.

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


    Did you find this post helpful? Yes | No

    Default Config fuses

    G'Day Dan,
    Ask the dog if he set the config fuses properly, or maybe you can set them in code for him Which compiler are you using, MPASM or the default PBP compiler?
    Look at this thread: http://www.picbasic.co.uk/forum/show...t=config+fuses
    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
    Feb 2007
    Location
    Near Chicago,Illinois USA
    Posts
    3


    Did you find this post helpful? Yes | No

    Smile Moving Forward!!!

    I am using ceramic resonators. But I do have x-tal's and will switch them out. Out of curiosity why does it matter? I chose the ceramic's because they consume less space.

    Fuses... That's something I've never heard or read about before (in PIC language).

    I'm using MicroCode Studio 2,2,1,1 and PBP version 2.46.

    When I select to "Compile and Program" the "meProg" initiates and I can select to view the configuration window. Do I have to do anything other than select the correct oscillator?

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dansdog View Post
    I am using ceramic resonators. But I do have x-tal's and will switch them out. Out of curiosity why does it matter? I chose the ceramic's because they consume less space.

    Fuses... That's something I've never heard or read about before (in PIC language).

    I'm using MicroCode Studio 2,2,1,1 and PBP version 2.46.

    When I select to "Compile and Program" the "meProg" initiates and I can select to view the configuration window. Do I have to do anything other than select the correct oscillator?
    Xtal vs resonator - xtal=tight tolerances, resonator=not quite so tight; required if you're using any kind of communications

    fuses - see the PBP manual, page 8.

  6. #6
    Join Date
    Feb 2007
    Location
    Near Chicago,Illinois USA
    Posts
    3


    Did you find this post helpful? Yes | No

    Smile Ahhhhhh......

    Thanks skimask!!!

    Page 8 might become next favorite page....I'll let you know tomarrow.

    Dan

Similar Threads

  1. Replies: 33
    Last Post: - 19th March 2010, 03:02
  2. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  3. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  4. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35
  5. Replies: 2
    Last Post: - 23rd July 2006, 08:16

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