Shop OBEX P1 Docs P2 Docs Learn Events
Real easy one I'm sure - Invalid parameter — Parallax Forums

Real easy one I'm sure - Invalid parameter

ProfessorwizProfessorwiz Posts: 153
edited 2008-08-19 00:40 in General Discussion
Hi all,
I'm trying to get into the SX again after a short time away.· I haven't used the subroutine function and was trying to use it.· Could someone tell me what I'm missing.. I'm sure it's a simple..

It's giving me an invalid parameter on the subroutine CLICKS, on line High LED4.· Is this because I should be passing a paramenter there?· I don't get it.

Thanks,
Russ
' =========================================================================
'
'·· File...... pwidth2
'·· Purpose... Trigger a camera shutter
'·· Author....· Russell Wizinsky
'·· E-mail....· Russw@professorwiz.com
'·· Started...8/1/08
'·· Updated...8/18/08
'
' =========================================================================
'
' Program Description
'
' The purpose of the program is to trigger a the shutter of a camera
' dependent on the movement of a remote control for Airplanes / Helis
' Down position will be camera off / standby
' Midstick will be single shot
' Top Stick will be 3 round bursts
' After all camera shots there will be a 1 second delay
'
' Device Settings
'
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
PROGRAM··Start

'
' IO Pins
'
led1··pin·rc.0·output
led4··pin·rc.4·output
led5··pin·rc.5·output
led6··pin·rc.6·output
led7··pin·rc.7·output
Camera··pin·rb.4·output
Receiver ·pin·rc.1·input
'
' Constants
'
'
' Subroutines
'
PIC3·SUB
CLICKS·SUB
PIC1·SUB

PIC3:
CLICKS
CLICKS
CLICKS
ENDSUB

PIC1:
CLICKS
ENDSUB

CLICKS:
HIGH led4
HIGH led5
HIGH led6
HIGH led7
HIGH camera
PAUSE 100
LOW led4
LOW led5
LOW led6
LOW led7
LOW Camera
PAUSE 100
ENDSUB
' Variables
'
pWidth··var·byte
'
·' INTERRUPT
'
' Program Code
'

Start:

