November 23, 2024, 10:33:17 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


output problems

Started by time2dive, June 07, 2011, 04:05:09 AM

Previous topic - Next topic

time2dive

I am testing a prop1 to use in a simple pop up prop.  I am using 12v LED panels to test the outputs.  My problem is that only OUT0 appears to work.
This is the first time that I am using a Prop1, I do have experience with the Prop2
Here is the program that I am running.

' =========================================================================
'
'   File...... tim04-pop up.bs1
'   Purpose... simple pneumatic pop up
'   Author.... Timothy Ewing
'   E-mail.... time2dive@hawaii.rr.com
'   Started... 04 June 2011
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'   Simple pneumatic pop up
'   input PIR
'   output pneumatic solenoid
'   output lights

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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  trigger         = PIN6                  ' SETUP = DN
SYMBOL  white           = PIN0
SYMBOL  red             = PIN1



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

SYMBOL  IsOn            = 1                     ' for ative-high input
SYMBOL  IsOff           = 0


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


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

Reset:


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

Main:
  IF Trigger = IsOff THEN Main                  ' wait for trigger
  DEBUG   "start"
  PAUSE 1000
  HIGH white
  DEBUG "white"
  PAUSE 1000
  HIGH red
  DEBUG "red"
  PAUSE 10000
  LOW white
  LOW red
  PAUSE 5000
  DEBUG   "finish"
  GOTO Main


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


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


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


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


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


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


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


I have the + side of the panels going to V+ and the - sides going to OUT0 and OUT1
The LED panels do work when I hook the - to GND

JonnyMac

The problem is with our definitions.  When using HIGH and LOW you must specify the pin as a number (0..7), not as an IO variable (PINx).  This is, I believe, the trickiest aspect of the Prop-1.  Let me try to explain.

When you use PINx (PIN0..PIN7) the behavior depends on which side of "=" the PINx statement falls.  When you do this:

 HIGH PIN7

... what is happening is that the processor is reading the state of PIN7 -- which will usually be low (0) do to the pull-down circuitry in the ULN -- and converting your statement to:

 HIGH 0

This is why you seem to get OUT0 working and no other.  If you change your definitions to this the program should work the way you expect.

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

SYMBOL  Red             = 1
SYMBOL  White           = 0


Note, too, that I ordered the pins as they appear on the PCB: 7 on top, 0 on bottom.  Note the change to Red and White to the actual pin numbers instead of pin variables (PINx).  We still need the PIN6 definition for Trigger because that's a pin we want to read.
Jon McPhalen
EFX-TEK Hollywood Office

time2dive

That fixed the problem.  I figured it was a difference in syntax between the Prop1 and Prop2.  I just could not find it in my documentation.

Tim

JonnyMac

June 07, 2011, 12:55:30 PM #3 Last Edit: June 07, 2011, 12:59:08 PM by JonnyMac
Remember that the BS2 came well after the BS1, and when we (I was working for Parallax at the time) were defining PBASIC 2.5 we made changes that would allow the compiler to intelligently deal with PINx variables.  This makes PBASIC 2.5 easier to use and less prone to the introduction of subtle errors.
Jon McPhalen
EFX-TEK Hollywood Office