November 15, 2024, 06:56:04 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.


All outputs are P0

Started by NorseKode, August 20, 2009, 10:47:16 AM

Previous topic - Next topic

NorseKode

August 20, 2009, 10:47:16 AM Last Edit: August 20, 2009, 10:58:33 AM by NorseKode
This worked well last night, but I forgot to save early and often.  When I came to work this morning, the computer had been logged out and I lost all my unsaved work.

Insert primal scream.
Repeat.

Code is below.  As you can see, I've commented out almost everything.  In fact, the only thing active is a single output and 2 digital inputs.
It does not seem to matter which output pin is under test.  p0 is the only output that toggles in either Debug (which I've erased from the code completely) or on the Prop Trainer.

I've been invoking the input at p7 with my EFX-Tek screwdriver across the W & R terminals for that port.  The Prop-1 is new (Rev D) and I've removed then replaced the ULN with no effect. 

Cue the moaning.

When I had all the lines of code active, the problem was exactly the same.  Debug would acknowledge the input status correctly, but the output would always be p0.  I've tried a number of things, including playing with the PINS and DIRS settings.  Those at the head of the class will realize I've defined all the pins, yet refer to them by pin number rather than my earlier definitions.  I never really thought the problem lay there, but I was getting a little desperate for a different result by then. 

No joy.

Both input jumpers are in the pull-down mode.  The 'Toggle.BS1' code that ships with the parallax IDE works just as advertised.  The LEDs chase each other dutifully.  The problem seems not to be hardware related, but entirely the result of some little tidbit of programming on my part.

So... what the heck am I doing wrong today?

Help?

**********

' {$STAMP BS1}
' =========================================================================
'
'   File...... TEMPLATE.BS1
'   Purpose... BS-1 Programming Template
'   Author....  Kalo Alexandra
'   E-mail....  kalexandra@gannett.com
'   Started...
'   Updated...



' =========================================================================


' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
'   This is actually 2 switching circuits.
'   The CPU is a Parallax BS1, available from www.efx-tek.com.
'
'   Both inputs are supplied by Miranda equipment GPI/O.
'   This is a powered contact closure circuit.
'   In normal operation (uninvoked), this contact is open (ungrounded).
'   This program sees an open contact as LOW.
'   The circuit uses a current limiting resistor.

'   Circuit (1) handles various tally indicators and the talent IFB confidence switch.
'   This functionality consists of one input and 4 outputs.
'   The input comes from the Miranda Kaliedo in the form of GPI(O) #8.

'   The outputs for (1) consist of 3 tally lights and an IFB confidence audio switch.
'   Each tally light output feeds an external voltage to the relay mounted on the light itself.
'   When the Kaleido contact closes, all tally lights go HIGH.
'     The IFB confidence switch goes LOW at this time.
'   When the Kaleido contact opens (non-live operation), all tally lights go LOW.
'     The IFB confidence switch goes HIGH at this time.
'   The IFB confidence switch itself needs a contact 'open' to engage.
'     And a contact 'closure' turns it off.

'   Circuit (2) forces 10.2 to 'follow' the output of 10.1
'   This is used for Amber Alerts and EAS crawls.
'   The input comes from GPI(O) #8 of the Miranda IS-750.
'   When this is engaged, a crawl is occuring and 10.2 should mirror the output of 10.1

' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------




' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
OUTPUT 0
OUTPUT 1
OUTPUT 2
OUTPUT 3
OUTPUT 4
OUTPUT 5
INPUT 6
INPUT 7
SYMBOL Audio_1_OnAir = PIN0
SYMBOL Control_1_OnAir = PIN1
SYMBOL Control_2_OnAir = PIN2
SYMBOL Confidence_On = PIN3
SYMBOL _10_2_follower = PIN4
'******************************
SYMBOL Echo_Kaleido_GPI = PIN5
SYMBOL Kaleido_Live_GPI = PIN6
SYMBOL IS750_GPI_8 = PIN7
'******************************
SYMBOL Active = 1
SYMBOL InActive = 0
DIRS = %00111111
PINS = %00000000






Main:
  IF PIN7 = 1 THEN Follow  'If pin 7 is hot, force 10.2 to simulcast 10.1 for crawls and alerts
  IF PIN7 = 0 THEN Lead   'Otherwise, 10.2 does it's own thing

Second:
  IF PIN6 = 1 THEN Live_Program   'If pin 6 is hot, we are local and live.  Turn on all OnAir signs
  IF PIN6 = 0 THEN Canned_Program  'Otherwise, all OnAir signs are off
  GOTO Main  'Repeat this polling loop forever

Live_Program:
' HIGH PIN0 'Audio_1_OnAir
' HIGH PIN1 'Control_1_OnAir
' HIGH PIN2 'Control_2_OnAir
' LOW PIN3 'Confidence_On     'The confidence switcher is an active low device
  GOTO Main  'Return to the Main: loop

Canned_Program:
' LOW PIN0 'Audio_1_OnAir
' LOW PIN1 'Control_1_OnAir
'  LOW PIN2 'Control_2_OnAir
'  HIGH PIN3
  GOTO Main  'Return to the Main: loop

Follow:
  HIGH PIN4 '_10_2_follower
  'HIGH PIN5 'Echo_Kaleido_GPI
  GOTO Second  'Return to the Main: loop

Lead:
  LOW PIN4 '_10_2_follower
' LOW PIN5 'Echo_Kaleido_GPI
  GOTO Second  'Return to the Main: loop


NorseKode

I've cut the code down to quite nearly the absolute minimum and my output is identical.

****************

' {$STAMP BS1}
' {$PBASIC 1.0}

DIRS = %00111111

Main:
  IF PIN7 = 1 THEN Follow  'If pin 7 is hot, force 10.2 to simulcast 10.1 for crawls and alerts
  IF PIN7 = 0 THEN Lead   'Otherwise, 10.2 does it's own thing
GOTO Main

Follow:
  HIGH PIN4 '_10_2_follower
  GOTO Main  'Return to the Main: loop

Lead:
  LOW PIN4 '_10_2_follower
  GOTO Main  'Return to the Main: loop

NorseKode

I thought, after the posts above, there might be a problem with the p7 input of the Prop-Trainer so I changed the input to p6, then p5.  The operations are exactly the same (though p5's LED goes hot along with the output when it is used as an input.

Something wrong with the pin assignments?

JonnyMac

August 20, 2009, 11:21:24 AM #3 Last Edit: August 20, 2009, 01:26:23 PM by JonnyMac
Okay, no whine-fests allowed in our forums!  ;D

Based on what I see in your code you could do this process with a couple inverter gates -- if you want to do it with the Prop-1 then this is the most efficient solution (IMO):

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


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


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


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

SYMBOL  IS750           = PIN7                          ' (I)
SYMBOL  Live            = PIN6                          ' (I)
SYMBOL  Echo            = PIN5                          ' (O)
SYMBOL  Follower        = PIN4                          ' (O)
SYMBOL  Confidence      = PIN3                          ' (O)
SYMBOL  Control2        = PIN2                          ' (O)
SYMBOL  Control1        = PIN1                          ' (O)
SYMBOL  Audio           = PIN0                          ' (O)


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

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

SYMBOL  OnAir           = 1
SYMBOL  OffAir          = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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


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

Reset:
 PINS = %00000000                              ' preset IOs
 DIRS = %00111111                              ' define outputs (1s)


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

Main:
 Follower = IS750
 Echo = IS750

Main2:
 Audio = Live
 Control1 = Live
 Control2 = Live
 Confidence = 1 - Live                         ' invert state

Loop_Pad:
 DEBUG CLS, #%PINS                             ' remove after testing
 PAUSE 100
 GOTO Main

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


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


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


Be careful you don't get too crazy with verbose symbols -- you made yours so obnoxiously long that you didn't want to use them in your code, and the whole idea behind symbols is to make code easier to read (from a functional standpoint).

Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

The problem you're having is the use of HIGH.  When you do this:

  HIGH PIN4

... the BS1 is reading the state of PIN4 (which is a bit variable and not the actual output pin) and then using that as the pin number for HIGH.  Since a PINx variable can only be 0 or 1 your output will only go to P0 or P1.  See my listing above; it works the way you want.
Jon McPhalen
EFX-TEK Hollywood Office

NorseKode

Though I hadn't worked out the reasoning, the PIN'X' problem finally fell out of the equation a few minutes ago. 

I do like the simplicity of your code.  Guess that comes from bunches of practice. 
On the subject of inverters: I didn't want to spend time gluing the outputs to the 12VDC driver I'd have to build to get these outputs from the point of GPI breakout across several hundred feet of cable to the destination relays.  Simpler is often better, but sometimes it just isn't so simple as it seems.  This is more expensive, but I can use a single modular unit and a single plug.   It may be 6 of one and half-dozen... but this is the way I went.

Thanks JonnyMac!