November 15, 2024, 12:43:18 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.


Prop1 Groundbreaker prop

Started by youngti, May 19, 2009, 03:25:02 PM

Previous topic - Next topic

youngti

Okay, so I re-wired the vmusic and still couldn't get it to work.  So I've taken your advice and started a little smaller.  I cut out all of the vmusic code and just worked one the solenods and the RC-4.   IT WORKS, here is what I came up with.

' =========================================================================
'
'   File...... GroundBreaker_V1.BS1
'   Purpose...
'   Author.... Tim Young (clean-up by Jon Williams)
'   E-mail....
'   Started... 05-19-09
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  RX              = 7                     ' SETUP = UP, no ULN
SYMBOL  TX              = 6                     ' SETUP = UP, no ULN
SYMBOL  Sio             = 5                     ' no ULN
SYMBOL  Trigger        = PIN3
SYMBOL  Solenoid2       = PIN1
SYMBOL  Solenoid1       = PIN0

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

SYMBOL  Baud            = OT2400

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  BreakTime       = 15000

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

SYMBOL  relays          = B0
SYMBOL   K1             =  BIT0
SYMBOL   K2             =  BIT1
SYMBOL   K3             =  BIT2
SYMBOL   K4             =  BIT3

SYMBOL  delay           = B2
SYMBOL  volume          = B3

SYMBOL  timer           = W4
SYMBOL  lottery         = W5
SYMBOL   lottoLo        =  B10
SYMBOL   lottoHi        =  B11



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

Reset:
  PINS = %00000000                              ' start with all off
  DIRS = %00010111                              ' set output pins

  SEROUT Sio, Baud, ("!RC4", %0000, "X")          ' clear RC-4 outputs

  PAUSE 15000                                   ' PIR warm-up, reset delay


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

Main:
  timer = 0
Check_Trigger:
  RANDOM lottery                                ' stir random value
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  K1 = IsOn                               ' light on
  relays = %0001
  GOSUB Update_RC4

  timer = 0

Ground_Break:
  RANDOM lottery                                ' create new timing
  Solenoid1 = LottoLo
  Solenoid2 = LottoHi
  RANDOM lottery                                ' re-stir random
  delay = lottery // 201 + 50                   ' between 50 and 250 ms
  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update timer
  IF timer < BreakTime THEN Ground_Break

Quit:
  LOW Solenoid1                                 ' stop it
  LOW Solenoid2
  K1 = IsOff
  relays = %0000
  GOSUB Update_RC4
  PAUSE 15000                                   ' hold 15 secs
  GOTO Main                                     ' start over

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

Update_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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

Now I just need to figure out what is going on with the vmusic.  Thank you once again Jon, you guys are the best.

JonnyMac

Just a note, Tim; these lines are redundant:

  K1 = IsOn                               ' light on
  relays = %0001


I suggest you use the first as it's more obvious.  You can also change "K1" to "Light" and then the program is self-documenting. 

Jon McPhalen
EFX-TEK Hollywood Office

youngti

Yea, looking at the program they do the same thing.  I appreciate your help on this. 

youngti

Okay, so i am also not very happy with the vMusic.  i can't seem to get it to work, the lights come on but no joy as far as playing any music.  I have tried just using the code from one of your original post on the set-up of the vMusic, but nothing.  I'm beginning to think it's a hardware issue.

Everything else is working great.  I really appreciate your suggestions and help.

BigRez

Did you update the firmware and are you sure the update was successful?  Did you do that with the cable or a thumb drive?  IN either case, when updating, did you update only the baud rate or did you also update the firmware version?

If you didn't update the firmware version, then larger thumb drives (those over 512K) will not work and the sound bit rate must be 224k/sec or less.  If you exceed that rate the sounds won't play.  The device won't recognize larger drives if you don't get the updated firmware.

mike

youngti

I updated the firmware last year when I first bought these and they worked then.

youngti

