UM0791 User manual. Demonstration firmware for the DMX-512 communication protocol receiver based on the STM32F103Zx. Introduction

Similar documents
AN3332 Application note

AN4014 Application Note Adjustable LED blinking frequency using a potentiometer and STM8SVLDISCOVERY Application overview

STEVAL-ISQ010V1. High-side current-sense amplifier demonstration board based on the TSC102. Features. Description

BD235 BD237. Low voltage NPN power transistors. Features. Applications. Description. Low saturation voltage NPN transistors

EVAL-RHF310V1. EVAL-RHF310V1 evaluation board. Features. Description

D44H8 - D44H11 D45H8 - D45H11

R 1 typ. = 15 kω. Order codes Marking Polarity Package Packaging. 2N6036 2N6036 NPN SOT-32 Tube 2N6039 2N6039 PNP SOT-32 Tube

AN2581 Application note

AN2979 Application note

Order codes Marking Polarity Package Packaging. MJD44H11T4 MJD44H11 NPN DPAK Tape and reel MJD45H11T4 MJD45H11 PNP DPAK Tape and reel

BD533 BD535 BD537 BD534 BD536

R 1 typ. = 15 kω. Order codes Marking Polarity Package Packaging. STX112-AP X112 NPN TO92-AP Ammopack STX117-AP X117 PNP TO92-AP Ammopack

STEVAL-CCA040V1. 4X10 Watt dual/quad power amplifier demonstration board based on the STA540SAN. Features. Description

BUX87. High voltage NPN power transistor. Features. Applications. Description

AN2333 Application note

MJE182 Low voltage high speed switching NPN transistor Features Applications Description High speed switching NPN device

AN279 Application note

ST26025A. PNP power Darlington transistor. Features. Applications. Description

2STD1665. Low voltage fast-switching NPN power transistor. Features. Applications. Description

STEVAL-ISA005V1. 1.8W buck topology power supply evaluation board with VIPer12AS. Features. Description. ST Components

BD241A BD241C. NPN power transistors. Features. Applications. Description. NPN transistors. Audio, general purpose switching and amplifier transistors

Obsolete Product(s) - Obsolete Product(s)

STEVAL-CCA011V1. Filter-free stereo 2x2.5 W Class-D audio power amplifier demonstration board based on the TS2012FC. Features.

Obsolete Product(s) - Obsolete Product(s)

Order codes Marking Package Packaging. STX0560 X0560 TO-92 Bag STX0560-AP X0560 TO-92AP Ammopack. December 2010 Doc ID Rev 1 1/9

STN9260. High voltage fast-switching PNP power transistor. Features. Applications. Description. High voltage capability Fast switching speed

2STA1695. High power PNP epitaxial planar bipolar transistor. Features. Applications. Description

SPV1001T40. Cool bypass switch for photovoltaic application. Features. Application. Description TO-220

BD243C BD244C. Complementary power transistors. Features. Applications. Description. Complementary NPN-PNP devices. Power linear and switching TO-220

AN1756 Application note

3STL2540. Low voltage high performance PNP power transistor. Features. Applications. Description

STD840DN40. Dual NPN high voltage transistors in a single package. Features. Applications. Description

TIP2955 TIP3055. Complementary power transistors. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

KF25B, KF33B KF50B, KF80B

2STC4468. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

AN1441 Application note

ST13003D-K High voltage fast-switching NPN power transistor Features Applications Description

STN High voltage fast-switching PNP power transistor. Features. Application. Description. High voltage capability Very high switching speed

STB High voltage fast-switching NPN power transistor. Features. Applications. Description

MD2009DFX. High voltage NPN power transistor for CRT TV. Features. Application. Description

ESDALCL6-4P6A. Multi-line low capacitance and low leakage current ESD protection. Features. Applications. Description

2STR SOT-23 Tape and reel 2STR1230G 130G SOT-23 Tape and reel

Part numbers Order codes Packages Temperature range. LM137 LM137K TO-3-55 C to 150 C LM337 LM337K TO-3 0 C to 125 C LM337 LM337SP TO C to 125 C

Obsolete Product(s) - Obsolete Product(s)

TR136. High voltage fast-switching NPN power transistor. Features. Applications. Description

LET9060C. RF power transistor from the LdmoST family of n-channel enhancement-mode lateral MOSFETs. Features. Description

