November 26, 2024, 07:00:09 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Devious Concotions Pneumatic Lifter w/Vmusic & Push Button Trigger

Started by halloweenrick, September 19, 2008, 07:46:03 PM

Previous topic - Next topic

halloweenrick

Hello Jon and all,
I am building the DC Pneumatic Lifter Prop from Brent's Book 1. I have also already got the Prop1 with Garage of Evil's Push Button trigger attatched and a test code for the Vmusic2 Player.  Here is the code I have got for that: (Liberally taken from Scary terry's site)
========================================================================
'
'   File....... vm2_bs1_demo.bs1
'   Purpose.... Demonstrate VMusic2 driven by a BASIC Stamp 1 or Prop-1
'   Author..... Scary Terry
'   E-mail..... terry@scary-terry.com
'   Started.... 4/6/2008
'   Updated.... 4/9/2008
'
'   {$STAMP BS1}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
' Sends serial commands to the VMusic2 via the RXD input.  The following are the individual commands
' (note that 13 is a "carriage return):
' VPF file 13   Plays single file where "file" is MP3 name, MAXIMUM 8 CHARACTERS PLUS EXTENSION (8.3)
' VST 13        Stops play
' V3A 13        Plays all MP3 files
' VRA 13        Repeatedly plays all MP3 files
' VRR 13        Repeatedly plays random MP3 files
' VSF 13        Skip forward one track
' VSB 13        Skip back one track
' VP 13         Pause
' VSV byte 13   Sets playback volume, 0 loud, 256 off

'Also receives serial data from VMusic2 via the TXD output.  I've found about the only useful thing it
'sends is the word "Stopped" at the end of a playback file.

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

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

' -----[ Constants ]-------------------------------------------------------
SYMBOL Baud = T2400                          'The baud rate we'll be using is TRUE 2400
SYMBOL Trigger = PIN0
' -----[ Variables ]-------------------------------------------------------

' -----[ EEPROM Data ]-----------------------------------------------------


' -----[ Initialization ]--------------------------------------------------
PAUSE 5000                                   'allow VMusic2 to initialize
SEROUT 7,Baud, ("VST",13)                    'stop anything that's playing
' -----[ Program Code ]----------------------------------------------------

Main:
IF trigger =0 THEN MAIN
SEROUT 7,Baud,("VPF test.mp3",13)           'Play a file named "test.mp3"
PAUSE 5000
SEROUT 7,Baud,("VP",13)                     'Pause playback of "test.mp3"
PAUSE 3000
SEROUT 7,Baud,("VP",13)                     'Resume playback of "test.mp3"
PAUSE 5000
SEROUT 7,Baud, ("VSV 30",13)                'Reduce playback volume
PAUSE 5000
SEROUT 7,Baud, ("VSV 0",13)                 'Return playback volume to full
PAUSE 5000
SEROUT 7,Baud, ("VST",13)                   'Stop playback of "test.mp3"

SEROUT 7,Baud, ("V3A",13)                   'Command to play all mp3 files.  It will play whatever file it first finds
PAUSE 5000
SEROUT 7,Baud, ("VSF",13)                   'Skip forward one track.  It will play the next file
PAUSE 5000
SEROUT 7,Baud, ("VSB",13)                   'Backs up to the start of this track.
PAUSE 5000
SEROUT 7,Baud, ("VST",13)                   'Stop playback

SEROUT 7,Baud,("VPF test2.mp3",13)          'Play a file named "test2.mp3"
PAUSE 2000                                  'necessary for timing purposes
SERIN 1, T2400, (">")                       'Waits for "test2.mp3" to stop playing.  VMusic2 sends ">" character at end of file.
PAUSE 2000

GOTO Main
END
' -----[ Subroutines ]---------------------------------------------


I was hoping to figure this out myself but its not going well.  I have the Push Button Trigger on Pin 0 and the Vmusic player on 7, so I can add the pneumatic cylinder on any pin but those.  I would like it so when I hit the Push Button trigger, the cylinder fires and the music plays, rotating between 5 music files.  (I assume I just keep going with the Test options and renaming their files to something more appropriate)  Would I then after to hit the trigger again to lower this prop?  I have a soleniod regulating the air thats regular 110 elec.  Thanks Jon for all you do for us programming challenged people.
Rick

JonnyMac

In the future you don't need to post demo code from another site (even our friends) unless you've modified it for your own needs and need help with the modification.  John and I are pretty good at this stuff!  ;D

I think this will do it (it works on my desk, anyway).  It may seem odd at first but you can in fact look at the state of an output to see what it's doing.  That's what this program does.  When you get a valid trigger we look at the Lifter; when the Lifter is off we turn it on and start the music.  When the lifter is on we turn it off and stop the music.  I added a little code that forces you to let go of the button.

Note that I changed your IO a bit.  And remember that we can only run 12 or 24 volt solenoids from the Prop-1/2/SX; if you are using a 120 VAC solenoid then you need to put a relay between the Prop-1 (coil goes to V+ and OUT0) and the 120 volt solenoid.


[Edit] Updated: 03 OCT 2008

' =========================================================================
'
'   File...... Ricks_DC_Lifter.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 03 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

' Connections:
'
' Prop-1        VMUSIC
' ------------  -----------------
' P7.W (RX)     TX  (#5, yellow)
' P7.B (GND)    CTS (#6, green)
' P6.W (TX)     RX  (#4, orange)
' P6.R (+5v)    5v  (#3, red)
' P6.B (GND)    GND (#1, black)


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


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

SYMBOL  RX              = 7                     ' SETUP = UP, no ULN
SYMBOL  TX              = 6                     ' SETUP = UP, no ULN
SYMBOL  Trigger         = PIN5                  ' use P5.W and P5.R
SYMBOL  Lifter          = PIN0                  ' use OUT0


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000001                              ' make P0-P5 outputs

  PAUSE 2500                                    ' let VMUSIC power up
  GOTO Stop_Music


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Check_Status:
  IF Lifter = IsOn THEN Stop_Music

Start_Music:
  Lifter = IsOn
  SEROUT TX, Baud, ("VRA", 13)                  ' random repeat all
  GOSUB VM_Wait_Start                           ' let it start
  GOTO Force_Release                            ' prevent stuck button

Stop_Music:
  Lifter = IsOff
  GOSUB VM_Stop                                 ' kill the music
  GOSUB VM_Wait_Prompt                          ' make sure it's off

Force_Release:
  IF Trigger = IsOn THEN Force_Release          ' let it go, bud!
    GOTO Main


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

VM_Wait_Start:
  SERIN RX, Baud, ("T $")                       ' hold for track timing
  RETURN

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

VM_Stop:
  SEROUT TX, Baud, ("VST", 13)
  RETURN

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

VM_Wait_Prompt:
  SERIN RX, Baud, (">")
  RETURN


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






Jon McPhalen
EFX-TEK Hollywood Office

halloweenrick

I can't get a good test on the Prop1.  When I hook the Vmusic Player on Pin 7, I get nothing. When I run the basic scary terry Vmusic demo program on Pin 0, the player works great.  I have the Trigger on Pin5, and the solenoid is hooked up with the relay and is getting power on V+ and the OUT 0.  Am I missing something simple? I have the jumpers on the UP pin and my ULN2003 is in all but the top two sockets. Something with the trigger maybe? 
Thanks for all that you guys do
Rick

JonnyMac

I'm sure you are (missing something simple) because the program runs fine on my end.  My code is a little different that Terry's because it does more checking.  If you're not using P6 and P7 it won't work -- my code is looking for responses.

-- make sure you have P7 going to the TX pin of the VMUSIC
-- make sure the P7 SETUP jumper is UP
-- make sure you have P6 going to the RX pin of the VMUSIC
-- make sure the P6 SETUP jumper is UP
-- if you're using the ULN2803 clip off pins 1 and 2; if using the ULN2003 clip off pin 1 (P6 and P7 must be free of the ULN)

I think the last suggestion is where things are snagging.

So why does Terry's version work for you?  I won't bore you with the technicalities but he's using T2400 instead of OT2400.  We tend to use OT2400 to have one baud definition for the VMUSIC and EFX-TEK accessories.  A simple check would be changing the baud constant to T2400 (no "oh").
Jon McPhalen
EFX-TEK Hollywood Office

halloweenrick

Uh oh.
I used Garage of Evil's site in wiring up my Vmusic2 player.  Their schematic calls for shaving back the yellow wire at Pin5 (the TX) In that way, I have but the one cable with pins 1,3,4 and 6 of the Vmusic player connected to the servo end cable-going to Pin 7 on the Prop1.  I assume I now need the yellow wire of the Vmusic player TX to go to Pin 6.  I'll need to get another servo cable in a few days to finish.  Would the yellow TX wire go to just the White wire on Pin 6? Also, do I need to remove some wires from the Vmusic2 wire harness?  Here is the link to GoE's schematic:
http://www.garageofevil.com/tech/vmusic2_tutorial.php
So the crux of the problem is I have nothing on Pin 6. I'll get that servo cable and work on it again.  I have another Vmusic2 harness cable if I need to change it.
I knew it was something simple.
Thanks!!
Rick

halloweenrick

Ok, still not much going right, but I feel like I'm making progress.
I got that other servo cable, and luckily checked on here before I did anything.  I saw Wonderrob's post in the Audio section. GOE's site has the yellow wire cut back, but according to your last post to Wonderrob, that actually is the TX to go to Pin 7, and the orange (RX) needs to go to Pin 6. So I have that done. 
So-
Pin7- Yellow to White, Red to Red,Green to Black
Pin6- Orange to White
Pin5 -Push Button Trigger, red to red, green to black
When I hook this up, I have power from V+ and OUT0 going through the relay to the solenoid, but I can't get any response from the VMusic. I tried Wonderrob's program but couldn't get anything either. I ran the Push Button test from GOE's site, works fine, and as I posted earlier it works on Pin0.  Now I think I must be getting down to the obvious stuff again.  I have to jumpers on the UP and middle pin, and I have clipped one set off my ULN2003. Did I mess up the ULN?  Thanks again guys for helping me out.  I await the Oracle as well, to quote Wonderrrob.

JonnyMac

I have updated the listing (above) to show you how I do my connections.  They work, I just ran your program again (though I did find a boo-boo, I had used "VRR" instead of "VRA").

Your options: 1) Rewire per my connections:

