May 19, 2024, 02:18:20 AM

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.


review proram

Started by robbob, October 14, 2007, 03:51:41 PM

Previous topic - Next topic

robbob


THIS IS MY FIRST PROGRAM ATTEMPT COULD ANY ONE PLEASE TAKE A LOOK ?
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL Sio  = 7
SYMBOL Pir = PIN6
SYMBOL valve =PIN0
SYMBOL IsOn =1
SYMBOL IsOff =0
SYMBOL Cylinder Tm = 50
SYMBOL Shaketime = 15000
SYMBOL off delay = 2000
SYMBOL idx =B2
SYMBOL shaker =w4
SYMBOL LOTTERY =w5
Dirs = %00000001
Lottery = 1031
SEROUT Sio, ot2400,("!!!!!!! RC4",O,"x",!AP8",o,"x")
Main:
Random lottery
IF PIR = is off then main
shaker = 0
serout sio , ot 2400 ("!AM8 ",o,"p",o)
serout sio , ot 2400 ("!RC4",o,"S",%0011)
THASH_about:
FOR IDX = 1 to 3
Random lottery
NEXT
BODY = lottery
PAUSE CylinderTM
SHAKER = SHAKER + CYLINDERTM
IF shaker < shake time then thash_about
POST_DELAY
PINS = %00000000
PAUSE OFF DELAY
GOTO MAIN





JonnyMac

October 14, 2007, 05:11:43 PM #1 Last Edit: October 14, 2007, 05:13:36 PM by JonnyMac
RobBob,

Did you actually put that into the PBASIC editor?  If you did, try pressing on the Memory Map button -- you'll see that there is a lot of problems.  This is the danger of copy-and-pasting without fully understanding what you're copying from (I recognize that code as mine).  In there end, here's what it should have looked like:

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Valve           = PIN0


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

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

SYMBOL  CylinderTm      = 50
SYMBOL  ShakeTm         = 15000
SYMBOL  OffDelay        = 2000


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

SYMBOL  idx             = B2
SYMBOL  tix             = B3
SYMBOL  shaker          = W4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear output(s)
  DIRS = %00000001                              ' configure output

  SEROUT Sio, OT2400,("!!!!!!!RC4", %00, "X","!AP8", %00, "X")
  PAUSE 20000
  tix = 0


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

Main:
  RANDOM lottery                                ' stir random value
  PAUSE 10
  tix = tix + 10 * PIR                          ' update or clear timer
  IF tix < 250 THEN Main                        ' wait for valid signal

  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)
  SEROUT Sio, OT2400, ("!RC4", %00, "S", %0011)

  shaker = 0

Thrash_About:
  FOR idx = 1 TO 3
    RANDOM lottery
  NEXT
  Valve = lottery
  PAUSE CylinderTm
  shaker = shaker + CylinderTm
  IF shaker < ShakeTm THEN Thrash_About

  GOTO Reset


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


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


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


Now, I probably have a few years head start on you -- still, you can get really good in a week or so of study.  Start with our programming basics presentations; you can find them linked to the Prop-1 page of our web site.
Jon McPhalen
EFX-TEK Hollywood Office