May 03, 2024, 05:08:11 PM

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.


Prop-1 Single Channel "Bit-Banger"

Started by JonnyMac, April 11, 2009, 12:10:33 PM

Previous topic - Next topic

JonnyMac

April 11, 2009, 12:10:33 PM Last Edit: April 11, 2009, 12:15:17 PM by JonnyMac
Back in the early days of EFX-TEK I wrote this program for a [now out of business] prop company who could not get "bit-banger" controllers from their normal source.  This is tricky code, and I'm sharing it to show you than turning a Prop-1 or Prop-2 into a bit-banger is 1) difficult at best, and 2) not really worth doing -- which is why we built the EZ-8 and priced it well below anything comparable on the market.

Since this program has just one output (jaw cylinder) I use a compression strategy to get eight frames per every byte available in the very small EEPROM space.

' =========================================================================
'
'   File...... Greeter.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 26 JUL 2006
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Greeter connections:
'
' P7 SETUP jumper = DN
' P6 SETUP jumper = DN
'
'     SETUP
'    * [*--*] P7
'    * [*--*] P6
'    UP   DN
'
'
' "New Show" (red) and "Trigger" (green) buttons use N.O. connections on
' the microswitches.
'
' New Show --> connect button between P7.W and P7.R
' Trigger  --> connect button between P6.W and P6.R
'
' Connect P5 header with servo extender wire to AP-8 serial header -- be very
' careful to note polarity of cable on both ends (look for W-R-B markings).
' Pin 3 (3rd down on left side) of ULN should be removed to prevent ULN2803
' from false triggering the AP8.
'
' Jaw solenoid is connected between V+ (common) and OUT0 (control)


' -----[ Revision History ]------------------------------------------------
'
' 24 JUL 2006 - Modified to use Normally Open switched
' 26 JUL 2006 - Modified for active-high inputs


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

SYMBOL  NewShow         = PIN7                  ' used to record new show
SYMBOL  Trigger         = PIN6                  ' animate recording / play
SYMBOL  Sio             = 5                     ' starts AP-8 (mod ULN!)
SYMBOL  Unused4         = PIN4
SYMBOL  Unused3         = PIN3
SYMBOL  Unused2         = PIN2
SYMBOL  Unused1         = PIN1
SYMBOL  Cylinder        = PIN0                  ' output control


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

' DON'T change these values!

SYMBOL  Yes             = 1                     ' for active-high inputs
SYMBOL  No              = 0

SYMBOL  IsUp            = 1                     ' cylinder extended
SYMBOL  IsDown          = 0                     ' cylinder retracted


' these values may be modified

SYMBOL  StepTime        = 62                    ' 62 ms sec step timing
SYMBOL  OffDelay        = 20000                 ' 20 secs rest


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

SYMBOL  playBits        = B0                    ' steps group
SYMBOL   outStep        =  BIT7                 ' cylinder output bit
SYMBOL   inStep         =  BIT0                 ' recorded input bit

SYMBOL  showLimit       = B2                    ' end of show memory
SYMBOL  showLen         = B3                    ' length of recorded show
SYMBOL  stpPntr         = B4                    ' pointer to steps group
SYMBOL  idx             = B5                    ' loop index

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

Reset:
  PINS = %00100000                              ' preset pins
  DIRS = %00000001                              ' make Cylinder an output
  READ 255, showLimit                           ' read memory limit
  showLimit = showLimit - 1                     ' reduced for safety


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

Main:
  Cylinder = IsDown                             ' down when not running
  IF Trigger = Yes THEN Play                    ' check play button
  IF NewShow = Yes THEN Record                  ' check record button
  GOTO Main                                     ' keep checking


' +-----------------------+
' | Play show from memory |
' +-----------------------+

Play:
  GOSUB Start_AP8                               ' start the audio
  READ 0, showLen                               ' read steps in show
  stpPntr = 1                                   ' initialize steps pointer

Play_Next:
  READ stpPntr, playBits                        ' get set of steps from EE
  FOR idx = 1 TO 8                              ' decompress eight steps
    Cylinder = outStep                          ' put step on output
    PAUSE StepTime                              ' wait
    playBits = playBits * 2                     ' get next step
  NEXT
  stpPntr = stpPntr + 1                         ' point to next group
  showLen = showLen - 1                         ' update show position
  IF showLen > 0 THEN Play_Next                 ' steps left?
    PAUSE OffDelay                              '   insert dwell time
    GOTO Main                                   '   go back to top


' +-----------------+
' | Record new show |
' +-----------------+

Record:
  GOSUB Start_AP8                               ' start the audio
  stpPntr = 0                                   ' reset steps pointer

Record_Next:
  stpPntr = stpPntr + 1                         ' update steps pointer
  FOR idx = 1 TO 8                              ' compress eight steps
    playBits = playBits * 2                     ' prep for step bit
    inStep = Trigger                            ' grab trigger input
    Cylinder = inStep                           ' copy to cyliner output
    PAUSE StepTime                              ' wait
  NEXT
  WRITE stpPntr, playBits                       ' write group to memory
  IF stpPntr = showLimit THEN Stop_Recording    ' out of memory?
    IF NewShow = Yes THEN Record_Next           ' still recording?

Stop_Recording:
  IF NewShow = Yes THEN Stop_Recording          ' force button release
    WRITE 0, stpPntr                            '   save length of show
    GOTO Main                                   '   go back to top


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

Start_AP8:
  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)
  RETURN


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

Show_Len:
  EEPROM (04)                                   ' number of bytes


' Show data is read left-to-right, top-to-bottom; a "1" bit means the
' control output is on, a "0" bit means the control output is off.  Each
' bit is ~62 milliseconds (0.062 seconds) in duration; each group of
' eight (byte) is ~1/2 second; each line in table is ~2 seconds.

Show_Data:
  EEPROM (%00001111, %00001111, %11111111, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)
  EEPROM (%00000000, %00000000, %00000000, %00000000)

  ' max length of show (1 minute)
Jon McPhalen
EFX-TEK Hollywood Office

EricTheMannn

With this bit banger code, is it possible for it to be modified to allow vixen to send I/O's from the serial port to the  trigger (pin6) input, to change the program in real time? using the prop-1 as a slave.

I will be testing this bit banger code later today with my other prop-1 kit.

I may attempt a concept this weekend.

-Eric



WooHoo

JonnyMac

The Prop-1 programming port does not work for serial communications; you need to use one of the I/O pins.  And adding serial port would cut into the already very small memory map.  I did the program as an exercise who couldn't get "bit-bangers" from a company very famous for them.  No worries, now, as we have the EZ-8.
Jon McPhalen
EFX-TEK Hollywood Office

EricTheMannn

May 15, 2009, 04:25:29 PM #3 Last Edit: May 15, 2009, 04:33:08 PM by EricTheMannn
Yeah, very soon i will get the EZ-8, its a necessary controller for one of the prop's i designed for this year. The idea is only intended as a small test project, while i wait for the rest of the pieces and parts to come in for my complete death chamber prop makeover. Which is a completely new design, I'll post the finished prop in about 3 to 4 weeks depending on how motivated i am. 

Thank you for you're response Jon, I cannot wait to get the EZ-8 controller.

-Eric
WooHoo