LM323. Three-terminal 3 A adjustable voltage regulators. Features. Description

AN3134 Application note

BUL38D. High voltage fast-switching NPN power transistor. Features. Applications. Description

MD2310FX. High voltage NPN power transistor for standard definition CRT display. Features. Application. Description

BUL743. High voltage fast-switching NPN power transistor. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

AN2837 Application note

BDX53B - BDX53C BDX54B - BDX54C

2STC4468. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

ETP01-xx21 Protection for Ethernet lines Features Description Applications Benefits Complies with the following standards

Obsolete Product(s) - Obsolete Product(s)

2STR2215. Low voltage fast-switching PNP power transistor. Features. Applications. Description

AN3116 Application note

2N2219AHR. Hi-Rel NPN bipolar transistor 40 V A. Features. Description

STD1802T4-A. Low voltage fast-switching NPN power transistor. Features. Description. Applications

MJD122 MJD127 Complementary power Darlington transistors Features Applications Description

BUL39D. High voltage fast-switching NPN power transistor. Features. Application. Description

2STD1360 2STF1360-2STN1360

STN9360. High voltage fast-switching PNP power transistor. Features. Applications. Description. High voltage capability Fast switching speed

1. Drain 2. Gate. Order code Marking Package Packaging. STAC4932F STAC4932F STAC244F Plastic tray. September 2010 Doc ID Rev 3 1/12

Overview of the STM32F103xx ACIM and PMSM motor control software libraries release 2.0

Low noise low drop voltage regulator with shutdown function. Part numbers

STX13005G-AP. High voltage fast-switching NPN power transistor. Features. Applications. Description

2STA1943. High power PNP epitaxial planar bipolar transistor. Features. Application. Description

AN3359 Application note 1 Introduction Low cost PCB antenna for 2.4GHz radio: Meander design

2ST2121. High power PNP epitaxial planar bipolar transistor. Features. Applications. Description 1 2 TO-3

STPS140Z-Y. Automotive power Schottky rectifier. Features. Description

LS1240. Electronic two-tone ringer. Features. Description. Pin connection (top view)

STPS3045FP. Power Schottky rectifier. Features. Description

STN2580. High voltage fast switching NPN power transistor. Features. Applications. Description. High voltage capability Fast switching speed

Part numbers Order codes Description Packages

L4940xx5 L4940V5 L4940D2T5-TR 5 V L4940xx85 L4940V85 L4940P85 L4940D2T85-TR 8.5 V L4940xx10 L4940D2T10-TR 10 V L4940xx12 L4940D2T12-TR 12 V

Order codes Marking Package Packaging 2STF SOT-89 2STN2550 N2550 SOT-223. November 2008 Rev 1 1/8

Obsolete Product(s) - Obsolete Product(s) Obsolete Product(s) - Obsolete Product(s)

AN4112 Application note

Order codes Marking Package Packaging

LM723CN. High precision voltage regulator. Features. Description

UM0890 User manual. 2-stage RF power amplifier with LPF based on the PD85006L-E and STAP85050 RF power transistors. Introduction

ST1510FX. High voltage fast-switching NPN Power transistor. General features. Applications. Internal schematic diagram. Description.

STL128D. High voltage fast-switching NPN power transistor. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

Obsolete Product(s) - Obsolete Product(s)

AN4233 Application note

Order codes Marking Package Packaging. STD2805T4 D2805 DPAK Tape & reel STD D2805 IPAK Tube. June 2007 Rev 1 1/9

2STC5242. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

STC04IE170HV. Monolithic emitter switched bipolar transistor ESBT 1700 V - 4 A Ω. Features. Application. Description

CPL-WB-02D3. Wide-band, directional coupler with integrated 50 ohm loaded isolated port. Features. Applications. Description.

AN440 Application note

BTA10-600GP. 10 A Triac. Features. Description

Order code Temperature range Package Packaging Marking

ESDARF03-1BF3. Ultralow capacitance ESD protection for antenna. Features. Applications. Description. Benefits. Complies with the following standards

STPSC V power Schottky silicon carbide diode. Features. Description

Part Number Marking Package Packing. MD1802FX MD1802FX ISOWATT218FX Tube. August 2006 Rev 1 1/8

Transcription:

