Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] driving ws2812 rgb led with lpc1788

Status
Not open for further replies.

monjiemegoo

Newbie level 6
Joined
Oct 27, 2018
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
307
hellow guys
iam using lpc1788 board to driving ws2812b addressable led rgb.there is a library for driving this leds with Arduino named fast led.when i using arduino i have no problem for driving one or more led.but when i using arm there is some problem.first i shoud say i write code myself and dont use any library for driving with arm.when i saw the waveform i create with pwm this is the exact waveform that arduino make and i have no problem with driving a single led but when i want drive two led with arm it makes several problem and the second led turn on with a lot of noise and this noise effect on the first led and the color chane. i realy dont know what shoud i do and where is the problem.shoud i add some capacitor into circuit or 3.3v voltage is not enough for driving this leds.is any simple circuit exsist for changing the 3.3v to 5v with 800khz frequncy that this les needs.
plese if anyone drived this leds with lpc and have a code or note for me help me
thanks
 

According to datasheet minimal logic high level is 0.7 Vdd, thus 5V Vdd demands at least 3.5V logic level. Due to ground bounce effects, you'll better drive a 5V supplied WS2812 with full 5V logic. TTL compatible CMOS gates like 74HCT are a simple way to convert 3.3V to 5V logic level.
 

thanks for answering
I have one 74hc125p but when I use it.it wont work right.please guide me how shoud I use it
thanks
 

74hc has cmos level specification similar to WS2812, you need 74hct with 5V supply.
 

do you mean I have to chane my ic?
I am new in electronic please help me with more details
thank and excuse for boudering you but I need it very much
 

Hi,

Search the datasheets for V_IH, this tells you what input voltage you need for the IC to detect it as logic HIGH.
You can't ignore this specification.

As already told you could use HCT types, because they are happy with about 2V.

Or you could try a pullup to 5V, to raise the level to a valid level.

Klaus
 

is anyone do what I wanna do with arm?
is anyone had a similar problem that I have?
I realy try every thing with any kind of voltage level
I need someone that know exactly where is the problem with my circuit
I think with adding som capacitor the problem could be fix but I don't know what is the exact circuit?
or anyone have any library for driving this leds with lpc?
thanks
 

Hi,

Your informations are rather confusing:
I realy try every thing with any kind of voltage level
I need someone that know exactly where is the problem with my circuit
I think with adding som capacitor the problem could be fix but I don't know what is the exact circuit?
or anyone have any library for driving this leds with lpc?
* we do not know what you have tried, what you expected and what the result is. We do not know where you think to use a capacitor..

Give exact and complete informations.
* show your circuit - even hand drawn is OK.
* show scope pictures of the logic signals....where we can see voltage levels and timing.
* show your code

Klaus
 

photo_2018-12-28_12-32-17.jpg

photo_2018-12-28_12-35-51.jpg


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include <lpc177x_8x.h>
 
