cancel
Showing results for 
Search instead for 
Did you mean: 

dmx512 transmitter

mahmoud boroumand
Associate III
Posted on July 24, 2017 at 13:22

Hello 

I useing stm32f103c8(72mhz) and i want create DMX512 transmitter for  led lighing.

I have some problem.I config usart like this.

USART_InitStructure.USART_BaudRate = 250000;

USART_InitStructure.USART_WordLength = USART_WordLength_8b;

USART_InitStructure.USART_StopBits = USART_StopBits_2;

USART_InitStructure.USART_Parity = USART_Parity_No;

USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

USART_InitStructure.USART_Mode = USART_Mode_Tx;

USART_Init(USART2, &USART_InitStructure);

when i make reset sequence and data with this code.

_delayus(20);///MarkBeforeBreak

USART_SendBreak(USART2);//Break

_delayus

(12);//MarkAfterBreak;

USART_SendData(USART2,0);///start code

for(int i=0;i<512;i++)

{  

USART_SendData(USART2,255);//R

USART_SendData(USART2,255);//G

USART_SendData(USART2,255);//B

_delayus

(12);//MTBP

}

I have some problem with this code.

1-Break time is 44us but dmx need 92us at least how can solve this problem?

2-Is structure right for dmx led light?

Thanks

5 REPLIES 5
Posted on July 24, 2017 at 14:30

Hi!!

for the first part:

by sending more (at least 3) consecutive breaks. Is it permited from protocol?

Posted on July 24, 2017 at 15:24

Hi again

for the second part. .

I am nnot familiar with this protocol but you have some UART issues

Before you send a character or every character by USART_SendData(USARTX,y);

must check before if DR txbuffer is empty by

//  SendByte sequence

while( USART_GetFlagStatus(USART2, USART_FLAG_TXE)==RESET);

USART_SendData(USART2,data);

to send two or more  consecutive breaks  must check before ' Break Character' flag

//check before  the CR1 SBK flag

while(USART2->CR1 & CR1_SBK_Set);

USART_SendBreak(USART2);//Break

while(USART2->CR1 & CR1_SBK_Set);

USART_SendBreak(USART2);//Break

Posted on July 25, 2017 at 13:06

hello thanks.

but when i use this code

while(USART2->CR1 & CR1_SBK_Set);

USART_SendBreak(USART2);//Break

break doesn't send at all

Posted on July 25, 2017 at 16:18

Hello again

mahmoud

!

What you mean

doesn't send at all

?

You mean stucks to ''while loop''?

To observe if Uart tranmitts  clear manualy TC flag (transmit completed) just before transmit.

and observe it after send a break .

I took a look at dmx512 protocol.

0690X00000603y3QAA.jpg

It don't says ''send a break ''  but describes Break condition as LO state of line. (means keep IO pin low for xxx microsec)

0690X00000603vPQAQ.jpg

So i think you need a different approximation for your project..

For Break and MAB and MTBFs   states you may use your TX pin as normal output and keep it low or hi  for some time. .

When you need to transmit serial data  Change it to Uart tx pin and transmit the data!

Regards

ISHA
Associate II

The USART module available on STM32

microcontrollers has the ability to automatically generate a 12-bit long break signal,

corresponding to 48 µsec at 250 k baud. Unfortunately, this is too short for use in a DMX512

application as the protocol requires a minimum length of 92 µsec.

Figure 6 shows the alternative hardware method chosen to generate the longer break

signal. A 100 Ω resistor is connected in series with the microcontroller's USART transmit pin

and the other end of the resistor to an I/O pin. With this solution, the break time can be

varied, from 92 µsec to 176 µsec to meet the DMX protocol break time specification, when

sending a break signal, the I/O pin is driven low. Later, the I/O pin is tri-stated to allow

transmission from the USART to resume.

 

ISHA_0-1719471466245.png