User manual Demonstration firmware for the DMX-512 communication protocol receiver based on the STM32F103Zx Introduction This document describes how to use the demonstration firmware for the DMX-512 communication protocol receiver. The USART (universal synchronous asynchronous receiver transmitter) module of the STM32F103Zx (ARM 32-bit Cortex -M3) microcontroller unit receives the data from the DMX-512 controller via an RS-485 transceiver. This receiver is compatible with the latest DMX-512 protocol, and can also be used with any DMX-512 controller having a NULL start code. This document provides: an overview of the complete solution. a description and flowcharts of the STM32 demonstration firmware. schematics and layouts. March 2010 Doc ID 16257 Rev 2 1/21 www.st.com

Contents UM0791 Contents 1 DMX-512 receiver format..................................... 4 1.1 Packet format............................................... 4 1.2 Timing values for DMX-512-A receiver............................ 5 2 DMX-512 receiver........................................... 6 2.1 System overview............................................ 6 2.2 DMX-512 receiver block diagram................................ 7 2.3 RS-485 transceiver........................................... 7 2.4 MCU block diagram.......................................... 9 3 Demonstration firmware..................................... 10 3.1 dmx_init.c file description..................................... 10 3.1.1 Timer2_Initialise........................................... 10 3.1.2 USART1_Intialise.......................................... 10 3.1.3 Timer3_PWM............................................. 10 3.1.4 PWM_Update............................................ 10 3.2 main.c file description........................................ 11 3.2.1 RCC_Configuration........................................ 11 3.2.2 NVIC_Configuration........................................ 11 3.2.3 GPIO_Configuration....................................... 11 3.3 Timer2 interrupt routine...................................... 11 3.4 USART1 interrupt routine..................................... 11 4 Firmware architecture overview............................... 12 5 Firmware flowcharts........................................ 13 5.1 Main routine............................................... 13 5.2 Timer2 interrupt routine...................................... 14 5.2.1 Channel 2 rising edge interrupt routine......................... 14 5.2.2 Channel 1 falling edge interrupt routine......................... 15 5.3 USART1 interrupt routine..................................... 16 6 Key features/specifications.................................. 17 2/21 Doc ID 16257 Rev 2

Contents 7 Schematic and layout....................................... 18 8 Revision history........................................... 19 Doc ID 16257 Rev 2 3/21

List of figures UM0791 List of figures Figure 1. Timing diagram for DMX-512 packet.......................................... 5 Figure 2. Typical DMX-512 receiver system............................................ 7 Figure 3. Typical DMX-512 receiver circuit............................................. 7 Figure 4. Block diagram of single DMX-512 receiver...................................... 8 Figure 5. Front view of RS-485 transceiver board........................................ 9 Figure 6. J1 pin diagram........................................................... 9 Figure 7. J2 pin diagram........................................................... 9 Figure 8. MCU block diagram...................................................... 10 Figure 9. Demonstration firmware architecture overview.................................. 13 Figure 10. Main routine flow chart.................................................... 14 Figure 11. Timer2 rising edge interrupt flow chart........................................ 15 Figure 12. Timer2 falling edge interrupt flow chart........................................ 16 Figure 13. USART1 interrupt flow chart................................................ 17 Figure 14. Schematic of RS-485 transceiver board....................................... 19 Figure 15. Layout of RS-485 transceiver board.......................................... 19 4/21 Doc ID 16257 Rev 2

DMX-512 receiver format 1 DMX-512 receiver format 1.1 Packet format The DMX-512 slots are transmitted sequentially in an asynchronous serial format, beginning with slot 0 and ending with the last implemented slot, up to slot 512 (a maximum total of 513 slots). Before the first data slot is transmitted, a reset sequence is transmitted, consisting of a BREAK, a MARK AFTER BREAK and a START code. Valid DMX-512 data slot values under a NULL START code range from 0 to 255 decimal. Figure 1. Timing diagram for DMX-512 packet The following points refer to the numbers shown in Figure 1. 1. SPACE for BREAK 2. MARK AFTER BREAK 3. Slot time 4. START time 5. LEAST SIGNIFICANT data bit 6. MOST SIGNIFICANT data bit 7. STOP bit 8. STOP bit 9. MARK TIME BETWEEN SLOTS 10. MARK BEFORE BREAK 11. BREAK to BREAK time 12. RESET sequence 13. DMX-512 packet 14. START CODE (slot 0, data) 15. SLOT 1, data 16. SLOT n, data (max 512) Doc ID 16257 Rev 2 5/21