' Connections:
'
' Prop-1        VMUSIC
' ------------  -----------------
' P7.W (RX)     TX  (#5, yellow)
' P7.B (GND)    CTS (#6, green)
' P6.W (TX)     RX  (#4, orange)
' P6.R (+5v)    5v  (#3, red)
' P6.B (GND)    GND (#1, black)


2) If you can find a pin that works for you then swap that swap that in to the TX definition in my program and remove any lines that are looking for a response from the player (I don't like this option but, hey, it's your prop <wink>).  Use an apostrophe (')at the front of lines that look like this to comment them out (the line will turn green to show that it's now inactive [a comment]).

GOSUB VM_Wait_Start
GOSUB VM_Wait_Prompt
Jon McPhalen
EFX-TEK Hollywood Office

halloweenrick

Option #1 worked great!  The Vmusic player works perfectly!  Now I can't get the relay to work right!
I got a 12v/10 amp relay from Radio Shack Part #275-218. Here is the link: http://www.radioshack.com/product/index.jsp?productId=2049722&cp= .  I'll attach the schematic I'm using as a .txt file.  I have the prop wired as per the schematic and cannot get the prop to fire but the first time I plug it in.  Its like the Prop1 (Hooked up to V+ and OUT0) gets to the relay, and the relay never shuts the power off to the 120v solenoid.   Do I have the wrong relay, or is it a defective one?  Or, once again, have I missed something obvious? Thanks to Jon and all for putting up with my antics and general prop building unworthiness.  (Looks at ground, downcast)
Thanks again!
Rick

JonnyMac

I spent a lot of time testing that program so I know it works.  Maybe you have a bad relay or ULN.  Connect one lead of the relay coil to V+, move the power switch to P2, then touch the other coil lead to GND.  The contacts should close when you do this.  When you remove the wire from the GND terminal it should open.

I've never seen a ULN lock up, especially since that's way under the current spec for a single ULN channel, but it's possible.  You could change definition for lifter and use another terminal as a test.
Jon McPhalen
EFX-TEK Hollywood Office