We are trying to synchronize the 4 LED lights to flash one after another, in sequence, and expose exactly one frame video each. The video will be captured at 120 Frames per second. We are trying to use the Sync Generator to keep the Camera and the Arduino in sync. I have attached a GIF I made to illustrate what we are trying to achieve.
With some help from a friendly engineer we have successfully made a circuit that allows the Arduino to power the lights. This is the very simple code that makes the lights flash in sequence at a rate that we can define:
/* A simple program to sequentially turn on and turn off 4 LEDs */
int LED1 = 13;
int LED2 = 12;
int LED3 = 11;
int LED4 = 10;
int DELAY = 8.3333;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
}
void loop() {
digitalWrite(LED1, HIGH); // turn on LED1
delay(DELAY); // wait for DELAY time
digitalWrite(LED1, LOW); // turn off LED1
digitalWrite(LED2, HIGH); // turn on LED2
delay(DELAY); // wait for DELAY time
digitalWrite(LED2, LOW); // turn off LED2
digitalWrite(LED3, HIGH); // turn on LED3
delay(DELAY); // wait for DELAY time
digitalWrite(LED3, LOW); // turn off LED3
digitalWrite(LED4, HIGH); // turn on LED4
delay(DELAY); // wait for DELAY time
digitalWrite(LED4, LOW); // turn off LED4
}
We have found this forum post that outlines how to read time-code from an XLR input. I am unsure if this post will be helpful to the code that we need. I have contacted Blackmagic Design to get some information about tri-level sync and how their Sync generator works and they told me they are not allowed to release any information about how their product works, however, they have sent 2 PDFs which I have attached to this post.
We are trying to work out how to read the tri-level sync pulse from the Sync Generator to make it drive the lights at the same rate as the camera shutter. Any help would be so appreciated.
You need to separate the sync with a comparator and feed the composite sync to a low pass filter to extract the vertical sync portion. That signal then needs to be filtered and edge detected.
I should mention we are trying to run our project on the camera with a project frame rate of 60fps or 30fps (depending on what works best with the sync generator):
From what I can tell, reading the two PDF's posted in the first topic, it looks like black-burst is only supported properly with NTSC and PAL, neither of which will be sufficient to sync with our 30FPS or 60FPS project frame rate.
I have looked at the LM1881 chip before and I think it might be inappropriate for our means. Firstly it does not look like the LM1881 chip supports Tri-Level sync detection at 30FPS since it mentions mainly NTSC (29.97fps) and PAL(25fps) support. It does mention support for "non-standard video signal", do you think the signal being produced by the Blackmagic Sync Generator would be non-standard? The Sync Generator can output either a tri-level sync or a "black burst" sync. The LM1881 has one input for "composite video" and an output for "black-burst"
I was hoping that since the Sync Generator is out-putting a clean sync pulse in either tri-level or bi-level (black burst) format, it would be a simple case of building a small circuit and reading it with the Arduino on a pin-interupt or something?
The input accepts standard analog SD/ED/HD video signals with either bi-level or tri-level sync, and the outputs provide all of the critical timing signals in CMOS logic, which swing from rail-to-rail (VCC and GND) including Composite, Horizontal, and Vertical Syncs, Burst/Back Porch Timing, Odd/Even Field, and Video Format Outputs. HSync features very low jitter on its leading (falling) edge, minimizing external circuitry needed to clean and reduce jitter in subsequent clock generation stages.
The LMH1981 automatically detects the input video format, eliminating the need for programming using a microcontroller, and applies precise 50% sync slicing to ensure accurate sync extraction at OH, even for inputs with irregular amplitude from improper termination or transmission loss. Its unique Video Format Output conveys the total horizontal line count per field as an 11-bit binary serial data stream, which can be decoded by the video system to determine the input video format and enable dynamic adjustment of system parameters, i.e.: color space or scaler conversions.
Thanks again for the reply. I have looked at that chip too. I am currently waiting to hear from Blackmagic support team to see if their sync generator would work with this chip.
Assuming that it does, what would be the next step? If that chip can extract the correct sync information and I plug it into an input on the arduino. What would I then need to do with the arduino code to make it run the lights in sync?
Blackmagic are no longer offering any support with regards to the progression of this project. They can only comment on issues with their hardware, so they are unable to comment on whether the LM1981 chip will do the job.
so they are unable to comment on whether the LM1981 chip will do the job.
Fair enough, it is an arse covering response, only to be expected.
What would I then need to do with the arduino code to make it run the lights in sync?
You would need to count the number of sync input pulses from 0 to 3 and when you get to 4 reset the count back to zero.
Do this with a state change program, an example of which is in the examples section of the Arduino's IDE
File -> Examples -> 02Digital
Then when the state changes just light the LED given by the count.
You need to sort out the hardware for driving each light as the Arduino pin can only supply 20mA which is not going to be enough. What are these lights you want to use?
Grumpy_Mike:
You would need to count the number of sync input pulses from 0 to 3 and when you get to 4 reset the count back to zero.
Do this with a state change program, an example of which is in the examples section of the Arduino's IDE
File -> Examples -> 02Digital
Then when the state changes just light the LED given by the count.
You need to sort out the hardware for driving each light as the Arduino pin can only supply 20mA which is not going to be enough. What are these lights you want to use?
If you, re-watch the GIF posted up top you'll see our set-up will actually need to operate slightly differently I think. The lights will need to change at 120Hz whereas the sync pulse is going to be either 30Hz or 60Hz (depending on what pulse speed we get from the sync generator, however 120FPS is not an option). So I think I need to count the sync pulse somehow and then make 2 or 4 lights go on/off every time. It's hard to know the best approach for this. Assuming the sync pulse is 30Hz, would I set-up a counter for the pulse that I divide by 4 and made a light toggle that amount?
Im reading over the StateChangeDetection sketch, but I'm very non-programming-minded so I find it hard to see how I would re-purpose it. I will persevere.
Assuming the sync pulse is 30Hz, would I set-up a counter for the pulse that I divide by 4 and made a light toggle that amount?
No.
It looks like you don't need an Arduino at all. What you need is a PLL ( Phased Locked Loop ) with the VCO ( voltage controlled oscillator ) part going at 120 HZ and being divided down by four before being applied to one side of the phase comparator with your recovered sync being applied to the other. Then also attach the VCO to a four bit ring counter and use that to drive your lights.
This is a bit advanced in terms of electronics but it is what you need to do. You might have to pay someone to do it for you.
aarg:
What I would like to know, is how you get sync information from the camera. Surely it does not have a 120fps sync input?
Sorry, do you mean "sync information to the camera"? That is done using the Sync Generator. I have given up trying to extract the sync information FROM the camera because I was told by the Blackmagic support team that it would be impossible to extract sync information from the video outputs on the camera. People have also speculated that even if this was possible it would be useless since it would probably have some delay or lag in the signal. So we are now trying to generate a sync signal using a Blackmagic Sync Generator which is documented in this PDF: http://documents.blackmagicdesign.com/Converters/2015-07-12/Blackmagic_Converters_Manual.pdf on page 52.
I think, similarly to this post here: Blackmagic Forum • View topic - Synchronizing URSA at high sensor frame rates what we are trying to do is sync the camera using a 30fps project frame rate and a 120fps sensor frame rate. the key thing to remember is that the camera has a "project frame rate" and a "sensor frame rate". If you look at my 2nd post on this thread you'll see a photo ive taken of my camera settings that illustrates this. I think the project frame rate can be thought of as the play-back frame rate and can be controlled by a sync generator. The sensor frame rate is separate and controls how many frames per second are actually captured by the sensor.
I am waiting for a response from Blackmagic about this, and I have yet managed to get the Sync Generator to do what I expected when plugged into the camera.
Another problem that someone has drawn my attention to is that the Delay function is not fast enough to operate with decimal points. So using a Delay value of 8.3333 does not actually work, instead I should be using "delayMicroseconds".
One thing I did notice while doing some tests was that even when the Delay value was set to 8.3333 milliseconds, which should be the correct interval of 1 frame of video at 120FPS (1 divided by 120 = 0.00833333333333) it was not reading the decimal places being an INT. I was seeing the lights ripple in and out of sync, never staying at a constant interval.
So I replaced Delay with delayMicroseconds (8333.33333333) but it is still weaves in and out of sync and does not look like the shutter and the lights are at the same interval.
I think my issue is that I am dealing with a Repeating Decimal, how can I represent this accurately?
It looks like you don't need an Arduino at all. What you need is a PLL ( Phased Locked Loop ) with the VCO ( voltage controlled oscillator ) part going at 120 HZ and being divided down by four before being applied to one side of the phase comparator with your recovered sync being applied to the other. Then also attach the VCO to a four bit ring counter and use that to drive your lights.
This is a bit advanced in terms of electronics but it is what you need to do. You might have to pay someone to do it for you.
hey mike,
this is really interesting and could be the approach that sorts out my timing issues. Would you be able to post some kind of circuit diagram for me to look at to get my head around this setup?
Grumpy_Mike:
I thought reply #6 was polite go away from Blackmagic?
Well they havent replied yet, but im hoping that since my question is in regards to their products they might comment on it. im not asking them about the LM1981 im just asking about the sync generator and the ursa mini. and they did tell me in a previous email that the sync generator would work with the ursa in 120 FPS. fingers crossed.
I think my issue is that I am dealing with a Repeating Decimal,
No. Delay will only take integers and delayMicroseconds only has a resoloution of 4uS.
You should not be using delay at all, you can not expect a crystal oscillator to stay in sync with another separate crystal oscillator, they will inevitably drift, it's a basic Physics.
Get your head round the block diagram of a PLL before you consider the circuit. It looks simple but their is a lot of design work in getting things like lock in speed to work to the spec you want. You even have your work cut out knowing what specifications you need.
I received a reply from my contact in Blackmagic support who has done some tests with off speed frame rates. They said:
I've just tested this here and the it looks like the URSA Mini does lose the Ref input when you enable the off-speed frame rate. I apologise I wasn't aware of this behaviour.
I tested two of URSA Mini cameras synced together and at 50 FPS they were perfectly synced, I then increased the frame rate to 100 fps and left the ref signal from our Sync generator plugged in, after one hour I checked the cameras and they were still in sync.
I believe this means that you should be still ok with the Sync generator, it is possible after a few hours the camera will drift and you will lose the sync.
This is very promising. It could mean that sync generator is still the correct tool to use and my next step is going to be using the LM1981 chip to extract the sync pulse and feed it into either the Arduino or some kind of PLL as mike has suggested.
aarg:
You need to separate the sync with a comparator and feed the composite sync to a low pass filter to extract the vertical sync portion. That signal then needs to be filtered and edge detected.
Would you be able to give some more information on this route? Would it require much external circuitry and once the signal from the pulse generator was read by the arduino would it be easy to program the arduino to fire the 4 lights accurately?