PULSIN receiver, 1, pWidth
IF pWidth > 200 then
·PIC3
·pause 1000
·goto start
ENDIF
IF pWidth >100 then
·PIC1
·pause 1000
·goto start
ENDIF
·pause 1000
goto start
·

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2008-08-19 00:18
    Russ,

    I'll admit I have not given this much depth of though but you may want to try one of the following:

    1.) Replace your END SUB statements with RETURN statements

    ...OR...

    2.) Place a SUB statement before your subroutine labels and keep the END SUB statements.


    If you try this and it does not work, let me know.

    - Sparks
  • YendorYendor Posts: 288
    edited 2008-08-19 00:23
    Hi Russ,

    Look in the SX/B help file under "Declaration" for one alternative.

    Another, it looks like you need to declare your sub's first, these assume to pass 0 variables to the subroutine:

    Program START
    

    '__________________________________________________________________________
    ' Subroutines / Jump Table
    '__________________________________________________________________________
    

    PIC3 SUB 0 
    CLICKS SUB 0 
    PIC1 SUB 0 
    
    

    START:
    'Then after the main code (after the END), I typically put the subroutines. 
    ' code
    Main: 
    ' code
    END 
    '___________________________ 
    'I like using the sub...endsub format, but there are alternate ways: 
    '___________________________ 
    SUB PIC3 
    'code 
    endsub 
    '___________________________ 
    SUB clicks 
    'code 
    
    endsub 
    '___________________________ 
    SUB PIC3 
    'code 
    endsub 
    '___________________________
    


    Hope this helps!

    Rodney
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-19 00:24
    The program is skipping right over your pin definitions. I think you'll find SX/B a little easier if you'll use the template from the help file; it lays out the kinds of things you will have in your program and in the *best* (my opinion) order to make things easy for you to succeed. Here's my rewrite of your program.

    ' =========================================================================
    '
    '   File...... CLICKS.SXB
    '   Purpose...
    '   Author....
    '   E-mail....
    '   Started...
    '   Updated...
    '
    ' =========================================================================
    
    
    ' -------------------------------------------------------------------------
    ' Program Description
    ' -------------------------------------------------------------------------
    
    
    ' -------------------------------------------------------------------------
    ' Conditional Compilation Symbols
    ' -------------------------------------------------------------------------
    
    
    ' -------------------------------------------------------------------------
    ' Device Settings
    ' -------------------------------------------------------------------------
    
    DEVICE          SX28, OSC4MHZ, TURBO, STACKX, OPTIONX, BOR42
    FREQ            4_000_000
    ID              "CLICKS"
    
    
    ' -------------------------------------------------------------------------
    ' I/O Pins
    ' -------------------------------------------------------------------------
    
    Led7            PIN     RC.7 OUTPUT
    Led6            PIN     RC.6 OUTPUT
    Led5            PIN     RC.5 OUTPUT
    Led4            PIN     RC.4 OUTPUT
    Led1            PIN     RC.0 OUTPUT
    
    Camera          PIN     RB.4 OUTPUT
    Receiver        PIN     RC.1 INPUT
    
    
    ' -------------------------------------------------------------------------
    ' Constants
    ' -------------------------------------------------------------------------
    
    IsOn            CON     1
    IsOff           CON     0
    
    
    ' -------------------------------------------------------------------------
    ' Variables
    ' -------------------------------------------------------------------------
    
    pWidth          VAR     Byte
    
    
    ' =========================================================================
    ' INTERRUPT
    ' =========================================================================
    
    
    ' RETURNINT
    
    
    ' =========================================================================
      PROGRAM Start
    ' =========================================================================
    
    
    ' -------------------------------------------------------------------------
    ' Subroutine / Function Declarations
    ' -------------------------------------------------------------------------
    
    DELAY_MS        SUB     1, 2
    
    PIC1            SUB     0
    PIC3            SUB     0
    CLICKS          SUB     0
    
    
    ' -------------------------------------------------------------------------
    ' Program Code
    ' -------------------------------------------------------------------------
    
    Start:
      PLP_A = %00000000
      PLP_B = %00010000
      PLP_C = %11110011
    
    
    Main:
      PULSIN Receiver, 1, pWidth
    
      IF pWidth > 200 THEN
        PIC3
      ELSEIF pWidth > 100 THEN
        PIC1
      ENDIF
    
      DELAY_MS 1000
      GOTO Main
    
    
    ' -------------------------------------------------------------------------
    ' Subroutine / Function Code
    ' -------------------------------------------------------------------------
    
    ' Use: DELAY_MS duration
    ' -- shell for PAUSE
    
    SUB DELAY_MS
      IF __PARAMCNT = 1 THEN
        __WPARAM12_MSB = 0
      ENDIF
      PAUSE __WPARAM12
      ENDSUB
    
    ' -------------------------------------------------------------------------
    
    SUB PIC1
      CLICKS
      ENDSUB
    
    ' -------------------------------------------------------------------------
    
    SUB PIC3
      CLICKS
      CLICKS
      CLICKS
      ENDSUB
    
    ' -------------------------------------------------------------------------
    
    SUB CLICKS
      Led4 = IsOn
      Led5 = IsOn
      Led6 = IsOn
      Led7 = IsOn
      Camera = IsOn
      DELAY_MS 100
      Led4 = IsOff
      Led5 = IsOff
      Led6 = IsOff
      Led7 = IsOff
      Camera = IsOff
      DELAY_MS 100
      ENDSUB
    
    
    ' -------------------------------------------------------------------------
    ' User Data
    ' -------------------------------------------------------------------------
    
  • ChetChet Posts: 150
    edited 2008-08-19 00:27
    came in late.....

    Regards

    Chet

    ' =========================================================================
    '
    '·· File...... pwidth2·
    '·· Purpose... Trigger a camera shutter
    '·· Author....· Russell Wizinsky
    '·· E-mail....· Russw@professorwiz.com
    '·· Started...8/1/08
    '·· Updated...8/18/08
    '
    ' =========================================================================
    '
    ' Program Description
    '
    ' The purpose of the program is to trigger a the shutter of a camera
    ' dependent on the movement of a remote control for Airplanes / Helis
    ' Down position will be camera off / standby
    ' Midstick will be single shot
    ' Top Stick will be 3 round bursts
    ' After all camera shots there will be a 1 second delay
    '
    ' Device Settings
    '
    DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
    FREQ··········· 4_000_000


    '
    ' IO Pins
    '
    led1· ·pin rc.0 output
    led4· ·pin rc.4 output
    led5· ·pin rc.5 output
    led6· ·pin rc.6 output
    led7· ·pin rc.7 output
    Camera· pin rb.4 output
    Receiver· pin rc.1 input
    '
    ' Constants
    '
    PROGRAM· Start
    '
    ' Subroutines
    '
    PIC3 SUB
    CLICKS SUB
    PIC1 SUB

    ' Variables
    '
    pWidth· var byte
    '
    ·' INTERRUPT
    '
    ' Program Code
    '

    Start:

    PULSIN receiver, 1, pWidth
    IF pWidth > 200 then
    ·PIC3
    ·pause 1000
    ·goto start
    ENDIF
    IF pWidth >100 then
    ·PIC1
    ·pause 1000
    ·goto start
    ENDIF
    ·pause 1000
    goto start

    SUB PIC3
    CLICKS
    CLICKS
    CLICKS

    Return

    ENDSUB

    SUB PIC1
    CLICKS

    return
    ENDSUB

    SUB CLICKS
    HIGH led4
    HIGH led5
    HIGH led6
    HIGH led7
    HIGH led4
    PAUSE 100
    LOW led4
    LOW led5
    LOW led6
    LOW led7
    LOW led4
    PAUSE 100

    return
    ENDSUB


    Post Edited (Chet) : 8/19/2008 12:33:21 AM GMT
  • ProfessorwizProfessorwiz Posts: 153
    edited 2008-08-19 00:40
    Thanks all, specially JonnyMac!!!

    Now I see where I was messing everything up. I'll try to keep with the template from now on.
    Works much better now. I was tearing my hair out for no other reason than poor organzation.


    Thanks again.

    Russ
Sign In or Register to comment.