Its a first draft and I offer it up as-is so I make not warranties.I'm open to suggestions or improvements.
BTW the question did seem familar.
Its a first draft and I offer it up as-is so I make not warranties.I'm open to suggestions or improvements.
BTW the question did seem familar.
Last edited by DynamoBen; - 8th March 2007 at 05:18.
dear dynamoben thanks for your answer i will try it, is there anybody here that tryed it and working?
and how can i use it for 16f628 and 20 mhz osc and i will use only 3 led to dimmer them imean 3 chanel ?
Last edited by syscoder; - 14th March 2007 at 22:09.
ok friends thank you for helping i will try to make it and will see if it is working then i will post code here cause i see there is many people here need help to receive dmx signal like me
i understand pulsin is for the break signal and hserin is to receive dmx
hi friends i search in the forum and found many examples thanks. i have pic 16f876 , 20 mhz osc and 1 led ,i have dmx512 lighting desk too and i want to dimm a led on dmxadres 1 (0-255 to led intensty) but there is some problem on this code it is not working. i found this code in the forum and made it again for my pic but couldnt find the problem.can you look to my code and say what is my problem here?or you can send other example code to receive dmx ..
' PIC 16F876 - 20MHZ OSC
DEFINE OSC 20 ' 20 MHZ OSC
DEFINE HSER_TXSTA 24h ' Enable transmit
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_SPBRG 4 ' 250 000 Baud @ 20MHz, 0.0%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
ASM
ERRORLEVEL -306, -302
ENDASM
ADCON0 = 0
ADCON1 = 7
counter var word
idleflag var word
dummy var word
RCIF VAR BYTE
startcode var word
aminus var word
adress var word
x var word
level1 var word
adress = 1 ' My Start Adress
checkdmx:
counter = 1 ' Dummy variable
pulsin portC.7,0,counter 'Here looking for the break signal
if counter = 0 then
idleflag = 1 'either no dmx , or break was too long to count
'return
endif
if counter < 40 then checkdmx ' watching for "break"
dummy = RCREG
dummy = RCREG
SPBRG = 0
TXSTA.2 = 0
TXSTA.4 = 0
RCSTA.7 = 1
RCSTA.6 = 0
RCSTA.4 = 0
RCSTA.4 = 1
while RCIF = 0: wend
startcode = RCREG 'firs byte after break
if startcode <> 0 then checkdmx
aminus = adress -1
for x = 1 to aminus
while RCIF = 0: wend
dummy = RCREG
next x
level1 = RCREG
portC.1 = level1 'i want to dimm led on port c.1
RCSTA.7 = 0
goto checkdmx
return
*sigh* Why don't you read the responses to your numerous other posts on this topic elsewhere in the forum.
maybe that's way ?
this was i found searching, is well commented and easy to modify, i was wondering how much channel is possible to drive if I put out analog in and change pic to 18f452 with pll_en (40mhz)
or is it clever (or possible) to port (interrupt driven) triac drivers and dmx receiver into a asm interrupt handler subroutine in bas file, so i can touch other not critical pieces of code...
I know it is not easy to do, but can be interesting to everyone in this thread...
my programming knowledge i poor when talking about asm_interrupt but I will give a try..
http://epanorama.net/digipack/Digi_Pack/dmx_pack.asm
newlevel1 = RCREG 'This is your target channel data
portA.2 = newlevel1 'i want dimming a LED on PORTA.2
RCSTA.7 = 0 'turn off the USART
--------
Just curious - how do you expect a single pin, which at any given time can only have one of two discretes states, to represent all 255 possible values of DMX channel data?
Hint: Pulse Width Modulation is your friend. It's a way to time-average a bunch of discrete states (ones and zeros) to approximate various channel levels.
Search for 'PWM' and see what you find. Check out 'HPWM' in your PBP manual. You'll also find many, many examples of software controlled PWM buried in this forum.
And if you're really ambitious, google for Artistic License's 'Bit Angle Modulation' white paper. It's ingeniously simple and requires almost no work to code the routine in software.
JEC
EDIT: Didn't realize this same question had been replied to in two other threads in the past few hours. Sorry to repeat what everyone else has been saying re: PWM & R'ing the Friendly Manual.
Last edited by JEC; - 21st March 2007 at 15:44.
Bookmarks