November 21, 2024, 02:42:38 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.


Learning to trigger with the Prop-1

Started by camronduran, July 12, 2018, 01:58:35 PM

Previous topic - Next topic

camronduran

July 12, 2018, 01:58:35 PM Last Edit: July 12, 2018, 02:25:48 PM by camronduran
Hello everyone!

I'm trying to learn how to use the Prop-1 with very little experience in using micro-controllers and I seem to have hit a roadblock, so please bare with me.

GOAL: I am trying to figure out how to get an electromagnetic lock to release when two buttons are pushed at the same time.

ISSUES: Pretty simple, I think, but I cannot seem to get a single trigger to work, let alone two. Attached is the code to the point that I am confident of - mostly. I tried reading through the tutorial on triggering, but I couldn't understand how it worked, and messing with values and trying different things didn't seem to change much of my understanding. Even more confusing for me is that when I have the magnet connected to PIN1 as the code requests, nothing happens, but if I have it on PIN0 (contrary to the code's request) it works.
I currently have the magnet connected red-red and white(controller)-black(magnet) since my understanding from other projects is that white is usually the trigger, which seems to hold true here. Controller's black wire is not connected. (EDIT: After looking around the forum a bit I noticed a warning against using coil devices on the PIN outputs, but when I try and define OUT0(-7) it comes back as undefined. Am I doing something wrong?)

If anyone is able to help clarify my confusions and help me get this working, I'd be eternally grateful.

Thank you!

JonnyMac

July 12, 2018, 06:08:02 PM #1 Last Edit: July 12, 2018, 06:10:58 PM by JonnyMac
QuoteGOAL: I am trying to figure out how to get an electromagnetic lock to release when two buttons are pushed at the same time.

Question: Do the buttons have to be pressed simultaneously (like turning two key switches in a nuclear silo) or can you press one, then the other?

Hopefully you're connecting your electromagnet between V+ and OUT0 -- do not connect electromagnetic devices to the pin headers; this can cause damage to the controller.
Jon McPhalen
EFX-TEK Hollywood Office

camronduran

Simultaniously!

I was before, but stopped as soon as I saw the warning. I was able to connect the magnet to V+ and OUT0, but was unable to declare it in the code, hence my experimention.

JonnyMac

Here's an example program that waits for both buttons to be pressed -- though you don't have to press them simultaneously. If you need the buttons to be pressed at the same time, I will adjust.

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


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


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


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

SYMBOL  Btn2            = PIN7                  ' SETUP = DN
SYMBOL  Btn1            = PIN6                  ' SETUP = DN

SYMBOL  GreenLamp       = 2                     ' lock state indication
SYMBOL  RedLamp         = 1

SYMBOL  MagLock         = 0                     ' lock control


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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  check           = B2


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

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P5..P0 are outputs


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

Main:
  HIGH MagLock                                  ' engage lock
  HIGH RedLamp
  LOW GreenLamp

Wait_For_Pressed:
  PAUSE 100
  check = PINS & %11000000                      ' isolate buttons inputs
  IF check = %11000000 THEN Unlock_It           ' both pressed? go!
    GOTO Wait_For_Pressed                       ' no, try again

Unlock_It:
  LOW MagLock                                   ' disengage lock
  LOW RedLamp
  HIGH GreenLamp
  PAUSE 5000                                    ' hold open 5s

  GOTO Main                                     ' reset
Jon McPhalen
EFX-TEK Hollywood Office