 |
 |
| View previous topic :: View next topic |
| Author |
Message |
freesat
Joined: 08 Feb 2011 Posts: 32
|
| 4Mhz is not quickly to do dmx |
Posted: Tue Feb 08, 2011 10:10 am |
|
|
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
|
|
Posted: Tue Feb 08, 2011 10:08 pm |
|
|
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....
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.
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
|
|
Posted: Tue Feb 08, 2011 10:50 pm |
|
|
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
|
|
Posted: Wed Feb 09, 2011 9:49 am |
|
|
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.  |
|
 |
arunkish
Joined: 23 Dec 2008 Posts: 83
|
|
Posted: Fri Feb 18, 2011 8:19 pm |
|
|
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
}
}
|
|
|
 |
|
|
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
|