Libstock
It is currently 24 Apr 2014 10:15

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: dmx receiver
PostPosted: 06 Jul 2006 11:26 
Offline

Joined: 04 Jul 2006 11:32
Posts: 11
Hi people,
i have an dmx receiver which works not correctly.
The data which i get from the receiver i want put out on a lcd.
the first 3 Bytes are exactly, but the 4th Byte and the following Bytes aren't on the channels which i send from an extern Dmx Transmitter.

This is my code:
//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules
#include "math.h"
#include "stdlib.h"
#include "string.h"

void waitBreakEnd(void);
#pragma interrupt_handler dmx_receiver_ISR

//#define FRAMING_ERROR 0x20    // Flag to check for parity error

int dmxcount;
BYTE master;
BYTE bRxData;
BYTE bRxData1;
BYTE bRxData2;
BYTE ch0, ch1, ch2, ch3, ch4, ch5, ch6;

void channels (WORD Data)
{
   if(dmxcount == 0)      //look for start code
   {
      if(Data == 0x00)   
      {
         ch0 = Data;
         dmxcount++;
         return;
      }
   }
   else if(dmxcount == 1)      //channel 1 (master)
   {
      ch1 = Data;
      dmxcount++;
      master = Data;
   }
   else if(dmxcount == 2)      // red
   {
      ch2 = Data;
      dmxcount++;
      pwmred_WritePulseWidth(Data * master);
   }
   else if(dmxcount == 3)      // green
   {
      ch3 = Data;
      dmxcount++;
      pwmgreen_WritePulseWidth(Data * master);
   }
   else if(dmxcount == 4)      // blue
   {
      ch4 = Data;
      dmxcount++;
      pwmblue_WritePulseWidth(Data * master);
   }
   
   else if(dmxcount == 5)      // orange
   {
      ch5 = Data;
      dmxcount++;
      pwmorange_WritePulseWidth(Data * master);
   }
   else if(dmxcount == 6)      // white
   {
      ch6 = Data;
      dmxcount++;
      pwmwhite_WritePulseWidth(Data * master);
   }

   //--------- hier kommt dann strobe
}

void waitBreakEnd(void)
{
   while(!(PRT0DR & 0x40)){}
}

void dmx_receiver_ISR (void)
{
   static BYTE bRxStatus = 0;
   static WORD bRxData = 0;
   bRxStatus = dmx_receiver_bReadRxStatus();   //read receiver status
   
   if(bRxStatus & dmx_receiver_RX_FRAMING_ERROR)   //check for start of dmx packet
   {
      dmxcount = 0;
      dmx_receiver_Stop();
      waitBreakEnd();
      bRxData = dmx_receiver_bReadRxData();      //read receiver data
      dmx_receiver_Start(dmx_receiver_PARITY_NONE);
      return;
   }
   
   bRxData = dmx_receiver_bReadRxData();      //read receiver data
      
   channels(bRxData);
   
   
}   

void main()
{
   char intRet0[8];
   char intRet1[8];
   char intRet2[8];
   char intRet3[8];
   char intRet4[8];
   char intRet5[8];
   int test = 0;
      LCD_1_Start();
   LCD_1_Init();
//   LCD_1_PrCString("Dmxreceiver");
   M8C_EnableGInt;
   dmx_receiver_EnableInt();       //enable Rx interrupt
    dmx_receiver_Start(dmx_receiver_PARITY_NONE);      //start receiver with no parity check
   pwmred_Start();
   pwmgreen_Start();
   pwmblue_Start();
   pwmorange_Start();
   pwmwhite_Start();
//   pwmred_WritePeriod(65535);
//   pwmgreen_WritePeriod(65535);
//   pwmblue_WritePeriod(65535);
//   pwmorange_WritePeriod(65535);
//   pwmwhite_WritePeriod(65535);
   
   
   
   PRT0DR &= ~0x20;
      while (1)
   {
   
//      LCD_1_Position(0,0);
//      LCD_1_PrCString("Ch0");
//      LCD_1_Position(1,0);
//      itoa(intRet0, (int)ch0, 10);
//      LCD_1_PrString(intRet0);

      LCD_1_Position(0,0);
      LCD_1_PrCString("Mas");
      LCD_1_Position(1,0);
      itoa(intRet1, (int)ch1, 10);
      LCD_1_PrString(intRet1);
      
      LCD_1_Position(0,3);
      LCD_1_PrCString("rot");
      LCD_1_Position(1,3);
      itoa(intRet2, (int)ch2, 10);
      LCD_1_PrString(intRet2);
      
      LCD_1_Position(0,6);
      LCD_1_PrCString("gre");
      LCD_1_Position(1,6);
      itoa(intRet3, (int)ch3, 10);
      LCD_1_PrString(intRet3); 
      
      LCD_1_Position(0,9);
      LCD_1_PrCString("blu");
      LCD_1_Position(1,9);
      itoa(intRet4, (int)ch4, 10);
      LCD_1_PrString(intRet4); 
      
      LCD_1_Position(0,12);
      LCD_1_PrCString("ora");
      LCD_1_Position(1,12);
      itoa(intRet5, (int)ch5, 10);
      LCD_1_PrString(intRet5); 
        



   }
   
   
}


thanks for all replies,
pfiff


Top
 Profile  
 
 Post subject: dmx receiver
PostPosted: 09 Jul 2006 21:48 
Offline

Joined: 03 Jul 2006 08:04
Posts: 66
I was trying to compile your code to see if i could help. :cry: But it seems that you have extra include files that are not located on my system. Is there anyway i could get a hold of them, so i can test it out also. :idea: Or maybe my setting for the project are not correct. Processor, Mhz, Etc :?:


Top
 Profile  
 
 Post subject:
PostPosted: 10 Jul 2006 06:55 
Offline

Joined: 04 Jul 2006 11:32
Posts: 11
Hi pahantom9999,
thanks for your reply, but i have solved this problem by myself. The problem was, that after i receive a byte i multiply a 16 bit value and this takes a lot of time.

pwmred_WritePulseWidth(Data * master);

Now i receive all bytes and then i multiply and write the pulse width of the pwms.

I have another problem:
i want to implement a strobe channel, channel 7.
my idea was using a counter, start it, set the port of my color high, when the counter is over, i set the port low.
10 % of Period time on, 90% of Period time off.
The problem is, i must strobe from 1 Hz to 25Hz.
The data, which i get from channel 7 must be the speed of the strobe.
dmx value 1 is 1 Hz, 255 is 25Hz, between this levels it must be linear.

Do you have any idea??

Thanks,
pfiff


Top
 Profile  
 
 Post subject:
PostPosted: 11 Jul 2006 05:42 
Offline

Joined: 03 Jul 2006 08:04
Posts: 66
Im kinda new to Mikro so bear with me. From reading you code, it dosent look like you using a Interrupts, You could use TMR0 ot TMR1 you interupt timer to do this function in the background. I have seen several posted code that uses the interrupts as a way to pulse all output to get everything in sync for AC timing for Zero Cross Dimming. Im sure something like that can be done.

Take a look at this link. This might help
http://www.mikroe.com/forum/viewtopic.p ... ght=dmx%2A


What is you application, what chip are you using and what are all the pins tied to.

What are you using for a pic and with what setting ( mhz,pinouts,etc. ). I would like to still see if i can get you code to compile on my system.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group