May 20, 2024, 11:52:36 AM

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.


SX- Controller to DC-16

Started by zpenow, May 06, 2009, 08:26:50 PM

Previous topic - Next topic

zpenow

I have been trying to communicate with my DC-16 board using my SX-Controller. I am using P15 to communicate with the DC-16. I have replaced the ULN28003AG with  a ULN2003A. The pins in the IC socket for P15 are empty. I also have a FC-4  board and successfully communicated with it. Currently I have been testing with only the SX-Controller and the DC-16. I am powering both units from a large 12V battery.  I got a program from the list and chopped out everything except communications with the DC-16, and then added some LEDs to see if anything was happening. I am also using a LED to verify that I have contacted the DC-16. I really suspect I have missed something but I don't know what. Here is the code.
I am running on VISTA using SX-Key Editor v3.2.92h BETA.

Thanks for the help.

John

' =========================================================================
'
'   File...... DemoNight.SXB
'   Purpose... SX/B Programming Template
'   Author.... 
'   E-mail.... 
'   Started...
'   Updated...
'
' =========================================================================


' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------


' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------

DEVICE          SX28, OSCXT2, TURBO, STACKX, OPTIONX, BOR42
FREQ            50_000_000

   
ID              "DN.0"

' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
'

Sio3       PIN    RC.7          ' talk to DC-16 %00-%11



LED0   PIN   RB.0   OUTPUT
LED1   PIN   RB.1   OUTPUT
LED2   PIN   RB.2   OUTPUT
LED3   PIN   RB.3   OUTPUT


' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
BaudMode1        CON     "OT38400"
BaudMode2        CON     "OT2400"

IsOn            CON     1
IsOff           CON     0

' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
tmpB1           VAR     Byte                    ' for subs/funcs
tmpB2           VAR     Byte
tmpB3      VAR   Byte
tmpB4      VAR   Byte
tmpB5      VAR   Byte
cnt      VAR   Byte
addr      VAR   Byte
tmpW1           VAR     Word
ser      VAR   Byte

result      VAR   Byte
idx      VAR   Byte

timing      VAR   Word


' =========================================================================
  PROGRAM Start
' =========================================================================

Pgm_ID:
  DATA  "Demo For Nightmare", 0

' -------------------------------------------------------------------------
' Configuration
' -------------------------------------------------------------------------

' -------------------------------------------------------------------------
' Subroutines / Jump Table
' -------------------------------------------------------------------------

TX_BYTE         SUB     1                       ' transmit a byte
TX_STR          SUB     2                       ' transmit a string
DELAY_MS        SUB     1, 2                    ' delay in milliseconds



' -------- DC-16 --------------------------------------
DC16SetLow      SUB   2      ' Set DC16 lower 8 outputs

'------- FC-4 Channels 1 - 4  -------------------------



' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Reset:
Start:
'  DC16ClearAll %11
'  HIGH Led1
'  LOW Led0
'  LOW Led1
'  LOW Led3
'  DC16SetLow   %11, %11111111
'  LOW Led3
  cnt = 0

Main:


  DC16SetLow %11, %11111111
  FOR idx = 1 TO 10
    'HIGH Led0
    LOW Led1
    LOW Led3
    timing = 50 * 2
    DELAY_MS timing
    HIGH Led1
    HIGH Led3
    'LOW Led0
    timing = 50 * 2
    DELAY_MS timing
  NEXT


  GOTO Main
' -------------------------------------------------------------------------


' DC-16 Subroutines ---------------------------------------------------------



'----------------------------------------------------------------------------
' "L" - Setup "Low" Outputs(OUT1..OUT8)
'----------------------------------------------------------------------------
' Syntax:   "!DC16", address, "L", status
'          - status controls OUT1..OUT8
'          - 1 bit = On, 0 bit = OFF
' Reply:   none


SUB DC16SetLow

  addr  = __PARAM1
  tmpB1 = __PARAM2
  ser   = 3
'  TX_STR  "!DC16"                                ' header
  TX_BYTE "!"
  TX_BYTE "D"
  TX_BYTE "C"
  TX_BYTE "1"
  TX_BYTE "6"
  TX_BYTE %11                               ' address
  TX_BYTE "L"
  TX_BYTE %11111111

  IF cnt = 0 THEN
    cnt = 1
    HIGH Led0
  ELSE
    cnt = 0
    LOW Led0
  ENDIF
 
  ENDSUB





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

' Use: TX_BYTE byteVal
' -- transmit "byteVal" at "BaudMode" on pin "Sio"

SUB TX_BYTE
  SEROUT Sio3, BaudMode1, __PARAM1
ENDSUB

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

' Use: TX_STR [string | label]
' -- "string" is an embedded string constant
' -- "label" is DATA statement label for stored z-String

SUB TX_STR
  tmpW1 = __WPARAM12                            ' get address of string
   DO
    READINC tmpW1, tmpB1                        ' read a character
    IF tmpB1 = 0 THEN EXIT                      ' if 0, string complete
    TX_BYTE tmpB1                               ' send character
  LOOP
  ENDSUB

' Use: DELAY_MS milliseconds

SUB DELAY_MS
  IF __PARAMCNT = 1 THEN
    tmpW1 = __PARAM1
  ELSE
    tmpW1 = __WPARAM12
  ENDIF
  PAUSE tmpW1
  ENDSUB


JonnyMac

Here's a little DC-16 demo that is compatible with SX/B 1.5 and 2.x -- use this as starting point.

' =========================================================================
'
'   File...... DC-16.SXB
'   Purpose... Simple DC-16 Demo
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
' =========================================================================


' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------


' -------------------------------------------------------------------------
' Conditional Compilation Symbols
' -------------------------------------------------------------------------


' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------

