November 27, 2024, 09:52:49 AM

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.


ap-8 to prop-1 serial connection

Started by lazerlite, February 18, 2008, 07:04:11 AM

Previous topic - Next topic

lazerlite

Hi JON, Well after about 24 hrs on this, I  need some help please. My ap-8 3-wire servo cable is plugged into the top at B R W, The B/R jumper is  like shown  on page2 (Document Version 2.0)  cofigured for 2400 baud, nothing on 0-p?, and on my prop-1 the servo cable is plugged in on P7.  a Normally  Open Button is on P6, and SETUP JUMPERS  are placed in the "DN". And I installed the Trainer ULN2003an. I also tried to run a test but it just gave me a blue screen? I tried making a program from looking at the Dog_House.bs1 file you wrote because it looks  kinda like what I need mine to do( It ran but the AP-8 DIDN'T PLAY),but  I also need to use an RC-4 with three relays. One for a 120v Cylinder (extended) and other two for 120v light bulbs. However, I did write it first using 'Whats a microcontroller  BASIC Stamp HomeWork Board That I have attached below using ALL LEDS inplace of the Pneumatic Cylender and two 120v bulbs: If at all possible can I please get the code to do this on my PROP-1 ,AP-8,RC-4? I think about this 24/7. Thank You for Your Time and Help.

'whats a Microcontroller - test timing for ap-8,lights, and pneumatics.bs2
'turn LED connecteded to p15 on and off.
'Reapeat 1 time per second indefinitely

'  {$STAMP BS2}
'  {$PBASIC 2.5}

DEBUG " OK.. . SET EM UP"

DO

DEBUG ? IN3
  IF  (IN3 = 1) THEN

HIGH 15                                 ' This being the  AP-8 PLAYING FOR 4.0 SECONDS
PAUSE 4000                           ' wait for 4.5 seconds
PAUSE 250
HIGH 14                                 ' This being first rc-4 (k1)120v Red light bulb ON
PAUSE 250                             ' wait 0.5   
LOW 14                                  ' Red Light off
HIGH 13                                ' This being RC-4 (k2) 120V second Green Light Bulb ON
HIGH 12                                ' This Being 120V PNEUMATIC Cylender extended ,(retracts on a seprate push button)
PAUSE 500                           ' 
LOW 12                                '
LOW 13                                ' Green Light off
LOW15                 
ELSE
PAUSE 500
ENDIF
LOOP

JonnyMac

February 18, 2008, 09:48:42 AM #1 Last Edit: February 20, 2008, 12:15:19 PM by JonnyMac
Here you go:

' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Connections:
' -- replace ULN2803 with ULN2003
' -- connect P7 to RC-4 (serial), RC-4 to AP-8
'    * RC-4 must be first in chain
' -- remove B/R jumper on RC-4 and AP-8
' -- remove A0 & A1 jumpers from RC-4 and AP-8
' -- remove Prop-1 P7 SETUP jumper
' -- move Prop-1 P6 SETUP jumper to UP
' -- connect N.O. switch between P6.R (+5v) and P6.W (input)


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  Baud            = OT2400

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


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

SYMBOL  relays          = B0
SYMBOL   redLight       =  BIT0                 ' connect to RC-4, K1
SYMBOL   grnLight       =  BIT1
SYMBOL   cylinder       =  BIT2


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

Reset:
  ' reset AP-8 and RC-4 on power-up or reset button
  '
  SEROUT Sio, Baud, ("!!!!!!AP8", 0, "X", "!RC4", 0, "X")
  PAUSE 25

  relays = IsOff                                ' all are off now


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

Main:
  IF Trigger = IsOff THEN Main                  ' wait for trigger

Start_Audio:
  SEROUT Sio, Baud, ("!AP8", 0, "P", 0)         ' play sound 0
  PAUSE 4500

Activate_Lights:
  redLight = IsOn
  GOSUB Refresh_RC4
  PAUSE 250

  redLight = IsOff
  grnLight = IsOn
  cylinder = IsOn
  GOSUB Refresh_RC4
  PAUSE 500

  relays = IsOff
  GOSUB Refresh_RC4                             ' clear relays
  SEROUT Sio, Baud, ("!AP8", 0, "X")            ' stop audio
  PAUSE 25                                      ' let AP-8 reset

  GOTO Main



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

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

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


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


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



Be a little careful with "What's A Microcontroller" -- it's a good book but teaches a really bad habit: using pin constants.  You should always name your I/O pins; this makes writing and reading the program much easier, you end up using less comments (good names and labels make a program self-documenting), and programs are always easier to update and troubleshoot.
Jon McPhalen
EFX-TEK Hollywood Office

lazerlite

Hi JON, I hooked it all up,  but  the only way I can get it to do anything is if I remove the baod jumper from the rc-4 and my lights light up. my trigger is not triggering my ap-8 of anything. DO I HAVE SOMETHING HOOKED UP WRONG?

gadget-evilusions

Can you take a picture of your connections so everyone can visually troubleshoot it?
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

My mistake in the notes -- you should REMOVE the Baud (B/R) jumper from the RC-4 and AP-8 for 2400 baud (Prop-1).  Sorry about that.  I've updated the listing above.
Jon McPhalen
EFX-TEK Hollywood Office

lazerlite

Quote from: JonnyMac on February 20, 2008, 12:14:50 PM
My mistake in the notes -- you should REMOVE the Baud (B/R) jumper from the RC-4 and AP-8 for 2400 baud (Prop-1).  Sorry about that.  I've updated the listing above.
Ok They are removed ,but know my lights connected to my rc-4 are just looping over and over without pushing button. no ap-8 is playing. my pic is not showing up on the forum that they asked for.

lazerlite

Quote from: gadget-evilusions on February 20, 2008, 11:13:47 AM
Can you take a picture of your connections so everyone can visually troubleshoot it?

lazerlite

Isn't the setup jumer for P6 "DN"? NOT "UP" for trigger?

lazerlite

I got it. The switch on p6 needed to be jumper "DN" and there was no SERVO CABLE jumped from serial to "P" play on the ap-8. I got it to work now. I have been awake for about 22 hours. how did I figure this out? cool. thank you JON and EVERYONE  for your time and help!

JonnyMac

You should be connecting to the Serial input on the AP-8, not the Play input.  The serial input gives you full control.
Jon McPhalen
EFX-TEK Hollywood Office

livinlowe

Ahhh, yes. The dreaded "leave the jumper in and watch your program cycle over, and over, and over" mistake. I have made that one myself, it does throw you for a loop until you realize what's happening! I notice you pause your program for 4.5 seconds. Is this to wait for the AP-8 to finish playing track 1? If it is, you can use some code to check when the AP-8 is done playing, that way if you change your audio track, you won't have to adjust your pause time.

Anyway, glad you got it working!
Shawn
Scaring someone with a prop you built -- priceless!

lazerlite

Quote from: livinlowe on February 20, 2008, 03:09:06 PM
Ahhh, yes. The dreaded "leave the jumper in and watch your program cycle over, and over, and over" mistake. I have made that one myself, it does throw you for a loop until you realize what's happening! I notice you pause your program for 4.5 seconds. Is this to wait for the AP-8 to finish playing track 1? If it is, you can use some code to check when the AP-8 is done playing, that way if you change your audio track, you won't have to adjust your pause time.

Anyway, glad you got it working!
It just worked out right, the timing of when  my first 120V (red) light is (needs to) come on. but I am interrested in the code thing you speak of.

lazerlite

Quote from: JonnyMac on February 20, 2008, 02:32:56 PM
You should be connecting to the Serial input on the AP-8, not the Play input.  The serial input gives you full control.
I have connected ( prop-1  p-7 to RC-4 SER,SER TO BRW on the ap-8, aP-8  SERIAL TO AP-8 INPUT P .

JonnyMac

You shouldn't be connecting your AP-8.Serial and AP-8.P pins together -- your connections should look something like this:

Jon McPhalen
EFX-TEK Hollywood Office

livinlowe

lazerlite-

Here is a link to my project I did last halloween.

http://www.efx-tek.com/php/smf/index.php?topic=389.0

I got all the code from here on the forums. Hope it helps!
Shawn
Scaring someone with a prop you built -- priceless!