May 18, 2024, 11:08:09 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.


Strange DC-16 Behavior

Started by neon_kenny, July 05, 2009, 10:24:06 AM

Previous topic - Next topic

neon_kenny

July 05, 2009, 10:24:06 AM Last Edit: July 05, 2009, 03:35:55 PM by neon_kenny
I must be missing something. I have an LED with proper resistor and polarity connected to each of outputs 1 thru 8 on the DC-16. In the following code if I comment out all but one of the DATA directives  (bs2), I get unexpected behavior on Output 6. It works in two instances. But if I switch the bits, it either does not fire or fires with the wrong timing depending on how I arrange the bits - even though the bits are essentially the same. I commented which DATA statements work and which do not.

Am I missing something too obvious?

' =========================================================================
'
'   File...... Basic_test.BS2
'   Author.... Kenny Greenberg
'   E-mail.... kenny@neonshop.com
'   Purpose...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================

idx VAR Byte 'loop control
tb VAR Word  'timing
lfoo VAR Byte 'lower byte for DC-16

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

idx=0
tb=250

DATA %00000110, %00000110, %11111001, %11111001  'works
'DATA %01100000, %01100000, %10011111, %10011111   'works
'DATA %01101111, %01101111, %10010000, %10010000   'does not work
'Out6 (bit5) does not fire

'DATA %00000110, %11110110, %00001001, %11111001  'works
'DATA %01100000, %01101111, %10010000, %10011111   'does not work
'Out6 (bit5) fires but turns off too soon

'DATA %01101111, %01100000, %10011111, %10010000   'does not work
'Out6 (bit5) is delayed

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

Main:
      READ idx, lfoo
      SEROUT 7, 6, ["!DC16", 3, "L", lfoo]
      PAUSE tb

      idx =idx + 1
      IF idx=4 THEN ReStart
      GOTO Main

Restart:
idx=0

GOTO Main

JonnyMac

If you have an older version of the DC-16 there is a firmware glitch that can cause this; run the DC-16 test program and let me know the revision of the firmware.  This glitch -- which almost never cropped up but is inconvenient when it does -- has been corrected in the 2.0 firmware.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Here's a subroutine that I wrote for Disneyland (they use a lot of our control products around the park) -- this takes care of that BIT5 issue with older DC-16s.  Note that it expects a work (in dc16) but can easily be modified to deal with a byte.

' Sends 16-bit value in "dc16" to board at address 0 that is connected
' to "sioPin"
'
' Routine takes approximately 8 milliseconds at 38.4K baud

DC16_OUT:
  SEROUT sioPin, Baud, ["!DC16", 0, "S", dc16.BYTE0, dc16.BYTE1]

  ' *Fix* output when byte falls between "a" (%01100001) and "z" (%01111010)

  SEROUT sioPin, Baud, ["!DC16", 0, "P",  6, dc16.BIT5]
  SEROUT sioPin, Baud, ["!DC16", 0, "P", 14, dc16.BIT13]
  RETURN
Jon McPhalen
EFX-TEK Hollywood Office

neon_kenny

Thanks.  I'll check the version but I assume its the old as I bought several boards very early on. I may be able to work around this and/or I may just update some of my boards. I'm glad I'm not losing my wits - at least not in this case.

JonnyMac

Here's an update of your program -- give it a try.

' =========================================================================
'
'   File...... Basic_Test.BS2
'   Author.... Kenny Greenberg
'   E-mail.... kenny@neonshop.com
'   Purpose...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15


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

#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     T38K4


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

idx             VAR     Byte
patBits         VAR     Byte


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

Reset:


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

Main:
  FOR idx = 0 TO 3
    READ Pattern1 + idx, patBits
    GOSUB DC16_OUTL
    PAUSE 250
  NEXT
  GOTO Main


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

DC16_OUTL:
  SEROUT Sio, Baud, ["!DC16", %11, "L", patBits]
  SEROUT Sio, Baud, ["!DC16", %11, "P", 6, patBits.BIT5]
  RETURN

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

Pattern1        DATA    %00000110, %00000110, %11111001, %11111001
Pattern2        DATA    %01100000, %01100000, %10011111, %10011111
Pattern3        DATA    %01101111, %01101111, %10010000, %10010000
Pattern4        DATA    %00000110, %11110110, %00001001, %11111001
Pattern5        DATA    %01100000, %01101111, %10010000, %10011111
Pattern6        DATA    %01101111, %01100000, %10011111, %10010000
Jon McPhalen
EFX-TEK Hollywood Office

neon_kenny

Thanks. Yes your update of the program works. FYI, my DC-16 version is 1.2.

JonnyMac

That was the first production release. 
Jon McPhalen
EFX-TEK Hollywood Office