ID              "DC-16"

DEVICE          SX28, OSCXT2, TURBO, STACKX, OPTIONX, BOR42
FREQ            20_000_000


' -------------------------------------------------------------------------
' I/O Pins
' -------------------------------------------------------------------------

Sio             PIN     RC.7                    ' P15, SETUP = UP, no ULN


' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------

IsOn            CON     1
IsOff           CON     0

Baud            CON     "OT38400"               ' DC-16 Baud jumper in


' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------

idx             VAR     Byte

tmpB1           VAR     Byte
tmpB2           VAR     Byte
tmpB3           VAR     Byte
tmpB4           VAR     Byte
tmpW1           VAR     Word
tmpW2           VAR     Word


' =========================================================================
' Subroutine / Function / Task Declarations
' =========================================================================

DELAY_MS        SUB     1, 2                    ' shell for PAUSE

TX_BYTE         SUB     1, 1                    ' shell of SEROUT
TX_STR          SUB     2, 2                    ' transmit a string

RX_BYTE         FUNC    1, 0, 0                 ' shell for SERIN

DC16_RESET      SUB     0, 0
DC16_SETPORT    SUB     3, 3


' =========================================================================
  PROGRAM Start
' =========================================================================

Start:
  PLP_A = %0000
  PLP_B = %0000_0000
  PLP_C = %0000_0000

  DELAY_MS 250
  DC16_RESET
  DELAY_MS 5

Main:
  FOR idx = 1 TO 15
    DC16_SETPORT %00, idx, IsOn
    DELAY_MS 50
    DC16_SETPORT %00, idx, IsOff
    DELAY_MS 2
  NEXT
  FOR idx = 16 TO 2 STEP -1
    DC16_SETPORT %00, idx, IsOn
    DELAY_MS 50
    DC16_SETPORT %00, idx, IsOff
    DELAY_MS 2
  NEXT
  GOTO Main


' -------------------------------------------------------------------------
' Subroutine / Function / Task Code
' -------------------------------------------------------------------------

' Use: DELAY_MS ms
' -- delay in milliseconds
' -- shell for PAUSE

SUB DELAY_MS
  msDuration    VAR     __WPARAM12

  \ SB   __PARAMCNT.1                           ' skip if word
  \ CLR  msDuration_MSB                         '  else clear for byte

  PAUSE msDuration
  ENDSUB

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

' Use: TX_BYTE byteVal
' -- transmit "byteVal" at "Baud" on pin "Sio"

SUB TX_BYTE
  SEROUT Sio, Baud, __PARAM1
  ENDSUB

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

' Use: TX_STR [string | Label]
' -- prints embedded string or z-string at Label

SUB TX_STR
  txAddr        VAR     tmpW1                   ' address of string
  txChar        VAR     __PARAM1                ' character from string

  txAddr = __WPARAM12                           ' copy address

  DO
    READINC txAddr, txChar                      ' get a character
    IF txChar = 0 THEN EXIT                     ' if 0, we're done
    TX_BYTE txChar                              ' print the character
  LOOP
  ENDSUB

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

' Use: bResult = RX_BYTE
' -- receive "bResult" at "Baud" on pin "Sio"

FUNC RX_BYTE
  SERIN Sio, Baud, __PARAM1
  ENDFUNC

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

SUB DC16_RESET
  TX_STR  Header
  TX_BYTE $FF                                   ' reset all addresses
  TX_BYTE "X"
  ENDSUB

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

' Use: DC16_SETPORT addr, port, level

SUB DC16_SETPORT
  spAddr        VAR     tmpB1
  pNum          VAR     tmpB2
  pLevel        VAR     tmpB3

  spAddr = __PARAM1                             ' address of board
  pNum = __PARAM2                               ' port #
  pLevel = __PARAM3.0                           ' port level (0 or 1)

  TX_STR  Header
  TX_BYTE spAddr                                ' reset all addresses
  TX_BYTE "P"
  TX_BYTE pNum
  TX_BYTE pLevel
  ENDSUB

' =========================================================================
' User Data
' =========================================================================

Header:
  DATA  "!DC16", 0
Jon McPhalen
EFX-TEK Hollywood Office

zpenow

John,
Last night I tried your program and it compiled without problem. My DC-16 still didn't work and then I remembered to check the address used in the program. If I am reading the program properly the address is 00. I removed both address jumpers from the board and tried again. It still isn't working. I even swaped one of the ULN2803 chips from the SX-Controller with one on the DC-16 still no joy.  The baud rate jumper is shorting the two pins which I believe is correct. I have access to some test equipment if that will help resolve this.

John

JonnyMac

May 08, 2009, 09:55:51 AM #3 Last Edit: May 08, 2009, 09:57:38 AM by JonnyMac
Things on the Prop-SX to check (again):
  1. P15 SETUP jumper is in the UP position
  2. ULN influence has been removed from P15 (swap upper ULN2803 with ULN2003 or clip pin 1 of ULN2803)
  3. Check WRB wire orientation against board markings
  4. If using an SX-Blitz plug a 20MHz resonator into the board (the Blitz does not have a clock generator)

Things to check on the DC-16 (again):
  1. Baud jumper is installed
  2. A0 and A1 jumpers are removed
  3. Check WRB wire orientation against board markings
  4. Set power switch to position 2 so that V+ is powered

Makes sure you select program from the SX-Key IDE; you may need to reset the Prop-SX after the program downloads.

I copied the working program right out of my editor so I'm sure it's something simple -- kind of betting of #4 in the Prop-SX section.
 
Jon McPhalen
EFX-TEK Hollywood Office

zpenow

The check list did the trick and it wasn't number 4.
I had gotten the P15 setup jumper in the wrong position.

Thanks again for all the help.