Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

rs-485

Status
Not open for further replies.

user1453

New Member
I'm interested in using rs-485 on a pic michrocontroller in order to generate a DMX signal, only problem is I'm not sure how to impliment it, can I use uart on a pic to generate rs485?

some information on dmx

The basic DMX-512 signal is a 250kbps serial signal, eight bits data, one start bit, two stop bits, and a frame start break traveling on the RS-485 standard. A frame contains 513 bytes, the first byte was intended to contain a device number, which was never defined as anything but 0, the remaining 512 are the values each device is supposed to receive. Device 0 will only use the second byte of each frame, device 13 will use the 15TH byte of the frame, etc. So a typical frame will contain a logic low for 88uS or greater (Frame break/start) then a logic high for greater than 7uS (two stop bits), then a logic low start bit of 4uS, eight bits of data, each 4uS, LSB first, then logic high for greater than 7uS. This enables each light to be updated some 40+ times each second. Each device is supposed to hold their last setting for up to 1 second if the signal stops. There is no checksum or error correction of any kind. You may note that for lighting this is ok, if a light has been getting 0 for the last few seconds, and suddenly gets a 128 due to noise, it doesn't have time to change brightness noticeably before the next value comes. Therefore it is to be used only for non-critical systems (i.e., no flash pots, props or other dangerous equipment). There is only one signal source, though there are devices available which will take two sources and transmit one signal containing the higher value of each source per channel.
 
There is plenty of PIC DMX stuff on the net, a simplr google give this at the top:
.

I've also seen quite a lot of commerical DMX gear that uses PIC's as well.
 
I know enough about dmx to send the correct packets, I was more looking for a tutprial about using rs485 with a pic
 
user1453 said:
I know enough about dmx to send the correct packets, I was more looking for a tutprial about using rs485 with a pic

Look at the routines used there, or the other many DMX/PIC websites, it should be simple to understand the serial routines - the site I mentioned only uses a 16F84 at 4MHz. For a more 'professional' approach you might try https://www.qsl.net/n5tle/ which uses a 20MHz 16F876, and has better commented code.
 
I prefer RS485 over RS232, the driver chips are simpler SN75176 is a nice small 8 pin dip (of course MAXIM makes nicer versions). It's half duplex and unless it's 9 bit you can pretty much just tx & rx just like rs232. You do need to toggle the DE/RE lines when you transmit.

Heres a link to a BASIC Stamp app note on RS485
**broken link removed**

One thing, when using with a hardware usart you should pull up 22K-100K the RX line going in to the PIC.

If you want to "play around" with RS485 then look at https://www.rs485.com
for schematics and info, great site.
Or use a simple pair of 1K resistors for a single ended RS232 to RS485 adapter. (Find the Cricket schematic on my sites' "old site") the schematic is part of that.
 
Last edited by a moderator:
any tutorials for dpoing rs485 in assembler?

could I just treat it as rs232?

but how would i include 2 stop bits?
 
from what I've read so far, I can use nigles software rs232 code by altering the wait routines and adding a secont wait after the stop bit, leaving the stop bit twice high twice as long, signifying 2 stop bits. In order to send the data on the dmx cable I will have to use an rs485 driver chip. As for the data itself, I can use each byte of ram to store a levels for each channel. Once I have sent all the channels I wish to send I can simply set the level high for a period and then restart the sequence.


I have two question

one what pic operations take more than 1 cycle and 2 would there be any way of displaying the signal on my pc serial port, the dmx signal will be at 250kbs?
 
user1453 said:
from what I've read so far, I can use nigles software rs232 code by altering the wait routines and adding a secont wait after the stop bit, leaving the stop bit twice high twice as long, signifying 2 stop bits.

Yes, it's no problem at all to add as many stop bits as you want.

I have two question

one what pic operations take more than 1 cycle

The datasheet explains the instructions, but essentially almost all are just one cycle, except for jump or branch instructions.

and 2 would there be any way of displaying the signal on my pc serial port, the dmx signal will be at 250kbs?

I would imagine a PC serial port can work at 250kbs?, after all a PIC running at only 4MHz can handle it in software simulation, so surely a hardware UART on a multi-GHz processor can?. I imagine a little googling would find a DMX monitor program?.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top