November 25, 2024, 12:08:47 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.


Same pin for input and output

Started by davisgraveyard, June 13, 2007, 11:43:44 PM

Previous topic - Next topic

davisgraveyard

I have a Prop-1 with 7 LED's attached to the 12V pins that will go on and off in sequence.  The 8th pin I am connecting to a AP8 & RC4 in serial.     Now I am out of pins but I want to have a trigger to start the whole thing.   Can I use one of the LED pins for a input trigger in a wait loop and then still set it to high as an output for a LED?


JonnyMac

June 14, 2007, 10:20:16 AM #1 Last Edit: June 14, 2007, 10:27:28 AM by JonnyMac
Yes.  Use P6 as your input with the SETUP jumper in the DN position; connect a normally-open switch/button between P6.W and P6.R.  When you press this button you'll get a high (1) on P6 that you can use as a trigger and will also light the LED on OUT6.  Here's how you'd setup your triggering code:


SYMBOL  Trigger         = PIN6

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

Main:
  DIRS = %00111111
  IF Trigger = IsOff THEN Main

Force_Release:
  IF Trigger = IsOn THEN Force_Release

  HIGH 6


The DIRS value in the wait loop puts P6 into input mode so that the next line can monitor the stat of that pin.  The first "On" LED in your program should be P6 as this will mask the lighting that pin from the trigger input.  The reason for the Force_Release section is that you really don't want to have the trigger button pressed when you make P6 LOW -- probably the best thing to do is make that pin an input during its cycle, so instead of:

  HIGH 6
  PAUSE 1000
  LOW 6


You would do this:

  HIGH 6
  PAUSE 1000
  INPUT 6


This will prevent a short circuit between the trigger input and the output of P6 that can happen when its in a LOW state.  There is a 220 ohm resistor on all processor pins to prevent a direct short, but there's no need to take a chance -- use INPUT 6 to turn that pin off (from the processor side).
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

June 14, 2007, 03:50:37 PM #2 Last Edit: June 14, 2007, 04:03:23 PM by davisgraveyard
That all makes sense and it was what I was going to try.  I was even thinking I could do a INPUT instead of a LOW for the pin I wanted to use for both.

Just a couple of thoughts.  Is there a reason for using PIN6 for the duel use? 

I am using PIN7 for serial i/o to a AP8 and RC4.

I am also playing sounds out of the AP8 as soon as the trigger happens and I don't want PIN 6 to GO HIGH right away.  Is this a problem?

I have 12v LED's attached to PIN0-6 and I was using a FOR/NEXT loop to turn them on in sequence. 

I was doing this
FOR i=0 to 6
   HIGH i
   PAUSE 1000
   LOW i
NEXT

Since we don't want to set PIN6 Low I did this

FOR i=0 to 6
   HIGH i
   PAUSE 1000
   IF i < 6 THEN LOW i
   IF i = 6 THEN INPUT i
NEXT

If it is important that PIN6 go first I could reverse the FOR/NEXT loop ( FOR i=6 to 0 STEP -1)?







JonnyMac

Here's how I'd do it -- this way the activation of OUT6 from the trigger is masked by the prop behavior:

Main:
  DIRS = %00111111
  IF Trigger = NotActive THEN Main

Force_Release:
  IF Trigger = Active THEN Force_Release

Zip_Leds:
  FOR ledPin = 6 TO 0 STEP -1
    HIGH ledPin
    PAUSE 1000
    INPUT ledPin
  NEXT

  GOTO Main


Don't bother complicating your LED control loop -- the ULN input side has a pull-down resistor for each circuit which holds that circuit off when the input is floating; this means you can use INPUT pin# to turn of the OUTx teriminal.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Wait a minute....are you saying that if I use PIN6 for a trigger when the switch is turned on that the LED will also come on?  That won't work for me.

The way that I am doing the routine there are sounds that play before the LED's are sequenced so there is a day before the LED's start coming on.

If this is the best I can do then I might be able to add the pre-sounds another way and the prop-1 can start with the first LED?

jeff

JonnyMac

Yep, sorry Jeff, but this is just the way things work -- a high on P6 will feed into the input side of the ULN causing OUT6 to be active; there is no stopping that if you want to use OUT6.

Choices:
  -- add a DC-16 to your chain
  -- switch to a Prop-2
  -- add an external decoder driver board (74HC595 and ULN2003) -- cheap, but you have to build it
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Darn!  You got my hopes up when you said that it would work.    If I triggered PIN6 what is the minimum that the LED would be on?  I might be able to live with a blip of a few milliseconds?

Just trying to squeeze the most of one of my existing Prop-1's

I know I could do this with a Prop-2 but it seems like overkill for such a simple program and only needing 1 more pin.

Same for the DC16 but a cheaper alternative I guess?

No thanks on building my own stuff.  Thats what you guys are for!


JonnyMac

June 14, 2007, 07:23:45 PM #7 Last Edit: June 14, 2007, 07:26:10 PM by JonnyMac
I said it would work and included this phase in my original response: ...on P6 that you can use as a trigger and will also light the LED on OUT6.

If you decide you want to build a simple expander circuit (turns three pins into eight outputs) let me know; I'll show you the schematic.  The parts would cost about $10 and it would take you about an hour to solder together.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Sorry about that didn't catch the subtlety of your first message.

You didn't answer my other question.  How long will the LED be lit for as the trigger connects?

Is there a way to wire a trigger to the rest button of the Prop-1?   


JonnyMac

Sorry, I didn't catch your other questions.

Yes, LED on OUT6 will remain on as long as the trigger button is pressed -- it's hardwired and there is no way around that.

Using the Reset button is not recommended unless it is a simple pushbutton that you (or an actor) will control -- DO NOT use this strategy for triggers that can be held down or retriggered before the program cycle completes.  I think you'll agree that using the reset button as a trigger is not a good idea, especially since it requires you to solder on the Prop-1, voiding its warranty.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

I gave up trying to make this work and just ordered a DC16.  Now I will have more than enough outputs and it was less than the Prop-2.    I will just put all my LED outputs on the DC16 and use P6 on the Prop-1 for the trigger and P7 for the serial i/o.  Then I have 6 other pins to use for future stuff.

Good to know that it would work as long as don't mind the pin going high as soon as you trigger it.