Serin serout problem


Closed Thread
Results 1 to 40 of 337

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok I am doing a remote control for my robot I wrote a code below, It seems long, Maybe you have a better idea. I am using two Potentiometer , the values of each will control the left and right motor of the robot:

    'Remote control*****************

    direction var word : speed var word

    Loop:
    If (left => 115) AND (left <= 135) AND (right => 115) AND (right <= 135) then
    goto stop

    If (left => 115) AND (left <= 135) AND (right <= 115) then 'left is stop, right is CCW
    goto LeftstopRightCCW

    If (left => 115) AND (left <= 135) AND (right => 135) then 'left is stop , right is CW
    goto LeftstopRightCW

    If (right => 115) AND (right <= 135) AND (right <= 115) then 'right is stop, left is CCW
    goto RightstopLeftCCW

    If (right => 115) AND (right <= 135) AND (right => 135) then 'right is stop , left is CW
    goto RightstopLeftCW

    If (left > 135) AND (right > 135) then 'Left Cw & right CW
    goto LeftCWRightCW

    If (left > 135) AND (right < 135) then 'Left CW & right CCW
    goto LeftCWRightCCW

    If (left < 135) AND (right > 135) then 'Left CCW & right CW
    goto LeftCCWRightCW

    If (left < 135) AND (right < 135) then 'Left CCW & right CCW
    goto LeftCCWRightCCW

    In brief:
    'Stop '--------------------------------$69 = 01 10 10 01
    'Leftwheel =stop : Rightwheel= CCW '--- $A6 = 10 10 01 10
    'Leftwheel =stop : Rightwheel= CW '----- $96 = 10 01 01 10
    'Leftwheel =CCW : Rightwheel= stop '---- $9a = 10 01 10 10
    'Leftwheel =CW : Rightwheel= stop '----- $A5 = 10 10 01 01
    'Leftwheel =CW : Rightwheel= CW '---- $66 = 01 10 01 10
    'Leftwheel =CW : Rightwheel= CCW '---- $56 = 01 01 01 10
    'Leftwheel =CCW : Rightwheel= CW '---- $5a = 01 01 10 10
    'Leftwheel =CCW : Rightwheel= CCW '---- $65 = 01 10 01 01
    Last edited by lerameur; - 7th January 2007 at 21:29.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    ok I am doing a remote control for my robot I wrote a code below, It seems long, Maybe you have a better idea. I am using two Potentiometer , the values of each will control the left and right motor of the robot:

    'Remote control*****************

    direction var word : speed var word

    Loop:
    If (left => 115) AND (left <= 135) AND (right => 115) AND (right <= 135) then
    goto stop

    If (left => 115) AND (left <= 135) AND (right <= 115) then 'left is stop, right is CCW
    goto LeftstopRightCCW

    If (left => 115) AND (left <= 135) AND (right => 135) then 'left is stop , right is CW
    goto LeftstopRightCW

    If (right => 115) AND (right <= 135) AND (right <= 115) then 'right is stop, left is CCW
    goto RightstopLeftCCW

    If (right => 115) AND (right <= 135) AND (right => 135) then 'right is stop , left is CW
    goto RightstopLeftCW

    If (left > 135) AND (right > 135) then 'Left Cw & right CW
    goto LeftCWRightCW

    If (left > 135) AND (right < 135) then 'Left CW & right CCW
    goto LeftCWRightCCW

    If (left < 135) AND (right > 135) then 'Left CCW & right CW
    goto LeftCCWRightCW

    If (left < 135) AND (right < 135) then 'Left CCW & right CCW
    goto LeftCCWRightCCW

    In brief:
    'Stop '--------------------------------$69 = 01 10 10 01
    'Leftwheel =stop : Rightwheel= CCW '--- $A6 = 10 10 01 10
    'Leftwheel =stop : Rightwheel= CW '----- $96 = 10 01 01 10
    'Leftwheel =CCW : Rightwheel= stop '---- $9a = 10 01 10 10
    'Leftwheel =CW : Rightwheel= stop '----- $A5 = 10 10 01 01
    'Leftwheel =CW : Rightwheel= CW '---- $66 = 01 10 01 10
    'Leftwheel =CW : Rightwheel= CCW '---- $56 = 01 01 01 10
    'Leftwheel =CCW : Rightwheel= CW '---- $5a = 01 01 10 10
    'Leftwheel =CCW : Rightwheel= CCW '---- $65 = 01 10 01 01

    You're right. There probably is a better/shorter way to do that.
    I'll think about it for a bit and get back to ya.
    I take it that the reason you've got 115 and 135 is for a bit of a 'deadband' so the thing doesn't jitter on you?

    (see that?, the manchester encoding is handy isn't it?)

    How about


    'Remote control*****************

    direction var word : speed var word
    bits var byte
    'bits = bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
    ' LCW (-LCW) LCCW -(LCCW) RCW (-RCW) RCCW (-RCCW)
    'use odd bits as a direction flag, use the even bits inverted from the others as the same thing, but also as a bit of error detection

    TX end...

    Loop:
    bits = %01010101

    If (left => 115) AND (left <= 135) then bits.7 = 0 : bits.6 = 1
    if (right => 115) AND (right <= 135) then bits.3 = 0 : bits.2 = 1
    if (right <= 115) then bits.1 = 1 : bits.0 = 0
    If (right => 135) then bits.3 = 1 : bits.2 = 0
    If (left <= 115) then bits.5 = 1 : bits.4 = 0
    If (left => 135) then bits.7 = 1 : bits.6 = 0
    transmit
    goto loop


    RX end....
    In brief:
    if bits.7 = bits.6 then bitserror 'bit pairs shouldn't be equal
    if bits.5 = bits.4 then bitserror
    if bits.3 = bits.2 then bitserror
    if bits.1 = bits.0 then bitserror

    'Stop '--------------------------------$69 = 01 10 10 01
    'Leftwheel =stop : Rightwheel= CCW '--- $A6 = 10 10 01 10
    'Leftwheel =stop : Rightwheel= CW '----- $96 = 10 01 01 10
    'Leftwheel =CCW : Rightwheel= stop '---- $9a = 10 01 10 10
    'Leftwheel =CW : Rightwheel= stop '----- $A5 = 10 10 01 01
    'Leftwheel =CW : Rightwheel= CW '---- $66 = 01 10 01 10
    'Leftwheel =CW : Rightwheel= CCW '---- $56 = 01 01 01 10
    'Leftwheel =CCW : Rightwheel= CW '---- $5a = 01 01 10 10
    'Leftwheel =CCW : Rightwheel= CCW '---- $65 = 01 10 01 01

    And at the receiver end, the receiver code wouldn't actuate a motor until receiving a few correct codes in a row (a one time code wouldn't trip the motors into running).

    Just a quick thought I had...

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I got the module working now, I will be doing some testing thursday.
    by the way i wouls like to have a crystal oscillate by itself, How do i do that ? I have a sensor chip that needs to be clocked. I tried connecting it to + and ground but nothing

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I got the module working now, I will be doing some testing thursday.
    by the way i wouls like to have a crystal oscillate by itself, How do i do that ? I have a sensor chip that needs to be clocked. I tried connecting it to + and ground but nothing
    Crystals don't oscillator by themselves. In short, you have to have a small inverting amp, induce a phase shift, and a few other things to get a usable signal from them. Grab the datasheet for a 4066 and see what they do with a crystal and one of those chips. Or just buy a DIP oscillator of the frequency of your choice (Digikey ECS oscillators).

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I got the oscillator goimg, Its square wave, I will be adding a couple of caps and resisor to make it more like a sin wave.

    Also I needed more memory for my project so I got the monster Pic18F4685. Iuse the same program as for the Pic16F877a and it gives errors about the nbit number, I guess I have to change all the specification of my program. but I am not sure what; here is the message i am getting after compiling:

    C:\PBP>pbp -p18F4685 motorG
    PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc.
    All Rights Reserved.
    PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
    Error 18F4685.INC 14 : [235] Opcode Expected Instead of 'Error: PM does not sup
    port this device. Use MPASM.'
    Error C:\PBP\MOTORG.ASM 85 : [225] Undefined Symbol 'PORTB'
    Error C:\PBP\MOTORG.ASM 86 : [225] Undefined Symbol 'PORTC'
    Error C:\PBP\MOTORG.ASM 87 : [225] Undefined Symbol 'TRISB'
    Error C:\PBP\MOTORG.ASM 88 : [225] Undefined Symbol 'TRISC'
    Error PBPPIC18.LIB 161 : [225] Undefined Symbol 'PORTB'
    Error PBPPIC18.LIB 379 : [225] Undefined Symbol 'PORTB'
    Error PBPPIC18.LIB 1153 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1153 : [218] Address Limit of FFFFh Exceeded
    Error PBPPIC18.LIB 1158 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1158 : [218] Address Limit of FFFFh Exceeded
    Error PBPPIC18.LIB 1281 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1281 : [218] Address Limit of FFFFh Exceeded
    Error PBPPIC18.LIB 1282 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1282 : [218] Address Limit of FFFFh Exceeded
    Fatal PBPPIC18.LIB 1282 : [300] Too Many Errors

    C:\PBP>

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I got the oscillator goimg, Its square wave, I will be adding a couple of caps and resisor to make it more like a sin wave.

    Also I needed more memory for my project so I got the monster Pic18F4685. Iuse the same program as for the Pic16F877a and it gives errors about the nbit number, I guess I have to change all the specification of my program. but I am not sure what; here is the message i am getting after compiling:

    C:\PBP>pbp -p18F4685 motorG
    PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc.
    All Rights Reserved.
    PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
    Error 18F4685.INC 14 : [235] Opcode Expected Instead of 'Error: PM does not sup
    port this device. Use MPASM.'
    Error C:\PBP\MOTORG.ASM 85 : [225] Undefined Symbol 'PORTB'
    Error C:\PBP\MOTORG.ASM 86 : [225] Undefined Symbol 'PORTC'
    Error C:\PBP\MOTORG.ASM 87 : [225] Undefined Symbol 'TRISB'
    Error C:\PBP\MOTORG.ASM 88 : [225] Undefined Symbol 'TRISC'
    Error PBPPIC18.LIB 161 : [225] Undefined Symbol 'PORTB'
    Error PBPPIC18.LIB 379 : [225] Undefined Symbol 'PORTB'
    Error PBPPIC18.LIB 1153 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1153 : [218] Address Limit of FFFFh Exceeded
    Error PBPPIC18.LIB 1158 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1158 : [218] Address Limit of FFFFh Exceeded
    Error PBPPIC18.LIB 1281 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1281 : [218] Address Limit of FFFFh Exceeded
    Error PBPPIC18.LIB 1282 : [200] Instruction Restricted to 14-Bit Core
    Error PBPPIC18.LIB 1282 : [218] Address Limit of FFFFh Exceeded
    Fatal PBPPIC18.LIB 1282 : [300] Too Many Errors

    C:\PBP>
    Check your PBP manual. You can't use the assembler that comes with PBP, gotta use MPASM for the PIC18Fxxxx parts.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    O ok, because i saw the .BAS and .INC files, so I thougt it would take it.
    alright

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. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. serout and serin problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2006, 19:44
  4. Replies: 11
    Last Post: - 13th July 2005, 19:26
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

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