ATMEGA8 and WS28121B strange start ???

Go To Last Post
26 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I've made a board with ATMEGA8 running at 8MHz and 11 WS2812B LEDS.

Because of a shortcut, i've had hard time making it work but i'm facing a problem i've never had before.

On cold start (capacitor uncharged or shortcut between vcc and gnd pins), the ATMEGA starts normally, it drives the LEDs stripe with 24 bits datas but NO LIGHT at all.

At this point, i put a small wire or a screw driver on RESET pin, then, the LED stripe goes ON.

I can do the same if i power the board with the programmer port and reset the chip (ExtremBurner read or write function).

On "HOT" startup (Caps charged), everything run normally.

I've tryed adding a delay on startup (_delay_ms(800);) and also the startup fuse setup (0, 4ms, 64ms with C4, D4, E4 at LFUSE).

Strange thing isn't it ?

If someone has a hint about this, it would be great.

 

 

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

FYI people - i think the word ‘shortcut’ should be ‘short circuit’.

Ok mr reptooyep, you’ve made a board and you’ve got problems. Without you giving us information about this board, how can we assist? A schematic and a picture might help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

the board is very simple.

Reset pin to VCC through 10Kohm resistor,Mosi to Mosi, etc ... and PC4 to Din of the first LED, Dout to Din of the second, etc ....

The battery voltage is measured by a divider bridge on PC2. The colors must change if the voltage goes down.

I don't have shematic (except in my head) but i can draw it if necessary.

I've made a video of the problem that i'll post as a link.

 

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As mentioned a schematic would be helpful.

 

What is your power supply?

 

Do you have by-pass caps on the micro?

 

Do you have a cap next to each LED?

 

Do you have a cap on the V+/Grd bus where it enters the board?

 

Plugging in the power connector is likely giving you bounce on the V+ bus, similar to a push button switch bounce when its contacts make or break.

 

The AVR micros have a power on reset circuit.

They like a clean, monotonic (single, clean slope of rising V+), on the Vcc pin.

 

You might try adding  a 0.1 uF cap from Reset\ to Ground to slow the reset inside the micro down, and see if that helps.

 

Not sure where in the world you are located, but you can likely purchase a bag of small push button switches on eBay or Aliexpress for about the same cost as an SMD resistor.

Having a small push button reset switch is safer than using a knife or screwdriver to short pins out

At some point you might short our the wrong pads / traces and damage your circuit.

 

JC

 

Edit: Typos

Last Edited: Sat. Jan 4, 2020 - 01:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, since the output command of the MCU is ok when the leds are off, i don't think the problem comes from the RESET but i've tryed the 0,1uf capacitor on RST pin without success.the problem should come from the WS2812 but i don't understand. I'll try to feed the LED line with ADC interrup in free run mode to see if it changes something.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

Last Edited: Sat. Jan 4, 2020 - 05:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Trying to describe a circuit in words is extremely ineffective

 

reptooyep wrote:
I don't have schematic (except in my head)

Well there's a recipe for disaster right there!

 

surprise surprise

 

but i can draw it if necessary.

Yes, it is necessary!

 

I suggest that you draw the schematic from first principles without looking at your board.

 

Then check your board against the schematic - that may well show you the problem(s) right away!

If it's still not working, then post the schematic.

 

Also post some good, in-focus photos of your setup.

 

See Tip #1 (in my signature, below; may not be visible on mobile) for how to put pictures in a post.

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
At some point you might short our the wrong pads / traces and damage your circuit.

Especially if you're just balancing it on your knee!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The circuit is not damaged, as i can see the LED command on scope. I'm here for help, not for jugment, the MCU part of the shematic is a copy/past of all my working projects so, i'm sure of the wiring of the MCU. Tonight, i'll draw a shematic, so that you will be happy.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Adafruit recommends putting a 100 uF capacitor across the V+ and the Ground near the LEDs (they call them NeoPixels).  And adding a 300 to 500 ohm resistor between the AVR data pin and the input of the first LED.  If you have 11  LEDs and they all turn on full at once (worst case), then you have 150 or more milliAmps surging through the circuit at the same time that the LEDs are receiving data or processing it internally.   If this surge pulls the Vcc down in this microSecond interval, then the LEDs may not be getting or processing the correct data in this ripple interval.  Adding a 10-100uF ripple-suppression capacitor can help.  The resistor adds nanoseconds of delay to the data signal and suppresses data signal reflections on long LED signal lines.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for this helpfull reply. I didn't see the need of a resistor between the MCU and the first LED. i've put a 100uf capacitor between Vcc and Gnd. I'll try this tonight.
Each led are powered throught a 100ohm resistor and have a 100nf cap between vcc and gnd.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why the 100 0hm resistor for each led? That seems like a recipe for disaster.
As mentioned, these leds can pull a significant amount of current - is your pcb designed to cope with this? Ie track sizing and layout.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I first didn't put resistor but the light was too strong
So, i put 69 ohm cause i want them to light a bit. So, for 11 leds, the current is about 800ma.
On reset, i have the good color, depends on what voltage i put on pc2 but it changes only on reset.
Maybe my MCU is fucked up. I don't have any spare one to test.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

Last Edited: Sun. Jan 5, 2020 - 12:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Led 0.1 uF caps should be at LED Vcc pin, not Vcc supply rail.  The resistor is ok & recommended to help clean the logic supply very slightly (RC filt).

 

The high current for the LEDS comes in on the Vdd pin , which you neglect to to show, or maybe forgot to hook up?

 

