CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

DMX512 Control
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
freesat



Joined: 08 Feb 2011
Posts: 32

View user's profile Send private message

4Mhz is not quickly to do dmx
PostPosted: Tue Feb 08, 2011 10:10 am     Reply with quote

Hi, increase your pic speed, then change baudrate register.

On my projects, 4mhz is not sufficient to do 250.000 and another instructions needed.

8mhz+ is recommended.

Soon will post my 18f4550 usb to dmx interface project and source code on this board. It works perfect with FreeStyler.
arunkish



Joined: 23 Dec 2008
Posts: 83

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 10:08 pm     Reply with quote

Temtronic, This is my latest stuff. As you advised I removed all those switch case statements and tried to send the data manually for all the 24 channels, as below. 4Mhz - Clock.

Code:

// ********** CHANNEL4
DMXOUT=0; delay_cycles(3); // 1 Start Bit
DMXOUT=1;delay_cycles(3);
DMXOUT=1;delay_cycles(3);
DMXOUT=0;delay_cycles(3);
DMXOUT=0;delay_cycles(3);
DMXOUT=0;delay_cycles(3);
DMXOUT=0;delay_cycles(3);
DMXOUT=1;delay_cycles(3);
DMXOUT=1;delay_cycles(3);
DMXOUT=1;delay_cycles(3);  DMXOUT=1; delay_cycles(3);  /* Stop Bits */



Before I experimented with the board I used MPLAB SIM - Stopwatch to make sure that the code runs exactly for 44 us that includes 1 StartBit + 8 Data Bits + 2 Stop Bits and unfortunately.... it stated to work in the board.... Very Happy

As you said... timing was the big mistake that was happening before.

Now... I tried to run the same code in this way....

#byte CH4=0
#bit CH4_0=CH4.0 ................. #bit CH4_7=CH4.7
DMXOUT=CH4_0;delay_cycles(3);.................DMXOUT=CH4_7;delay_cycles(3)

I experimented with the stop watch and it gave me 7 us width for a single bit. Therefore I removed the delay_cycles(3) and again checked with the stopwatch.

DMXOUT=CH4_0;.................DMXOUT=CH4_7;

Running this gave me exactly 32 us width (4*8) for 8 bits. When I checked with the board.... it did not work as expected.
Sad

What's wrong. What makes the difference in both the code? Why the time period increases if i refer to a variable? Should I change anything???
arunkish



Joined: 23 Dec 2008
Posts: 83

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 10:50 pm     Reply with quote

I suspect the variable turns to 0 when the 8 bits are sent as mentioned below.

DMXOUT=CH4_0;.................DMXOUT=CH4_7;

I tried like this

DMXOUT=1; delay_us(3);
DMXOUT=CH4_1;
DMXOUT=1; delay_us(3);
DMXOUT=CH4_4;
DMXOUT=CH4_5;
DMXOUT=CH4_6;
DMXOUT=CH4_7;

This gave me a Circle.... the one that i got when I tried to run it manually without variables. When variables are used I get the result of 0, when i do manually.
arunkish



Joined: 23 Dec 2008
Posts: 83

View user's profile Send private message

PostPosted: Wed Feb 09, 2011 9:49 am     Reply with quote

Cheers!!!! The war is finally over. Made required changes in Hardware and Software. Finally everything works well. I will post the code here in this forum tomorrow. Thank you all for your great help. Wink Razz
arunkish



Joined: 23 Dec 2008
Posts: 83

View user's profile Send private message

PostPosted: Fri Feb 18, 2011 8:19 pm     Reply with quote

Here is the working code to send 25 channel data to DMX Controller. Bit Banged!


Code:

#include <16F73.h>
#fuses HS,NOWDT,PUT,NOBROWNOUT,PROTECT
#use delay(clock=8000000)

#byte PORTA=0x05
#byte TRISA=0x85


#bit DMXOUT=PORTA.0


#byte CHD=0
#bit  CHD0=CHD.0
#bit  CHD1=CHD.1
#bit  CHD2=CHD.2
#bit  CHD3=CHD.3
#bit  CHD4=CHD.4
#bit  CHD5=CHD.5
#bit  CHD6=CHD.6
#bit  CHD7=CHD.7



void sendchanneldata(void);

int j;


byte data_DMX[24]={255,6,45,0,0,
                          0,0,0,0,1,
                    0,0,0,0,0,       
                    0,0,0,0,0,
                    0,0,0,0};


void main(void)
{

set_tris_a(0x00);PORTA=0x00;
DMXOUT=1;
sendchanneldata();
   
}



void sendchanneldata(void)
{

               
DMXOUT=1; // MTBP - Idle
delay_cycles(14);  // MTBP - Idle
DMXOUT=1; //  MTBP - Idle
delay_cycles(14);  // MTBP - Idle


DMXOUT=0; // B
delay_cycles(100); //B
delay_cycles(79); //B



DMXOUT=1;       // MAB
delay_cycles(7);   //MAB
DMXOUT=1;       // MAB
delay_cycles(7);   //MAB


/*****************************************/
/* SC */
/*****************************************/


DMXOUT=0; delay_cycles(7);  // 1 Start
delay_cycles(64);
DMXOUT=1;delay_cycles(7); DMXOUT=1; delay_cycles(7);   // Stop

/*****************************************/
/*  SC */
/*****************************************/


      for(j=0;j<=23;j++)
      {   
               CHD=data_DMX[j];
         
               DMXOUT=0; delay_cycles(7); // 1 Start
         
               DMXOUT=CHD0 ;delay_cycles(4);
               DMXOUT=CHD1 ;delay_cycles(4);
               DMXOUT=CHD2 ;delay_cycles(4);
               DMXOUT=CHD3 ;delay_cycles(4);
               DMXOUT=CHD4 ;delay_cycles(4);
               DMXOUT=CHD5 ;delay_cycles(4);
               DMXOUT=CHD6 ;delay_cycles(4);
               DMXOUT=CHD7 ;delay_cycles(4);

               
                    DMXOUT=1;delay_cycles(7); DMXOUT=1; delay_cycles(7); //* Stop
             
      }

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group