November 23, 2024, 10:49:11 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Program for my prop1

Started by Lynn, January 21, 2010, 01:56:58 PM

Previous topic - Next topic

JonnyMac

All I did was a code clean-up to remove the syntax errors and it works fine.  I'm testing on a Trainer, but I can see that the servos are being updated (P0 and P1 LEDs are dimly lit due to pulsing) and P2 comes on after the trigger.  Since you have verified that P2 works with your LED, this should now do it for you.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Light           = PIN2
SYMBOL  Rotate          = 1                     ' rotation servo
SYMBOL  Tilt            = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2
SYMBOL  pos             = B3                    ' tilt servo position
SYMBOL  speed           = B4                    ' rotation servo speed

SYMBOL  delay           = W5


' -----[ Initialization ]--------------------------------------------------

Reset:
 PINS = %00000000
 DIRS = %00000111

 pos = 100
 speed = 155

 delay = 40000
 GOSUB Servo_Pause


' -----[ Program Code ]----------------------------------------------------

Main:
 timer = 0

Check_Trigger:
 PULSOUT Tilt, pos
 PULSOUT Rotate, speed
 PAUSE 17
 timer = timer + 20 * Trigger
 IF timer < 100 THEN Check_Trigger

Light_On:
 Light = IsOn
 Delay = 500
 GOSUB Servo_Pause

Drop:
 pos = 200
 delay = 3000
 GOSUB Servo_Pause

Roll_Up:
 Light = IsOff
 pos = 100
 speed = 125
 delay = 11000
 GOSUB Servo_Pause

 GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------

' Use instead of PAUSE
' -- put pause value (ms) in "delay" before calling

Servo_Pause:
 PULSOUT Tilt, pos
 PULSOUT Rotate, speed
 IF delay < 20 THEN SP_Exit
   PAUSE 17
   delay = delay - 20
   GOTO Servo_Pause

SP_Exit:
 PAUSE delay
 RETURN

' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

ScaryTinker

Jon,

What would the code look like if a pot was added to control the length of time the roll up the string routine runs?

Steve

JonnyMac

February 10, 2011, 10:05:51 AM #32 Last Edit: February 10, 2011, 10:07:26 AM by JonnyMac
You'd have to define a pin for a pot and then read it just before the section the rolls up the prop. Setting the speed is not the problem, it's setting the delay that follows that is.  Here's the partially adjusted section:

Roll_Up:
 Light = IsOff
 pos = 100

 POT SpdAdjust, 100, speed
  speed = speed / 5 + 100 MAX 150       ' may need tweaking

 delay = 11000                         ' WARNING!!! - not adjusted for pot
 GOSUB Servo_Pause

 GOTO Reset


If you have one of these props and can do timing tests on the extreme ends of the pot then we can make the delay time work with the pot setting. To do that, though, will require some empirical data.
Jon McPhalen
EFX-TEK Hollywood Office

ScaryTinker

I've got the rig sitting on the desk at home.

I took your code and put the pot on the delay value.  It compiles.  I have no idea if it will work.  Can you take a look?  I'm still fuzzy on the DIRS instruction and was kinda guessing at the pot implementation

Thanks

Steve

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  TimeAdjust      = PIN3                  'POT
SYMBOL  Light           = PIN2
SYMBOL  Rotate          = 1                     ' rotation servo
SYMBOL  Tilt            = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2
SYMBOL  pos             = B3                    ' tilt servo position
SYMBOL  speed           = B4

SYMBOL  delay           = W5


' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000
  DIRS = %00001111

  pos = 100
  speed = 155

  delay = 40000
  GOSUB Servo_Pause


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0

Check_Trigger:
  PULSOUT Tilt, pos
  PULSOUT Rotate, speed
  PAUSE 17
  timer = timer + 20 * Trigger
  IF timer < 100 THEN Check_Trigger

Light_On:
  Light = IsOn
  Delay = 500
  GOSUB Servo_Pause

Drop:
  pos = 200
  delay = 3000
  GOSUB Servo_Pause

Roll_Up:
  Light = IsOff
  pos = 100

speed = 125

POT TimeAdjust, 100, delay
  delay = delay / 5 * 1000         'SWAG value to be determined by testing
GOSUB Servo_Pause

GOTO Reset



' -----[ Subroutines ]-----------------------------------------------------

' Use instead of PAUSE
' -- put pause value (ms) in "delay" before calling

Servo_Pause:
  PULSOUT Tilt, pos
  PULSOUT Rotate, speed
  IF delay < 20 THEN SP_Exit
    PAUSE 17
    delay = delay - 20
    GOTO Servo_Pause

SP_Exit:
  PAUSE delay
  RETURN

' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

JonnyMac

You need to modify your declaration for the pin called TimeAdjust.

SYMBOL  TimeAdjust      = 7                     ' Pot: No SETUP, No ULN

The POT command takes care of the DIRS stuff. The important thing for POT is to remove the ULN and SETUP influence.

Jon McPhalen
EFX-TEK Hollywood Office