Your ADC pin is missing a cap, be sure to include something so Uncle Al doesn't sneak into the ADC spectrum.  

  

 

Edit:

Ah, these comments apply for the WS2812, the WS2812B has a slightly reduced pinout, which combined the led & logic power onto one pin

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Jan 5, 2020 - 08:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No need to use profanity. There’s no evidence to suggest your AVR is Friar Tuck - what the evidence is pointing to is bad circuit and pcb.
The software determines the brightness - thats why you’re using the ws2812 isn’t it? Putting a resistor in the supply is most likely causing more problems. Upset the first ws2812 in the chain and the others wont work.

Also realise that your pcb tracks are resistors. Depending on what current is flowing where determines if there are significant voltage drops. This is why we need to see the layout. You ‘think’ your circuit is dimple, but clearly there are things happening that are not simple. Most likely there are a number of fundamental problems working together to make a very complex problem.
We know the led current can be significant - ensure the led current doesnt flow through tracks to the AVR. Current flows in a loop - so visualise where those loops are. The led current loop should be psu, 100uF capacitor then the leds. The AVR loop should be separate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And adding a 300 to 500 ohm resistor between the AVR data pin and the input of the first LED.

OK, but if the WS LED is the only component attached to the IO pin, and the micro and the LED (s) are all on the same PCB, then it isn't clear to me that this is needed at all.

 

Why would one think that it would impact long chain reflections?

 

Each LED has its own internal circuitry, and after stripping off its data, passes the remainder of the serial data stream on down the line.  

Each LED has its own serial data receiver, and its own serial data transmitter.

Clearly there can be current surges, but all of the LEDs don't turn on together, they turn on sequentially, as the data makes its way down the string.

That said, they can draw a lot of current, and one clearly needs a good power supply to drive a bunch of them.

 

WHY is there a resistor on the V+ supply for the LEDs?

The LEDs have their own digital circuitry, and the spec sheet for the WS LED tells its operating voltage.

If you want to dim the LEDs you do so in software, as mentioned above, NOT by putting a resistor in series with them.

These are digitally controlled LEDs not normal LEDs where one could use a series resistor to implement dimming.

 

If each color is 255, 255, 255 then you get bright White.

If the colors are 128, 128, 128, then you get "1/2" brightness.

(In quotes because the actual perceived intensity isn't linear to the LED's internal level adjustment.)

 

The data sheet also says that each of the LEDs should have its own by-pass cap.

No surprise there, they are digital chips that happen to contain three LEDs.

Chips need by-pass caps, these are no different than any other chip in that regard.

 

They are very cool LEDs to work with!

 

JC

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
That's so evident now. The datasheet didn't explain how to deal with brightness. My Vdd line for the led is the same than the MCU but with the small ammount of curent, this should not be an issue.
One question :
The led routine turn off interrupts but i use free run mode adc with ISR, so, this should not cause a problem ? The interrupts are put back on after WS data writing.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why run the adc in free run with interrupts then? Keep things simple so potential problems are simple to identify and solve.

 

 

My Vdd line for the led is the same than the MCU but with the small ammount of curent, this should not be an issue.

That's a bit assumption. Of course the Vdd line is the same as is the 0V , but the physical layout is the critical issue. You've yet to show us this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've tryed both way with the same result but free run is a bit smarter way i think (for me only).
I've made two boards but the mcu of the second one was fused for crystal. So, i've added a crystal with flying wires just to reprogramm the fuses. Now i have two board with exacty the same setting and the same problem.
Still searching 😞
I forgot to say : Happy new year to everyone

I use ATMEL STUDIO 6 and work now on ATMEGA328p

Last Edited: Sun. Jan 5, 2020 - 10:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why are you still searching? We've told you where the problem most likely is, but you seem to ignore it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With a software tweak, now, it works as expected without adding caps anywhere else.
I'm very sory to say that my hardware is good.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the code or code library that you are using for driving the LEDs?   At 8MHz, the AVR will be using assembly language to get the timing right on the WS2818B LEDs. They have each of the 24 bits use the format of 400 nanoSec  high, followed by 400 nS of data level, and ending with 400 nanoSec of logic low (0 volts).

The interrupts need to be turned off during this 300 microsecond  LED-write period (1.2uS per bit, 24 bits, 11 LEDs).   How quickly are you updating the 11-LED frame?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
I use POLOLU led_strip_ds.c library.
It's convenient to use cause all the ASM code is writen in a single function.
I use freerun mode adc to launch the leds updating.
The POLOLU function starts by cli() and stops with sei().
So, i don't know how many time does the updating last. I can check with the scope.
The only way i make it work is to relaunch the freerun mode of the adc at the end of the ISR.. I don't know why but it works. I'll try to understand why did it refuse to work in a simple way later.
The only remaining problem is that i check the battery value between 29,3 and 23,3v with a 1/10 divider on 8 bits. So, the measuring range is very tiny(between 150 and 120 integer), i only have about 30 differents colors but the board is very simple for a not so bad result.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

Last Edited: Sun. Jan 5, 2020 - 08:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I measure 400ns for the 24X11 bits.
I think it's not precise cause the clock is not.

I use ATMEL STUDIO 6 and work now on ATMEGA328p

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

reptooyep wrote:
The only way i make it work is to relaunch the freerun mode of the adc at the end of the ISR.. I don't know why but it works.

What do you mean by"relaunch"? Do you start a new conversion?

 

If a small change mysteriously makes something "work" then you should be very careful in your assumptions. You may still have a latent problem with the circuit, PCB and/or software.

/Jakob Selbing