November 23, 2024, 07:39:57 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Prop 1 quick program help

Started by chuckb0004, October 27, 2010, 01:41:10 PM

Previous topic - Next topic

chuckb0004

Jon Im in apanick and need your help. Im running out of time and need a quick program. I know if I had more time I could fiquire it out but I dont have the time. This is what I want to do I have a prop one that needs to do the following.
Energize a 12vdc relay for 26 seconds and at the same time move a servo to its max position for that same amount of time. At the end of 26 seconds de-energize the relay and move the servo to its opposite max position and hold this for 15 seconds and then repeat the entire rountine again, over and over. Hope you have the time I know this is a very busy time but hopefully you can sqeeze me in. Thanks Chuck

JonnyMac

So your panic is supposed become my priority?   ;D ;D ;D

No worries, we can help -- just stop calling me out by name.  Who knows how many people didn't help you because you just asked for me (our rules forbid this....).

Okay, here's your code.  I don't know what kind of servos you have, but if they're HiTech then you may want to change the servo values to 60 and 240.  Also, because of the way the code works, you'll want to put a stopwatch to it and tweek the 26000 and 15000 values to get right on the timing you want.  With the BS1 there is no way to be precise without a little experimentation.

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


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


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


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

SYMBOL  Relay           = PIN1                  ' use V+/OUT1
SYMBOL  Servo           = 0                     ' use P0 header


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

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


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

SYMBOL  pos             = B2
SYMBOL  delay           = W5


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

Reset:
 PINS = %00000000                              ' clear all outputs
 DIRS = %00000011                              ' make P0-P1 outputs


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

Main:
 Relay = IsOn
 pos = 100                                     ' one extreme (60 to 100)
 delay = 26000                                 ' 26 secs (may need tweak)
 GOSUB Servo_Pause

 Relay = IsOff
 pos = 200                                     ' other extreem (200 to 240)
 delay = 15000                                 ' 15 secs (may need tweak)
 GOSUB Servo_Pause

 GOTO Main                                     ' do it again


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

' Use in place of PAUSE to keep servo refreshed

Servo_Pause:
 PULSOUT Servo, pos
 IF delay < 20 THEN SP_Exit
   PAUSE 18
   delay = delay - 20
   GOTO Servo_Pause

SP_Exit:
 PAUSE delay
 RETURN

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


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


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

chuckb0004