#define RES 150000
#define a 14
#define b 60
#define ONE_SEC_SUITCH 20000
//***********************************************************************
_Bool green_flag=1;
int complate_green_flag=0;
_Bool red_flag=0;
int complate_red_flag=0;
//***********************************************************************
uint8_t counter_color=0;
uint8_t red[25]           ={18,18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18};
uint8_t green[25]         ={54,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18};
uint8_t yellow[25]        ={54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18};
uint8_t blue[25]          ={18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54};
uint8_t blue1[25]          ={a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,b,b,b,b,b,b,b,b};
uint8_t double_green[49]  ={54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18};
uint8_t double_red[49]    ={18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18};   
uint8_t double_blue[49]   ={18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54};
uint8_t green_red[49]     ={54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,54,54,54,54,54,54,54,54,18,18,18,18,18,18,18,18};
//***********************************************************************
void initTimer0(void)
{
        LPC_TIM0->CTCR = 0x0;
        LPC_TIM0->PR   = 0;
        LPC_TIM0->TCR  = 0x02;
}
//***********************************************************************
void delay_us(unsigned int microseconds)
{
        LPC_TIM0->TCR = 0x02;
        LPC_TIM0->TCR = 0x01;
        while(LPC_TIM0->TC < microseconds);
        LPC_TIM0->TCR = 0x00;
}
//***********************************************************************
void initPWM(void)
{
        LPC_SC->PCONP |= 1<<5;
        LPC_IOCON->P1_2 = 3;               //Select PWM0.1 output for Pin1.18
        LPC_PWM0->PCR = 0x0;               //Select Single Edge PWM - by default its single Edged so this line can be removed
        LPC_PWM0->PR = 0;                  //1 micro-second resolution
        LPC_PWM0->MR0 = 75;                //20000us = 20ms period duration
        LPC_PWM0->MR1 = 54;                //1ms - default pulse duration i.e. width
        LPC_PWM0->MCR |= (1<<1) | (1<<0) ; //Reset PWM TC on PWM0MR0 match
        LPC_PWM0->LER = (1<<1) | (1<<0);   //update values in MR0 and MR1
        LPC_PWM0->PCR = (1<<9);            //enable PWM output
        LPC_PWM0->TCR = (1<<1);            //Reset PWM TC & PR
        LPC_PWM0->TCR = (1<<0) | (1<<3);   //enable counters and PWM Mode
}
//***********************************************************************
void updatePulseWidth(unsigned int pulseWidth)
{
      LPC_PWM0->MR1 = pulseWidth;  //Update MR1 with new value
      LPC_PWM0->LER = (1<<1);      //Load the MR1 new value at start of next cycle
}
//***********************************************************************
 
//  void switch_red_green()
//  {
//           if(green_flag)
//              {
//                  green();
//              }
//           if(complate_green_flag>ONE_SEC_SUITCH)
//              {
//                  green_flag=0;
//                  red_flag=1;
//                  complate_green_flag=0;
//              }                
//           if(red_flag)
//              {
//                  red();
//              }
//           if(complate_red_flag>ONE_SEC_SUITCH)
//              {
//                  red_flag=0;
//                  green_flag=1;
//                  complate_red_flag=0;
//              }
//  }
//***********************************************************************
void send_color (uint8_t color[25])
{
    updatePulseWidth(color[counter_color]);
            if(counter_color >=25 )
         {
             updatePulseWidth(0);
             delay_us(RES);
             counter_color=0;
         }
}
//***********************************************************************
void send_double_color (uint8_t color[49])
{
    updatePulseWidth(color[counter_color]);
            if(counter_color >=48 )
         {
             updatePulseWidth(0);
             delay_us(RES);
             counter_color=0;
         }
}
    //***********************************************************************
    void PWM0_IRQHandler(void)
  {
    LPC_PWM0->IR |= (1<<0);
    counter_color++;
  }
//***********************************************************************
 
int main()
{
      initTimer0();
    initPWM();
    NVIC_EnableIRQ(PWM0_IRQn);
    while(1)
     {
    //for(int t=0;t<100000;t++)
            send_color( blue );
            //send_double_color(green_red);
            //send_double_color(double_blue);
            //send_double_color(double_green);
            //send_double_color(double_red);
   }
 
}



the frequency is 60mhz

thanks
 
Last edited by a moderator:

Hi,

There are several issues regarding your schematic:

* The LPC has no power supply
* the LPC has no power supply capacitors
* what´s the use of the pot? --> don´t use it.
* VDD of the WS2818B needs to be connected to the 5V supply (not to the pot)
* each WS2812B needs it´s own ceramics capacitor connected as close as possible to it´s VDD and GND.

WS2812_app.JPG

You urgently need to read WS2812B datasheet and keep on it. Especially the "Typical application circuit"


Klaus

added:
show scope pictures of the logic signals....where we can see voltage levels and timing.
This is no scope picture, thus we can´t see voltage levels.

BTW: I can´t see that you have tried anything (and how) we have posted.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top