Real easy one I'm sure - Invalid parameter
Professorwiz
Posts: 153
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
·
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
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
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:
Hope this helps!
Rodney
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
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