I have given up on the vmusic.  I re flashed and tried again, no go.  so it onto a CAP.  Only problem is that I can get the CAP200 to play but it plays once when I turn the PROP1 on and then not agian.  The rest of the program works at the PIR trigger, but not the CAP200.  I must be missing something.  i do have the CAP200 wired as you have on http://www.efx-tek.com/php/smf/index.php?topic=806.0.  As you can see I have changed the timing in the code, but even if I put it back I get the same result.  I appreciate any help.

' =========================================================================
'
'   File...... GroundBreaker_V1.BS1
'   Purpose...
'   Author.... Tim Young (clean-up by Jon Williams)
'   E-mail....
'   Started... 05-19-09
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN7                  ' SETUP = DN, no ULN
SYMBOL  Sio             = 5                     ' no ULN
SYMBOL  CAPAudio        = PIN4                  'Cowlacious CAP200
SYMBOL  LeftEye         = PIN3                  ' Led eye
SYMBOL  RightEye        = PIN2                  ' Led eye
SYMBOL  Solenoid2       = PIN1
SYMBOL  Solenoid1       = PIN0

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

SYMBOL  Baud            = OT2400

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  BreakTime       = 30000

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

SYMBOL  relays          = B0
SYMBOL   K1             =  BIT0
SYMBOL   K2             =  BIT1
SYMBOL   K3             =  BIT2
SYMBOL   K4             =  BIT3

SYMBOL  delay           = B2

SYMBOL  timer           = W4
SYMBOL  lottery         = W5
SYMBOL   lottoLo        =  B10
SYMBOL   lottoHi        =  B11



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

Reset:
  PINS = %00000000                              ' start with all off
  DIRS = %00100011                              ' set output pins

  SEROUT Sio, Baud, ("!RC4", %0000, "X")          ' clear RC-4 outputs


  PAUSE 5000                                   ' PIR warm-up, reset delay


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

Main:
  timer = 0
Check_Trigger:
  RANDOM lottery                                ' stir random value
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  LeftEye   = IsOn
  RightEye  = IsOn

  Start_Audio:
    GOSUB CAP_Start
    PAUSE 5000

  K1 = IsOn                               ' light on
  GOSUB Update_RC4

  CAPAudio = IsOn

  timer = 0

Ground_Break:
  RANDOM lottery                                ' create new timing
  Solenoid1 = LottoLo
  Solenoid2 = LottoHi
  RANDOM lottery                                ' re-stir random
  delay = lottery // 201 + 50                   ' between 50 and 250 ms
  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update timer
  IF timer < BreakTime THEN Ground_Break

Quit:
  LOW Solenoid1                                 ' stop it
  LOW Solenoid2
  K1 = IsOff
  relays = %0000
  GOSUB Update_RC4
  PAUSE 5000                                   ' hold 5 secs
  GOTO Main                                     ' start over

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

Update_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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

CAP_Start :
  CAPAudio = IsOn
  PAUSE 5000
  CAPAudio = IsOff
  RETURN

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

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

JonnyMac

June 08, 2009, 05:36:49 AM #22 Last Edit: June 08, 2009, 05:41:31 AM by JonnyMac
I'm standing at a wi-fi bench in an airport as I write this so I'll be as helpful as I can without any product to play with.

Issues I can see:
-- you don't need a 5000ms pause in CAP_Start; change it to 250
-- remove the CAPAudio = IsOn line that happens after the call to CAP_Start
    * this could cause unwanted looping once the wiring is sorted
-- make sure that OUT4 (not P4) is connected to the CAP trigger input
-- make sure that the GND terminal is connected to ground on the CAP board

Let me suggest that until you get really comfortable with connecting other "smart" devices to the Prop-1/2/SX that you not try to integrate them into your programs; write a test program first that verifies you connections and any code required for the device.  Once this works you can move that into your prop control code.  Even I do this -- it's better to work with new products in isolation until you get a really good handle on them.
Jon McPhalen
EFX-TEK Hollywood Office

youngti

Thank you for the info.  I keep telling my self to slow down but sometimes I don't listen.  I will try your suggestions.  One question, when you put in the lines in the I/O definition is there a difference between PIN4 and just 4?  As I look at other code you have written it seems to me that PIN4 is the TTL pins and just 4 would be the outs.  Is that right?

