Shop OBEX P1 Docs P2 Docs Learn Events
Is something wrong!! — Parallax Forums

Is something wrong!!

FREDDYFREDDY Posts: 5
edited 2006-04-24 00:08 in Robotics
I have been getting bad results from the microcontroller. It seems that when I do Ch1=1 I get highs on all my I/O. My program says only Ch2. When I do Ch3=1 I get lows on all I/O. I have not got past that point in the troubleshooting.

??? Is there something wrong with my code or microcontroller ???

' ==============================================================================
'
' File......
' Purpose...RC CONTROL OF Unmanned Search And Rescue Vehicle (USARV)
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' ==============================================================================


'
' Program Description
'

'Control USARV using 4-Channel R/C
'
'
' I/O Definitions
'
Ch1 PIN 12 ' Input channel used to receive forward'
Ch2 PIN 1 ' Output channel used to drive forward'
Ch3 PIN 13 ' Input channel used to recieve reverse'
Ch4 PIN 2 ' Output channel used to drive reverse'
Ch5 PIN 14 ' Input channel used to receive left'
Ch6 PIN 3 ' Output channel used to steer left'
Ch7 PIN 15 ' Input channel used to receive right'
Ch8 PIN 4 ' Output channel used to steer right'
'
' Program Code|
'
begin:
DO

INPUT Ch1
INPUT Ch3
INPUT Ch5
INPUT Ch7

IF ( Ch1=1 AND Ch3=0 ) THEN : GOSUB FWD 'Drives USARV forward'

ELSEIF ( Ch1=0 AND Ch3=1 ) THEN : GOSUB REV1 'Drives USARV backwards'

ELSEIF ( Ch1=0 AND Ch3=0 ) THEN : GOSUB stops 'Stops USARV'

ENDIF


IF ( Ch5=1 AND Ch7=0 ) THEN : GOSUB LFT 'Turns USARV left'

ELSEIF ( Ch5=0 AND Ch7=1 ) THEN : GOSUB RHT 'Turns USARV right'

ELSEIF ( Ch5=0 AND Ch7=0 ) THEN : GOSUB NOTURN 'Drive straight'

ENDIF

LOOP

'
' Subroutines
'

FWD:
HIGH Ch2
LOW Ch4
PAUSE 50
RETURN

REV1:
LOW Ch2
HIGH Ch4
PAUSE 50
RETURN

stops:
LOW Ch2
LOW Ch4
PAUSE 50
RETURN

LFT:
HIGH Ch6
LOW Ch8
PAUSE 50
RETURN

RHT:
LOW Ch6
HIGH Ch8
PAUSE 50
RETURN

NOTURN:
LOW Ch6
LOW Ch8
PAUSE 50
RETURN

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-24 00:08
    FREDDY -

    I think you want to remove all of the COLONS from all of your IF and ELSEIF statements:

    Change -

    IF ( Ch1=1 AND Ch3=0 ) THEN : GOSUB FWD 'Drives USARV forward'

    ELSEIF ( Ch1=0 AND Ch3=1 ) THEN : GOSUB REV1 'Drives USARV backwards'

    ELSEIF ( Ch1=0 AND Ch3=0 ) THEN : GOSUB stops 'Stops USARV'

    ENDIF

    To this -

    IF ( Ch1=1 AND Ch3=0 ) THEN GOSUB FWD 'Drives USARV forward'

    ELSEIF ( Ch1=0 AND Ch3=1 ) THEN GOSUB REV1 'Drives USARV backwards'

    ELSEIF ( Ch1=0 AND Ch3=0 ) THEN GOSUB stops 'Stops USARV'

    ENDIF


    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.