DMX-512 receiver format UM0791 1.2 Timing values for DMX-512-A receiver The receiver only accepts the data if all the timing values comply with those given in Table 1. Table 1. Timing values of DMX-512 packet received Description Min Typical Max Unit Bit rate 245 250 255 Kbps Bit time 3.92 4 4.08 µs Minimum update time for 513 slots - 22.7 - ms Maximum refresh rate for 513 slots - 44 - µs "SPACE" for BRAEK 88 176 - µs "MARK" after BREAK (MAB) 8 - <1.00 "MARK" time between slots 0 - <1.00 s "MARK" before BREAK (MBB) 0 - <1.00 s BREAK to BREAK time 1196-1.25 DMX-512 packet 1196-1.25 µs s µs s µs s 6/21 Doc ID 16257 Rev 2

DMX-512 receiver 2 DMX-512 receiver 2.1 System overview Figure 2 represents a typical DMX-512 system. 1. The multiple receivers are connected to the DMX host in a daisy-chain manner and every packet goes through every receiver in its entirety. 2. Each receiver receives the differential signal through an RS-485 transceiver and gives it to the controller on the receiving side. 3. Each receiver is programmed with a specific slot address so that it knows which slot it has to extract from each packet. Figure 2. Typical DMX-512 receiver system 4. There should be only one terminating resistance with a set of receivers and that terminating resistance should be connected with the receiver farthest from the transmitter/controller. Figure 3. Typical DMX-512 receiver circuit Doc ID 16257 Rev 2 7/21

DMX-512 receiver UM0791 2.2 DMX-512 receiver block diagram Figure 4 shows the block diagram of the single DMX-512 receiver. The signals are first received by the RS-485 transceiver. The STM32F103Zx microcontroller receives the packet through the USART_RX pin according to the address programmed. The receiver then extracts a particular slot from the packet and modifies the duty cycle of the PWM output as per the data received. Figure 4. Block diagram of single DMX-512 receiver 2.3 RS-485 transceiver Figure 5 on page 9 depicts the front view of the RS-485 transceiver board. The jumpers on the RS-485 transceiver board should be set as shown below to receive the DMX differential signal from the transmitter and transmit the signal to the microcontroller. Jumper J3 on pin 2 and pin 3 Jumper J4 on pin 2 and pin 3 8/21 Doc ID 16257 Rev 2

DMX-512 receiver Figure 5. Front view of RS-485 transceiver board Figure 6 and Figure 7 show the connections of J1 and J2 on the RS-485 transceiver board. Figure 6. J1 pin diagram DMX+ and DMX- are the differential signals from the DMX-512 transmitter. NC means not connected. Figure 7. J2 pin diagram RS485_RX is the signal given to the STM32F103Zx. NC means not connected. Doc ID 16257 Rev 2 9/21

DMX-512 receiver UM0791 2.4 MCU block diagram Figure 8 shows the connections to the STM3210E-EVAL board. Figure 8. MCU block diagram The RS485_RX signal is transmitted to three GPIO pins, PA0, PA1 and PA10. The PWM output is generated on pin PA6. PA0 is configured as channel1 of timer2. The falling edge input capture is configured on this channel. PA1 is configured as channel2 of timer2. The rising edge input capture is configured on this channel. PA10 is configured as the Rx pin of USART1. A PWM of 120 Hz is produced on channel1 of timer3. The duty cycle of the PWM varies according to the data received. 10/21 Doc ID 16257 Rev 2

