Nai 's depot

Tuesday, July 7, 2015

Thursday, June 5, 2014

C-programming AVR-Timer

XMEGA-A1 XPLAINED

Use the code shown to figure out the Peripheral Clock that drives the timer if it's not obvious or you don't want to read the manual.

The peripheral clock on the XMEGA-A1-XPLAINED can be driven by 5 different clock sources and it can be scaled 3 times before it gets to the timer module.

By default the clock = 2 MHz and all prescaler are set to 1.


To set the desired time:
            1) change the 16 bit timer period (TCC0.PER),
            2) change the clock scaling (TC_CLKSEL_DIVx_gc)


















RS485 Tranceiver

RS485 Module
Cheap RS485 module can be bought on ebay for about $1.  It uses a MAX485 IC that is rated for 15KV ESD protection and that has all the required termination.  It does not hurt to add more protection to the RS485 lines.  VCC=5V

RS485 Tranceiver


Wednesday, May 21, 2014

uC based DMX Transmitter

Simple Lighting Set


DATA FRAME

Each DMX512 transmitter sends 512 packets of 8-bit dimming values, between 0 and 255, where 0 represents the lights off and 255 represents the maximum intensity. The DMX512 protocol requires the transmitter to continuously repeat (at least once a second) the transmission of a frame as shown in the timing diagram in Figure1 and Table2.



STATE MACHINE
State1: SENDMBB - DMX Idle (Mark Before Break)
State2: SENDDATA - Send 512 bytes
State3: SENDMAB - DMX Idle (Mark After Break)
State4: SENDBREAK - Send Break







    
























DMX512



DMX 512 is used to control intelligent lights in professional stage lighting.  It is an asynchronous serial communication and is based on the EIA/TIA-485 (aka RS-485).  RS-485 specifications allow only one driver to send data at a time, and up to 32 unit loads (12-kΩ load x 32=375Ω) can be placed on the bus.  Maximum distance is 1500 ft using a twisted-shielded cable (e.g. microphone cable) and two terminators, consisting of 120 Ω, 1/2W resistors.  As a rule of thumb, the data signaling rate (in bps) multiplied by the cable length (in meters) should not exceed 10^8.  For example, a system with a cable measuring 500 m should not transmit data at speeds greater than 200 kbps (10^8/500).

DMX 512 can use good quality microphone cables.  The 3-pin XLR connector wiring is shown below: 
DMX512 Connector: pin1=shield, pin2=Data-, pin3=Data+
 DMX 512 data is transmitted at 250 kiloHertz (kHz).  A single transmission (DMX Packet) includes synchronizing elements and channel data for up to 512 channels (1 universe).  RS-485 uses a daisy chain connectivity scheme and requires termination at both ends of the cable.

DMX512 Protocol