Hi all,
I have a need to read and pass through data very fast from one pin to another. Its for Pixel LED tape.
For example I need to digital read pin 3 and digital write this to pin 5. I need this to be able to happen reliably at around 800khz for the pixel tape to work.
So, I'm guessing I'll need direct port manipulation? Enable interrupts, then read bit set check?
With that in mind I've sort of tired by doing this:
int led_Din = 2;
int led_Dout = 5;
void setup(){
pinMode(led_Dout, OUTPUT);
pinMode(led_Din, INPUT);
attachInterrupt(0, data_in, CHANGE);
}
void loop() {
// put your main code here, to run repeatedly:
}
void data_in() {
byte x = PINB & B00000100;
if (byte x = 1)
{
bitSet(PORTD, 5);
}
else
{
bitClear(PORTD, 5);
}
}
Am I on the right lines? Will this be quick enough?
You might be on the right lines but your code won’t work....
If ( x = 1) is always true.... try ( x == 1) to test if x is equal to one. But as you are doing a bit wise and with 4, it never will be...., x can only ever be 4 or 0.
Are the LED Pixel Tape compatible with FastLed.h library, or the Adafruit Neopixel library? I'm having trouble finding a datasheet on the LEDs used in the strip.
Hi,
What is the application?
Where are the pulses coming from?
Why do you need to copy and send the pulses?
Why do you need the Arduino to do it?
What model Arduino are you using?
Pulses are from a data stream provided by external hardware. I'm working on a project with WS2812 pixels, data is sent serially and each pixel snips off its own bit of data then passes on the rest. I want to do the same and remove 'n' pixels from the data stream and then pass on the rest.
In addition I want to be able to have the Arduino do its own test program, but that's the easy bit. External switching wouldn't do what I want, as hopefully is now evident.
Its something I could do in assembler on a pic chip, but I'm much less experiences with C on the Arduino platform.
The ATmega chips have a special fast instructions to set and clear a bit in a output register. When you use the Arduino bitSet() and bitClear() macros, the compiler will translate that into the special fast instructions.
That means you are on the right track, but I think it will not work.
You could get rid of the interrupt and copy the bit continuously in the loop().
I have tried a similar thing in the past, but I think it was about maximum 100kHz.
Therefor I agree with the others that tell you to use extra hardware.
The WS2812 LEDs are probably very tolerant for timing jitter if you had this working with a pic chip.
Just wanted to correct something for you. You are declaring "byte x" twice, so your code will never work. In fact you do not need the byte at all, your "data_in" can be as simple as this:
Sorry I mean I could write the asm in PIC not that I actually have, and if clocked suitably I'm quite certain would work just fine.
External hardware would be simple - but isn't what I want to do, and I feel that it must be possible to do this running a 16mhz clock?
I'm going to try and call on some programming help from someone who knows far better than I. Since the arduino has no problem generating a WS2812b data stream, or indeed even acting as a ArtNET node, I can't really see why it should struggle to do this, which is simply copying port data across, and potentially counting and snipping 'n' bits of data that passes through it. -I'm obviously missing something, or badly failing to explain!
Thank you, but no. Essentially I'm working on a fixture. WS2812b are serial, should one LED fail, the rest after also fail. In a fixture this would mean any subsequent fixtures die also. I want to therefore remove 'n' pixels data, and pass the rest on, so that should any pixels fail (and they do, especially if your not careful in the assembly process/heat humidity etc) it doesn't kill anything further down the "chain" if you like.
BeyondHelp:
WS2812b are serial, should one LED fail, the rest after also fail.
In a fixture this would mean any subsequent fixtures die also.
I want to therefore remove 'n' pixels data, and pass the rest on, so that should any pixels fail (and they do, especially if your not careful in the assembly process/heat humidity etc) it doesn't kill anything further down the "chain" if you like.
How can you pass on any info if the pixel has failed?
Unless you also physically remove the failed pixel and bypass the DI to DO as well as modify the signal.
Tom.....