Loading

why is frequency of neopixel signal faster than PWM of the Arduo

Please Login to Comment

hay guys.

i was playing around with an oscilloscope and decided to compare the wavelength the neopixel data sinal with that of the PWM at, what i thought should be its highest possible frequency?

I'm using an arduino uno for the neopixel signal and a arduino nano to run the a sketch (see below) for the PWM. Both boards have 16Mhz clock speed so i assumed that wouldn't be a factor.
Anyway, as u can see in the picture the neopixel data sinal (blue line) is at a much higher frequency the the PWM (yelow line).

My question is, why is this?

//PWM code
void loop() {
digitalWrite(6,HIGH);
digitalWrite(6,LOW);
}

The Arduino PWM functions are universal and work on all Arduino derivatives.
That is because they are not hardware PWM.
If you chose a particular arduino derivative you could probably find a better PWM library that only works on that board.
The object of the Arduino PWM libraries is primarily to handle simple motor control and lamp brightness. That means that it doesn't have to go fast. The processors can go fast and do hardware PWM. but the universal libraries slow everything down. If you want performance then you shouldn't be using Arduino libraries.

PS I dont care what oscilloscope you use. I have worked with some very expensive oscilloscopes operated by people who didn't understand what they were doing.

That's not PWM, that's setting a pin high then low and repeating. Hantek doesn't make oscilloscopes, they make toys.
Lastly, from this website, it would seem that there is a specific timing to control the neopixels. Seems like yours are doing their default thing. I'm sure there are header files for this kind of thing, take a look around github for them or adafruit's site.

As Axeman72 says, 'arduino' headers tend to screw the pooch when it comes to timing. It's not super important for your neopixels though.

PWM with arduino is accomplished by a analogWrite(value), wherein value is a number from 0-255 to dictate duty cycle.

humm could do without the sarcasm regarding oscilloscopes.
But your right I should be less lax in my use of terminology when talking about stuff like pwm. As a mater of fact i have been experimenting with actual pwm i.e. the analogWrite() since i first posted.

That wasn't sarcasm, USB 'scopes are toys to learn with. How much did you end up spending on that Hantek anyway and what's the bandwidth on it?

Its not a usb scope. But even if it was that wouldn't make make it a "toy". A toy is something a child plays with. I don't think peoples should be mocked just for using entry level equipment.
If your really interested the modal number is DSO5102P, and it has bandwidth 100MHz although apparently it can be hacked 200MHz. It's not a professional level tool but its more than adequate for my purposes.

That's insane, $330 for a Hantek? Might have saved up a few pesos more and got the Rigol DS1054z. That puppy is a four channel dream, also hackable to 100Mhz with 24 Mpts. Rigol even sends four 150 Mhz probes and now the math functions come standard.

I wasn't ripping on you bud, just Hantek, calm yourself.

I actually spent the equivalent of around $225 on the Hantek. I'm sure the Rigol DS1054z is very good but its a lot more money and would imedity need to be hacked just to bring it to a respectable bandwidth, which is something i don't really want to risk attempting. At this point in time i don't think I need of four channels.

Maybe in the future I'll feel the need to upgrade but for now im content with the Hantek

The digitalWrite function is very slow. It's almost an order of magnitude, compared to the raw port bit manipulation.

Take a look at the show function in the neopixel library sources: https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp

It's quite complex, and full of tricks to get the needed data stream speed.

Beside that, it disables all interrupts, even the hardware ones.

yeah your not wrong about the neopixel library being quite complex, to complex for me to follow at least :)

But thanks for the explanation, that was all i was after anyway.