November 21, 2024, 06:52:58 PM

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.


HELP! do's and don'ts

Started by kegg750, July 22, 2010, 05:16:05 PM

Previous topic - Next topic

kegg750

So i have a efx-tek prop-2 controller. 

I have been reading, and reading and have only gotten more and more confused.   

What im trying to do...

I'm good with visual basic and will write a visual basic program to send commands to the prop-2
The prop-2 will use its own regulated 12v-1amp powersupplly at the plug to power the bs2. 
I will use a seperate 12v computer power supply to power 12v lights or relays. 
The prop-2 power switch will be in POS 1?
I will wire the ground from the 12v computer power supply to the GND on the prop-2 terminal strip?
So the prop-2's outputs if HIGH will pass the ground to my relay, right?   

The prop-2 will be connected to my computer via the onboard programming db9, and will communicate with my VB program.
accepting on/off commands for out0-out15
Is this ok?

What do i have to declare in BSE for this configuration?   I'm having trouble understanding how to program the prop-2 for this.  Thanks for any help.

JonnyMac

You have to be VERY careful using old computer power supplies because they are designed to have a certain load on them; if they are not properly loaded then can fail to regulate properly and you'll have all sorts of problems.  Put a load (power resister) on the output of the supply so the even if no relays are active, the supply will see a small load and will provide the correct voltage output.

Once that's sorted, yes, connect ground from the power supply to the GND terminal and use the positive side of the supply to the other side of your devices -- do not connect the positive side of your computer power supply to the Prop-2.

Yes, you can send serial commands through the programming port.  User SERIN on pin 16 at the baud rate you desire.  You might want to use a timeout so that you can re-sync things if there's a problem.

Jon McPhalen
EFX-TEK Hollywood Office

menehune

You can look at the Scary-Terry web page on ATX power supplies for some tips on how to use an old ATX power supply.
http://www.scary-terry.com/atxps/atxps.htm
A web search in your favorite search engine can also yield additional pages.

kegg750

Thank you for your reply! Yes I followed a tutorial on converting a psu into a power station. I have a light on it to keep the regulator happy.  I don't need help with the PSU I need help with how the code should look to achieve my goal stated above.  So I need to declare pin16 as serout to use the onboard programming db9 port right? 
Any help or examples is appreciated!

kegg750

I mean use serin for pin 16 not serout

JonnyMac

July 27, 2010, 09:20:34 PM #5 Last Edit: July 27, 2010, 09:24:01 PM by JonnyMac
It's hard to give an example without know what your VB program is going to send and what it expects.  To get one character from the DB-9 you would do this:

 SERIN 16, Baud, [char]

(or you could use DEBUGIN which is fixed at 9600 baud)

To send one back:

 SEROUT 16, Baud, [char]

(or you could use DEBUG which is fixed at 9600 baud)

Be mindful that the construction of the programming port on the Prop-2 causes every character the PC sends to be echoed back -- you have to filter this on the PC side.

Here's a demo program that just does what it's told.  Pins are converted to letters ("A" - "P"), on is "1", off is "0" -- and must be followed by a carriage return.  I ran this is a Prop-2 using a DEBUG window and it does what it is supposed to do.

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


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


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


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

PC              CON     16                      ' programming port


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

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

Yes             CON     1
No              CON     0

#SELECT $STAMP
 #CASE BS2, BS2E, BS2PE
   T1200       CON     813
   T2400       CON     396
   T4800       CON     188
   T9600       CON     84
   T19K2       CON     32
   T38K4       CON     6
 #CASE BS2SX, BS2P
   T1200       CON     2063
   T2400       CON     1021
   T4800       CON     500
   T9600       CON     240
   T19K2       CON     110
   T38K4       CON     45
 #CASE BS2PX
   T1200       CON     3313
   T2400       CON     1646
   T4800       CON     813
   T9600       CON     396
   T19K2       CON     188
   T38K4       CON     84
#ENDSELECT

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000

Baud            CON     T9600


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

io              VAR     Byte
state           VAR     Byte
term            VAR     Byte


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

Reset:
 OUTH = %00000000 : OUTL = %00000000           ' clear all
 DIRH = %11111111 : DIRL = %11111111           ' set outputs


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

Main:
  SERIN PC, Baud, [io, state, term]             ' wait for packet
  GOSUB UCASE                                   ' make pin uppercase
  ' validate packet
  IF (io >= "A") AND (io <= "P") THEN           ' pin in range?
    IF (state = "0") OR (state = "1") THEN      ' state valid?
      IF (term = CR) THEN                       ' correct terminator?
        OUTS.LOWBIT(io - "A") = state - "0"     ' set pin to state
      ENDIF
    ENDIF
  ENDIF

  GOTO Main


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

UCASE:
 IF (io >= "a") AND (io <= "z") THEN           ' if lowercase
   io = io - $20                               ' convert to upper
 ENDIF
 RETURN


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


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


Jon McPhalen
EFX-TEK Hollywood Office

kegg750

Thank you SO MUCH. This is exactly what i needed to help me understand.  I cant play with this right now but i look forward to tonight.  I have to say, The support this forum offers is amazing.  I havent seen anyone blasted.  Thanks