livinlowe

No, the difference between pin4 and 4 is how it is used by a command. Like Serout you can't say Serout pin4,baud, etc. The help file says Serout is Serout Pin#,Baud rate, etc.
Shawn
Scaring someone with a prop you built -- priceless!

youngti

Okay, so yeah I do have the CAP200 on the out 4 Power to V+ and ground to the Ground on the Prop 1.

JonnyMac

You need to make P4 and output; change your DIRS line to:

  DIRS = %00110011

Notice that I changed bit4 of the DIRS register to a 1 to make it an output.  I like using the SomePin = IsOn kind of programming but you have to make sure the pin has been set to output state before that will work.

Sorry I missed that the first time -- that's one of those sneaky things we have to be careful with.
Jon McPhalen
EFX-TEK Hollywood Office

youngti

Thank you, as always your have been a great help.  Your service is excellent.  I have not had a chance to get back to this yet, but I hope to work on it this weekend. 

youngti

Okay, so I Finlay had time to work on this and cleaned up the spots you suggested.  I think I have figured out what is going on, but not sure where this issue is.  after observing the operation for a while it looks like the program is cycling through with out being triggered by the PIR.   I am posting the cleaned up code and maybe you can suggest where I am going wrong.  The CAP200 still only runs once when the power is turned on then not again.


' =========================================================================
'
'   File...... GroundBreaker_V1.BS1
'   Purpose...
'   Author.... Tim Young (clean-up by Jon Williams)
'   E-mail....
'   Started... 05-19-09
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN7                  ' SETUP = DN, no ULN
SYMBOL  Sio             = 5                     ' no ULN
SYMBOL  CAPAudio        = PIN4                  'Cowlacious CAP200
SYMBOL  LeftEye         = PIN3                  ' Led eye
SYMBOL  RightEye        = PIN2                  ' Led eye
SYMBOL  Solenoid2       = PIN1
SYMBOL  Solenoid1       = PIN0

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

SYMBOL  Baud            = OT2400

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  BreakTime       = 30000

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

SYMBOL  relays          = B0
SYMBOL   K1             =  BIT0
SYMBOL   K2             =  BIT1
SYMBOL   K3             =  BIT2
SYMBOL   K4             =  BIT3

SYMBOL  delay           = B2

SYMBOL  timer           = W4
SYMBOL  lottery         = W5
SYMBOL   lottoLo        =  B10
SYMBOL   lottoHi        =  B11



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

Reset:
  PINS = %00000000                              ' start with all off
  DIRS = %00110011                              ' set output pins

  SEROUT Sio, Baud, ("!RC4", %0000, "X")          ' clear RC-4 outputs


  PAUSE 5000                                   ' PIR warm-up, reset delay


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

Main:
  timer = 0
Check_Trigger:
  RANDOM lottery                                ' stir random value
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  LeftEye   = IsOn
  RightEye  = IsOn

  Start_Audio:
    GOSUB CAP_Start
    PAUSE 5000

  K1 = IsOn                               ' light on
  GOSUB Update_RC4

Ground_Break:
  RANDOM lottery                                ' create new timing
  Solenoid1 = LottoLo
  Solenoid2 = LottoHi
  RANDOM lottery                                ' re-stir random
  delay = lottery // 201 + 50                   ' between 50 and 250 ms
  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update timer
  IF timer < BreakTime THEN Ground_Break

Quit:
  LOW Solenoid1                                 ' stop it
  LOW Solenoid2
  K1 = IsOff
  relays = %0000
  GOSUB Update_RC4
  PAUSE 5000                                   ' hold 5 secs
  GOTO Main                                     ' start over

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

Update_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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

CAP_Start :
  CAPAudio = IsOn
  PAUSE 250
  CAPAudio = IsOff
  RETURN

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

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

JonnyMac

If it's starting without an external trigger input check the position of the P7 SETUP jumper -- I suspect it's in the UP position which is creating a false input.  Move it to DN.
Jon McPhalen
EFX-TEK Hollywood Office