Demonstration firmware 3 Demonstration firmware This chapter describes the software developed for the DMX-512 receiver. The differential signals are first received by the RS-485 transceiver. After the retransmission of the signals from the RS-485 transceiver, the valid RESET sequence ( BREAK and MARK after BREAK ) and the DMX-512 packet time are detected to process the received data. A particular data slot is selected from the packet received according to the address programmed, and the duty cycle of the PWM is varied, such that 255 signifies a 100% duty cycle and 0 signifies a 0% duty cycle. The software is described as it appears in each of the files, starting with the DMX initialization file followed by the main file and then the interrupt file. The software is developed using IAR EWARM5.3. The project uses the STM32 firmware library version 3.0.0. The demonstration firmware consists of four main parts. A dmx_init.c file for configuring all the peripherals used in this application. A main routine, including PWM control, based on the data received. A Timer2 interrupt routine. A USART1 interrupt routine. 3.1 dmx_init.c file description The dmx_init file is used for configuring various peripherals used in the application. Each function is described hereafter. 3.1.1 Timer2_Initialise This function configures channel 1 in rising edge polarity and channel 2 in falling edge polarity of TIMER2 in input capture mode. 3.1.2 USART1_Intialise This function configures USART1 in receiver mode with a baud rate of 250 kbps. 3.1.3 Timer3_PWM The TIM3 clock runs at 120 Hz. TIM3 is set-up to work in PWM1 mode. 3.1.4 PWM_Update This function updates the duty cycle of the PWM according to the data received. Doc ID 16257 Rev 2 11/21

Demonstration firmware UM0791 3.2 main.c file description The main.c file contains all the data required to initialize the peripherals used for this application. After receiving a valid packet according to the DMX-512 2008 standard, a particular data slot is retrieved according to the address programmed, and the duty cycle of the PWM is updated, shown by a change in the intensity of the LEDs. The following sections describe each of the functions defined in the main.c file. 3.2.1 RCC_Configuration This function enables the high-speed external crystal, including the PLL. It also configures various system clocks. 3.2.2 NVIC_Configuration This function sets up the interrupts used in the STM32F103Zx. 3.2.3 GPIO_Configuration This function sets up various IO ports used for the application. 3.3 Timer2 interrupt routine In the timer2 interrupt subroutine, the RESET Sequence and DMX-512 packet time are detected and checked to see whether they are within the limits of the DMX-512 2008 standard. If the RESET Sequence is not valid, the timer2 interrupt routine waits for a valid RESET Sequence. If the DMX-512 packet time is above the limits, the entire packet is discarded. 3.4 USART1 interrupt routine This routine handles frame errors and data storage. Initially, when a frame error is detected it is treated like the RESET Sequence. Once the RESET Sequence has been validated (confirmed in the timer2 interrupt routine), this routine starts receiving data slots and stores them in a buffer when the USART receive interrupt is enabled. If a frame error occurs in between data slots, no additional data is stored. 12/21 Doc ID 16257 Rev 2

Firmware architecture overview 4 Firmware architecture overview Figure 9 illustrates the architecture of the demonstration firmware. Figure 9. Demonstration firmware architecture overview Doc ID 16257 Rev 2 13/21

Firmware flowcharts UM0791 5 Firmware flowcharts 5.1 Main routine Figure 10. Main routine flow chart 14/21 Doc ID 16257 Rev 2

Firmware flowcharts 5.2 Timer2 interrupt routine 5.2.1 Channel 2 rising edge interrupt routine Figure 11. Timer2 rising edge interrupt flow chart Doc ID 16257 Rev 2 15/21

Firmware flowcharts UM0791 5.2.2 Channel 1 falling edge interrupt routine Figure 12. Timer2 falling edge interrupt flow chart 16/21 Doc ID 16257 Rev 2

Firmware flowcharts 5.3 USART1 interrupt routine Figure 13. USART1 interrupt flow chart Doc ID 16257 Rev 2 17/21

Key features/specifications UM0791 6 Key features/specifications The developed solution: receives data according to the DMX-512 2008 standard. is used with any DMX-512 transmitter irrespective of the number of bytes transmitted by the transmitter. 18/21 Doc ID 16257 Rev 2

Schematic and layout 7 Schematic and layout Figure 14. Schematic of RS-485 transceiver board Figure 15. Layout of RS-485 transceiver board Doc ID 16257 Rev 2 19/21

Revision history UM0791 8 Revision history Table 2. Document revision history Date Revision Changes 02-Feb-2010 1 Initial release. 17-Mar-2010 2 Changed document title from DMX-512 communications protocol algorithm for receiver, based on the STM3210E-EVAL to Demonstration firmware for the DMX-512 communication protocol receiver based on the STM32F103Zx. Replaced some references to the STM32 device with STM32F103Zx throughout the document. Corrected board part number in Section 2.4: MCU block diagram and Figure 8 on page 10. Minor text changes throughout the document. 20/21 Doc ID 16257 Rev 2

Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. 2010 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com Doc ID 16257 Rev 2 21/21