DMX

DaveBl

New Member
Anybody had a crack at generating DMX512 with an overclocked picaxe 28/40? Ccould be borderline too slow maybe.

Dave B
 

hippy

Ex-Staff (retired)
Borderline too slow is a bit of an understatement; DMX-512 requires a baud rate of 250,000 baud, the best an overclocked 28X/40X can deliver is 192,000.

I did propose a solution for high-speed and unusual baud rate transmissions ( eg, MIDI ), which would be to use serial-in-serial-out shift registers, load the required bits for a transmitted byte at PICAXE rates by bit-banging, and then let PWMOUT run to clock those bits out at the correct rate. Not sure if anyone tried it.

http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=3739
 
It will cost you a lot (£80), but Milford Instruments do a RS232 to DMX converter card based on the SX MCUs (I think they also do pre programmed chips). I realise this isn't getting a PICaxe to do the work for you.

You could perhaps get a RS232 to RS485/422 converter and use that
 

hippy

Ex-Staff (retired)
Or take it as a golden opportunity to learn some minimal PICmicro / AVR skills and design a simple Serial In / DMX Out interface yourself.

It's just a matter of bit-banging, sampling the serial in at the right time and the DMX byte can be banged out during the course of the incoming stop bit even for serial up to 192,000 baud. No need to use on-chip UART or anything fancy or complex.

You'll need a means to trigger sending the DMX 'break', but there are a number of options which can be discussed if you go this route.

If you are using DMX but don't understand the protocol, this could be the opportunity, and it is fairly easy to grasp.
 
Hippy,

Could you expand on how difficult it would be to start outputing DMX from a PIC? Does it involve a lot of calculating instruction execution timing to get the DMX timing correct? I'd like to have a go, but I've not even finished the first stepper motor controller I started using an 16F627A yet. I currently use an RS232 to DMX converter like I mentioned from Milford. I use visual basic to control that.

Thanks

Matthew
 

hippy

Ex-Staff (retired)
It's relatively easy, and is generally a case of counting off execution cycles so the DMX line is put high or low according to the bits of the byte you are outputing. The hard part is in getting every bit from a byte and outputing it every 4uS. Something like this at 8MHz ...<code><pre><font size=2 face='Courier'>Bit0:
NOP ; 1 1
NOP ; 1 1
BTFSC txByte,0 ; 2 1
GOTO Bit0Hi ; 2
NOP ; 1
BCF PORTB,7 ; 1
GOTO Bit1 ; 2
Bit0Hi: ;
BSF PORTB,7 ; 1
GOTO Bit1 ; 2
; = =
; 8 8 = 4uS </font></pre></code> At the main loop level you would send a break using the same timing tricks using NOP's etc as pauses, send all the bytes you want to and repeat forever. Of course you then need to handle RS232 bytes coming in and it would be easiest to handle them by using the on-chip UART, and check if anything has been received before sending each DMX byte. That's quick enough checking that nothing will be missed and no incoming data over-runs should happen.

How straight forward that all seems probably depends upon your previous programming experience !
 

DaveBl

New Member
Thanks Hippy re DMX. I think I will grab a
PIC16F whatever and give it a go using a Hitech C compiler, what do you reckon? I will brush up on my neglected C for a day or two!

Dave B

 

hippy

Ex-Staff (retired)
Hitech C should work, I've done similar timing stuff using CC5X/CC8E C. You probably need to tweak the C code to get the right code/timing or drop in to inline Assembler, but you should be okay. Microchip's MPLAB Stopwatch is superb for checking bit-banged timing.<code><pre><font size=2 face='Courier'>void main()
{
Initialise();
do
{
SendDmxHeader();
for( channel = 0; channel &lt;= 512; channel++ )
{
SendDmxByte( channelData[channel] );
}
}
while ( TRUE )
) </font></pre></code> Or something like that, and build up from there.
 
Top