hi.
I am new to Pi. What I want to do is making a delay function of 50ns in python or C. I have not written a single code for in python till now.
Please tell me if its possible or not.Should I over-clock the Pi to get that delay?
hi.
I am new to Pi. What I want to do is making a delay function of 50ns in python or C. I have not written a single code for in python till now.
Please tell me if its possible or not.Should I over-clock the Pi to get that delay?
Ah! Please find anther project. This one is not for you.
If you call "usleep (50)" you will get a delay of 50 microseconds, or more. Chances are you'll get 1 or 10 miliseconds.
If you are asking these questions, your project should be to make fancy colours on 1, 2, or 3 of these led strips in series, with the library you will find if you google for a few seconds.
On not-RT kernels that kind of delay functions are hardly that accurate.
Is easier to get that timing on an Atmega or any other 8 bits IC than in interpreted language on a full fledged OS running a non RT kernel.
The reason is easy, in the Atmega you have every clock cycle at your disposal to make whatever signal you need. The limits are on the clock source and you have to be sure how many clock cycles your instructions needs.
On a full fledged OS interrupts from other processes / hardware can delay your signal so you wont get an accurate delay function.
You can also, disable most hardware, build a RT kernel, and make a kernel module to try to get close to that accuracy, but I would settle for an external IC doing just that signal for you and communicate with that IC via I2C /TWI or other means to drive it from your raspberry.
I would even think on getting an Arm Cortex M0 like the ATSAM D20 to drive it at 54Mhz to have a little more flexibility, or a Teensy board with an MK20 Cortex M4 that runs at 72Mhz.
I see here folk offering you advice on a 50 uS delay saying you can use an Arduino etc how ever you are asking for a 50ns delay this is like 1000 times shorter.
Are you sure you require 50ns?? If so then the other solutions simply won't do as 50 ns is actually less than 1 clock period on say an Arduino 
If you need to do some computation on an input and get an out put in say 50 ns then I would suggest a controller with a clock speed of several 100's of MHZ to have
a chance of getting the job done. I would actually suggest you get an XMOS Startkit from E14/Farnell and then you will get your 50ns quite easily !
With regards to doing this with RPI as folk have alluded to it may be possible in assembler to get the right delay but because you are using a non realtime O/S your code will be randomly interupted by that OS so your delays can easily be way off. To be honest you need to tell the community more about what you are trying to do to get better answers.
You are right I did not saw he was talking about nano-seconds.
There is no Atmega capable of running even near to that speed.
The project he is into is this one Raspberry Pi with WS2812b strips
This was what got me confused because for that project he was talking about a refresh rate of 50Hz, so I did not digged further on what he was trying to do.
I don't know how he somewhat got into this math he would need a signal in the nanoseconds range.
Anyway there is also the problem of the 1080Amps/5.4KW Peter calculated was required to drive his project, so I guess he will need to go for some good hardware to have a 1080Amps of current pulsing with a signal in the nanoseconds range.
In that kind of timing even the signal velocity must be taken into account, because the signal would need some time to get to the end of the 300 meters of led strips.
So I'm sorry, but I got utterly confused with this project.
May be that confusion came from the Adafruit page for those led strips.
http://www.adafruit.com/products/1138
- Second, to get high density, the controller chip is inside the LED, which is kind of cool, but also means that the chip only uses a single pin for input and a single pin for output. The protocol used is very very timing-specific and can only be controlled by microcontrollers with highly repeatable 100nS timing precision. We have example code for using with the Arduino Uno/Mega microcontroller at 8MHz and 16MHz, but it will not work with the Raspberry Pi, Basic Stamp, NETduino, any other interpreted/virtual machine microprocessor or any processor slower than 8 MHz. For those processors, check our 32 LED/meter digital LED strip which has SPI-like input/output and works well with Pi, NETduino, and other processors.
I guess they got the unit wrong because I would like to see that library with an 8Mhz device, giving a clock signal of 1/100,000,000,000 sec.
... or may be I am getting it all wrong again ... bed time I guess.
Um are we having some type of language fail here. Many of those strips are like 60 LEDs per M and 5 M long giving 300 LEDs per strip.
So the question here is he driving a number of "300 LED long Strips" or 300x strips !!
I find strips like this tend to take 1-2Amps per Metre depending on the colour and Brightness etc so each strip can be 5-10A quite easily.
Unfortunately we are seeing more and more project ideas with poorly fleshed out specs so the advice is equally vague or poor.
Can Parag explain his project and give exact numbers
Hi folks.
Many of you guys are still confused with my specification. So Here are they in detail:-
I am trying to make a screen of resolution 180X100.
So total number of leds = 18000
At maximum brightness each led can consume 50mA of current.
Maximum current consumption = 18000x0.05 = 900A
Maximum power consumption = 18000x0.05x5 = 4.5KW
the screen size would be 3m by 1.33m.
Strips (of length 3m) are connected horizontally in series. Power as well as the signal would also be carried horizontally.
The data of pixel values to be written on screen would be provided serially from another system.
And that is where the problem in my system lies.
I have a total of 18000 leds. 3 bytes are required for each pixel. One frame requires a data of 54Kb. The refresh rate that would properly stream a video, is 25Hz.
So on serial communication I would require a speed of 1.35Mbps. Maximum speed with any serial comm is 115200 i.e. 14.0625Kbps.
Previously I tried with Teensy3.1 and arduino Mega. Both have the above limitation.
That is the reason that I want to switch these boards with Pi.
Following is a site were I found something related to "How to patch linux kernel with rt kernel?"
https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO
Let me know would it work with Pi or not.
@John Alexander: I did not misunderstand the 50ns versus 50us. I tried to make clear that asking for 50us (1000 times longer than in the question) will already give you wildly inaccurate results.
There are now two threads about this. Confusing! On another forum I frequent the moderators would close one thread and point everybody to the other thread.
[When people ignore enough advice given: I switch to "answering the questions" mode. As opposed to "trying to help".]
Let me know would it work with Pi or not.
Yes. It will work with pi. Not with /your/ raspberry pi though.
To write 1 to led strip you have to set data in high for 800ns and then low for 450ns.
To write 0 to led strip you have to set data in high for 400ns and then low for 850ns.
As you can see both values are in steps of 50ns. So if I am able to generate delay function in multiples of 50ns, then
if(data_write == '1')
{
pin = HIGH;
delaynano(800);
pin = low;
delaynano(450);
}
if(data_write == '0')
{
pin = HIGH;
delaynano(400);
pin = low;
delaynano(850);
}
This would be much more simple.
I would write:
pin = HIGH
delay_nano (400);
if (data) {delay_nano (400);pin = LOW;}
else {pin = LOW;delay_nano (400);}
delay_nano (400);
However, this way your CPU will be 100% busy during the sending of the data. There is no way you can handle more than one chain at a time. Any interrupt will corrupt one or more bits. As I said, this is in no way going to help you finish your project.
You are setting your goals too far. "I want to build a rocket and go to the moon" is a project they achieve in comic books or in movies. Not in real life.
For /you/ a nice project is to make fancy patterns on five of these led strips in series. Then 6*3=18 strips in series. (that's 1/16th of your big screen!)
If you want you can see that as "necessary steps towards the big display".