May 01, 2024, 08:48:28 AM

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.


RS-485 Adapter documentation soon to be available?

Started by tds234, March 11, 2009, 08:17:20 PM

Previous topic - Next topic

tds234

Hi J&J,
I was working on my next order and wanted to consider the RS-485 adapter for networking some nodes in my yard haunt. Is there a pre-release document that I can see? I know that you two are perfectionists (and the quality of your products show that) and have lot's on your plate but I was hoping to verify usage before I purchased them.

Basically I want to set up nodes on a bus and have a master controller ( which may be from another source) sending out addresses and control sequences to slave nodes to coordinate my show. So each node has 'local intelligence' which allows me to program more interesting behaviors at each place while the master node really just coordinates behaviors across nodes. I was hoping to use a shared bus and have nodes watching for their address and then picking up a set number of bytes after that.. nodes will be a mix of Prop-sx and Prop-2's with probably other controllers in use as well.

BTW, I plan to go to St Louis Haunt show I hope you are there....

JonnyMac

March 12, 2009, 01:05:00 AM #1 Last Edit: March 12, 2009, 01:24:09 AM by JonnyMac
It's completely my fault and I'll get it done.  I can post a schematic if that will help you, and I can show you a Prop-SX demo that's been running in my office the last few days.

I call this program DMX-16 because it will send out a DMX-512 type packet -- but only for 16 channels.  I have it running a program that cycles and fades through the colors. 

' =========================================================================
'
'   File...... DMX-16_EZ_Demo.SXB (requires SX/B 2.00.16 or later)
'   Purpose...
'   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... 08 MAR 2009
'
' =========================================================================


' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
'
' Demo program for Chauvet LED-PAR83 COLORsplash Jr.
'
' Channels:
' 1 : Shutter/Strobe/Dimmer
'     -- 000 to 001 = blackout
'     -- 002 to 127 = strobe
'     -- 128 to 255 = color
' 2 : Red
'     -- 000 to 255 (0% to 100%)
' 3 : Green
'     -- 000 to 255 (0% to 100%)
' 4 : Blue
'     -- 000 to 255 (0% to 100%)
'
'
' DMX outputs from RS-485 Interface board:
' DMX+ : Y
' DMX- : Z
' DMXS : G


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


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

ID              "DMX-16ez"

DEVICE          SX28, OSCHS2, BOR42
FREQ            50_000_000


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

RS485           PIN     RB                      ' for DMX/RS-485 board
Aux            PIN     RB.7 INPUT  PULLUP      ' auxilliary input
RX             PIN     RB.6 INPUT  PULLUP      ' serial in
TX             PIN     RB.5 OUTPUT             ' serial out
TxEnable       PIN     RB.4 OUTPUT             ' tx control (0 = off)
Addr8          PIN     RB.3 INPUT              ' bit 8 of address
Clock          PIN     RB.2 OUTPUT             ' to 74x165.2 (CLK)
Din            PIN     RB.1 INPUT              ' to 74x165.9 (QH)
ShLoad         PIN     RB.0 OUTPUT             ' to 74x165.1 (S/LD)


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

Baud            CON     "T250000"               ' for DMX-512

No              CON     0
Yes             CON     1


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

level           VAR     Byte

tmpB1           VAR     Byte                    ' for subs/funcs
tmpB2           VAR     Byte
tmpW1           VAR     Word

dmx             VAR     Byte (16) BANK
ctrl           VAR     dmx(0)                  ' DMX channel 1
red            VAR     dmx(1)
grn            VAR     dmx(2)
blu            VAR     dmx(3)                  ' DMX channel 4


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

DMX_OUT         SUB     0                       ' transmit DMX-16 packet
TX_BYTE         SUB     1                       ' tx one byte

DELAY_MS        SUB     2, 2, Word              ' shell for PAUSE
DELAY_US        SUB     2, 2, Word              ' shell for PAUSEUS


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

Start:
  PLP_A = %0000                                 ' pull-up unused pins
  PLP_C = %0000_0000

  TX = 1                                        ' put TX in idle state
  TxEnable = Yes                                ' required for DMX out
  DELAY_MS 25                                   ' clear for full DMX frame

Main:
  PUT dmx, 255, 255, 000, 000                   ' full red
  DMX_OUT
  DELAY_MS 1000

  PUT dmx, 255, 000, 255, 000                   ' full blue
  DMX_OUT
  DELAY_MS 1000

  PUT dmx, 255, 000, 000, 255                   ' full green
  DMX_OUT
  DELAY_MS 1000

  PUT dmx, 255, 000, 000, 000                   ' all off
  DMX_OUT
  DELAY_MS 1000

  FOR level = 0 TO 255                          ' fade up red
    red = level
    DMX_OUT
    DELAY_MS 10
  NEXT

  FOR level = 0 TO 255                          ' cross-fade, r to g
    red = 255 - level
    grn = level
    DMX_OUT
    DELAY_MS 10
  NEXT

  FOR level = 0 TO 255                          ' cross-fade, g to b
    grn = 255 - level
    blu = level
    DMX_OUT
    DELAY_MS 10
  NEXT

  FOR level = 0 TO 255                          ' fade out blue
    blu = 255 - level
    DMX_OUT
    DELAY_MS 10
  NEXT

  GOTO Main


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

' Use: DMX_OUT
' -- sends 88us break, 8us mark, start byte ($00), 16 DMX channel values
' -- takes about ~844us (0.844ms)

SUB DMX_OUT
  dmxIdx        VAR     tmpB1

  TX = 0                                        ' break
  DELAY_US 88
  TX = 1                                        ' mark
  DELAY_US 8
  TX_BYTE $00                                   ' start byte (not used)
  FOR dmxIdx = 0 TO 15                          ' send channels
    TX_BYTE dmx(dmxIdx)
  NEXT
  ENDSUB

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

' Use: TX_BYTE bVal
' -- adds 4us pad (to give each byte two stop bits per DMX spec)

SUB TX_BYTE
  SEROUT TX, Baud, __PARAM1
  DELAY_US 4                                    ' extra stop bit
  ENDSUB

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

' Use: DELAY_MS duration
' -- duration in milliseconds
' -- shell for PAUSE

SUB DELAY_MS
  msDuration    VAR     __WPARAM12

  PAUSE msDuration
  ENDSUB

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

' Use: DELAY_US duration
' -- duration in microseconds
' -- shell for PAUSEUS

SUB DELAY_US
  usDuration    VAR     __WPARAM12

  PAUSEUS usDuration
  ENDSUB


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


Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

BTW, the hardware is electrically compatible with the Prop-2 but as it can't buffer serial communications your Prop-2 programs would have to be sitting on a SERIN statement when the command(s) arrive.  With the Prop-SX I can show you how to do fully buffered serial comms (I'll give you the code I used in the EZ-8).
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

I just updated the schematic to match the production units -- it's attached.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Jon McPhalen
EFX-TEK Hollywood Office

tds234

That's a lot of good information thanks very much.
I'm basically looking to build a network bus of slave nodes and a master node and was hoping to use this.
If prop-2 is out of the question it's not a problem since I'm really leaning towrd more SX (and other controllers I won't name here),
I may use one of the other controllers as the master and a bunch of slave SX's since they are much better at the other end for props stuff while my master node really just needs to trigger audio and send commands to other slave nodes.
All can talk serial so should be able to use these devices. This looks like my answer so I'll order a couple of these with my next batch of stuff...

Thanks VERY much for the reply.


tds234

Jon,
I'm not sure how busy you are ( that is any busier than normal with all that you do) but I was wondering about some simple example code.

If I had two types of nodes:

One Prop-SX master sender sending 16 bytes periodically (up to 10 a second let's say) onto the network (and it'll be doing some other things but I can probably arrange that.)

Many Prop-sx slaves receiving each packet and pulling out a (different, configurable) specific bytes up to 10 times a second ( and then doing stuff from that which I can probably handle) i.e. they would wait in a loop for the next incoming packet, pick up the specific byte ( or multiple bytes) and then react based upon that.

Is this easy to prototype for the RS-485 adapter?

I think there is enough parts in the codes samples that you mention but this would seem to be a nice set to put in the library for people to use these to create simple master/slave networks for prop control.

What do you think? I would certainly understand if this is too much to tackle right away. If so, I'll order up two of these with SX's and start on it and post the basics if I need help or get it working...


The full program for the master will be reading these values from EEPROM and between watching the time signal from a MP3 player and keeping a real time clock it is going to send the slave commands out on the network at the proper time as each track plays. So a show will be a set or tracks and data files with the output packets to send to the slaves at the appropriate time (as well as some local command to turn on on off lights and such) This master will control multiple mp3 players as well. This part I figured I could do. Sort of vixen built onto an SX if you will.

Doug

JonnyMac

Please make this a new post in the Prop-SX forum -- it differs from the original topic.

On paper this project seems "simple" but is quite sophisticated.  I may not be able to get to it until after TransWorld.   Also, can you live with data bytes that are limited 0 to 127? (MIDI style); if so, that simplifies the protocol.

Don't answer here; repost as a new programming request.
Jon McPhalen
EFX-TEK Hollywood Office