High Speed Photography
#1
Posted 19 April 2011 - 07:36 PM
#2
Posted 20 April 2011 - 03:40 AM
#3
Posted 20 April 2011 - 04:25 AM
#4
Posted 20 April 2011 - 05:18 AM
#5
Posted 20 April 2011 - 11:20 AM
I need a delayed trigger circuit that can 'short' the flash hot-shoe pins (to fire a strobe flash) after getting tripped by sound or something passing through a gate (like a water drop)
I'm sorry if I'm not being clear ... I will look for some more links to share on the subject.
#7
Posted 20 April 2011 - 11:47 AM
#8
Posted 20 April 2011 - 02:08 PM
The Arduino sample looks pretty good and really simple.
However, I don't think it can be performed by using a Netduino: the delay between the ADC reading and the flash trigger could be too long.
It seems to me that you need an less-than-one-millisecond response time: perhaps could be hacked in some way even with Netduino, but I guess is somewhat hard.
Cheers
Thank you for your response.
I'm not sure what ADC is there a delay between receiving a trigger from a sensor and performing a pin short? I was assuming that I'd be able to modify this delay programaticaly or through a web interface?
#9
Posted 20 April 2011 - 02:38 PM
forever { value = read myADC if (value > threshold) { activate myOUT wait a bunch of millisecs deactivate myOUT exit forever } }The program loops indefinitely within the "forever" clause, reading the ADC port until the value become grater than a threshold. That threshold is adjustable from you, of course.
As soon the threshold has reached, the output (flash) has to be activated. The successive delay is just to keep the flash activated enough (on the Arduino project is 100ms).
Finally shuts the flash off and the program ends.
This is *VERY* trivial!
Where is the problem?
The bang of a gun runs about 34cm/ms (1 foot/ms).
A board like Arduino can read the ADC, evaluate the condition and perform the output activation within a bunch of microseconds. The delay between the sensor detection (i.e. ADC read) and the flash is insignificant.
Netduino operates with managed code, much more powerful, but also much heavier. The same task can take some millisecond, but it is also uncertain and variable time by time.
One millisecond less or more is significant, because your bullet could be run over the balloon, while the flash will light with a substantial delay.
I'd choose an external circuitry or an Arduino board. That depends on your long-term goal.
Cheers
#10
Posted 20 April 2011 - 03:10 PM
#11
Posted 27 April 2011 - 11:46 AM
Netduino operates with managed code, much more powerful, but also much heavier. The same task can take some millisecond, but it is also uncertain and variable time by time.
Is there a way to test this delay between tripping a trigger and performing a pin short?
Why would the delay be variable?
#12
Posted 27 April 2011 - 12:26 PM
The simplest way is using a scope.Is there a way to test this delay between tripping a trigger and performing a pin short?
Without any instrumentation it could be difficult. Another way to test the time could be using a kind of circuit measuring the time...I think it is not so easy for who has not practice with hardware, though.
Basically there are two factors that could influence the delay:Why would the delay be variable?
- the garbage collector, that is a underlying task that flushes away the finalized objects and compact the memory also;
- the multi threading, that may break silently your function to serve some other pending.
Cheers
#13
Posted 27 April 2011 - 12:34 PM
Is there a way to test this delay between tripping a trigger and performing a pin short?
Why would the delay be variable?
Garbage Collection. If garbage collection occurs while your trying to fire it off your code would be put on hold so thus the variable. You don't know if garbage collection will occur.
Terry Massey
#14
Posted 27 April 2011 - 07:44 PM
In response to what Mario and Terry said, IMHO neither multithreading nor garbage collector is really the issue here, in this particular application both can be avoided: there is no need for multiple threads and garbage collector will not run until there are objects that go out of scope and need to be cleaned up to make room for newly allocated objects - this can be ensured with careful coding.Is there a way to test this delay between tripping a trigger and performing a pin short?
Why would the delay be variable?
The real problem is the way how .NET Micro Framework handles interrupts: they are queued and events are checked for only in between scheduling threads, this happens on Netduino every ~21 µs (frequency is 46875 Hz). Another problem is that in the current implementation of .NET Micro Framework native method calls are blocking, which means the CLR execution engine has to wait until it finishes - but in this particular application we can avoid this, if no such function is called.
The trivial case is to connect a sensor directly to a pin configured as an interrupt source. The sensor can be for example a phototransistor, or anything that outputs voltage in logic level thresholds (a passive level shifter, voltage divider, pull-up/down resistor can be easily used if needed). The application can look like the following:
using System; using System.Threading; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace NetduinoApplication1 { public class Program { private static InterruptPort sensor = new InterruptPort(Pins.GPIO_PIN_D0, false, ResistorModes.Disabled, InterruptModes.InterruptEdgeLow); private static OutputPort trigger = new OutputPort(Pins.GPIO_PIN_D1, true); public static void Main() { sensor.OnInterrupt += sensor_OnInterrupt; // Wait for the sensor interrupt Thread.Sleep(Timeout.Infinite); } static void sensor_OnInterrupt(uint pin, uint state, DateTime time) { // This is called at 'time', but a little bit later // than the interrupt really occured. trigger.Write(false); // Toggle trigger (falling edge) trigger.Write(true); } } }After the setup (the interrupt mode and trigger initial value were chosen to make measurement easier, they are not particularly important) the application waits for the sensor interrupt to occur. When it happens, sensor_OnInterrupt event handler is called and toggles trigger output pin. The handler is called 266 µs (min), resp. 278 µs (max) after the signal change occurs on the interrupt pin; see attached screenshots (measured with official firmware 4.1.1. beta 1, yellow channel 1 is sensor, cyan channel 2 is trigger pin).
So, now the question is, if such delay is acceptable in your desired scenario? And if you can compensate for it? A bullet will travel about 10 cm in ~0.3 ms.
Personal note: For this kind of application, Netduino is rather an overkill and it makes little sense to invest into overcoming one of .NET Micro Framework's weaknesses. I would go for Arduino (even though it is an overkill too, this can be done with only few components ;- )
Attached Files
- ULight.Me likes this
#15
Posted 28 April 2011 - 04:10 AM
#16
Posted 28 April 2011 - 06:40 AM
Yes, I agree with you - although it is possible to avoid garbage collecting, in practical use it makes little sense - because it is one of things to benefit the most from in a managed application.Firstly, that program has not any object going off the scope, so the GC would never work. I'd say that it is hard (better:nonsense) to write a practical application, where we must pay attention to avoid any GC'ing. So, *that* example is correct, but as soon you begin adding some function, some object would be created and destroyed.
The interrupt is handled immediately in the ISR (Interrupt Service Routine), but it just adds a callback entry to the HAL queue.Secondly, the same example is firing me a question. That is a single thread task, without any other service running, and it waits for a stupid interrupt. I am also assuming that the interrupt is natively fired (such as a MCU handler), and *not* simulated by polling some flag. So far so good. Now, why the delay is so large?
To be honest, I was expecting 21 µs too, at this time I don't have an explanation for ~12 µs jitter. The results are from many test passes, I have used 1 kHz continuous square wave signal to simulate sensor output.Assuming a certain number of tests, I was expecting a jitter of 21us (that is the slow clock period) and not 12us. Maybe 'cos you've done a couple of test only?
There is one slight inaccuracy in the original post related to time measurement - the delay between edges includes OutputPort.Write() call, the interrupt event handler is executed a little bit earlier. It takes roughly 50 µs for the interpreter to execute the method call, native pin state change function takes about 4 µs (the port register is changed at about 2 µs from the native function start) - it would require change in firmware to make precise measurement, I have not done that.Over that, CW2, we are talking of a 48MHz CPU: what the hell it is doing between the interrupt and the output falling edge???...
According to the sheet is over 10K instructions: what are these ops???
I also agree that such performance seems to be low, considering a 48 MHz 32-bit microcontroller - on the other hand, there is quite a lot of things happening in .NET Micro Framework. Unfortunately, I cannot give you a definite answer, because my knowledge is still rather limited in this area (and you would probably not appreciate a list of source files or function names :- ) I strongly believe there is a room for various performance improvements in the current .NET Micro Framework implementation, or it can be extended to support some specialized application scenarios. However, one has to keep in mind that it is not designed to be real-time system, and sometimes there is a board that fits particular need better than the other (dare to say Netduino; but $35 48 MHz switch... ...I do understand most of the projects here are to learn electronics and embedded programming, which is great and .NET MF is very good for that).
#17
Posted 28 April 2011 - 09:29 AM
It sounds to me easier to say than to do.although it is possible to avoid garbage collecting
Just modify any string and the game is over.
Some microsec is fully acceptable as "macro" for setting a port. I guess an asm port r/w could take 1-2 cycles.It takes roughly 50 µs for the interpreter to execute the method call, native pin state change function takes about 4 µs (the port register is changed at about 2 µs from the native function start)
Of sure it's me, but I really cannot believe that a "gosub surrogate" could take thousands of ops.
Is there any way to make it faster?
I don't believe the problem is Netduino itself. Chris has put a powerful MCU on a board, then glued some peripheral around. All that for a bunch of Euros. Nothing wrong on that.dare to say Netduino; but $35 48 MHz switch
I think the problem is behind the MF...I may understand that the MF team is climbing the Space Needle with nails, but they must recognize that a realistic platform could not perform decently only using a 100+ MHz chip.
Did you remember the "ancient" PC-XT @ 4.77MHz, with 640K ram???
Please, let explain me why a several thousand lines Turbo Pascal application would compile in few secs on that PC, and the MF would take a dozen of mins on a 4Gig, 2.2GHz dual-cored CPU???
Let explain me why on that old PC you may run and use complete apps, even graphical, and here a single call takes 50us???
I repeat, it's surely me, but I feel there is something off our control.
Cheers
#18
Posted 28 April 2011 - 10:09 AM
#19
Posted 28 April 2011 - 11:35 AM
There's no doubt that a one-Euro 555 would be the perfect solution for this kind of apps. The '70 were plenty of 555 circuits and we able to fly to the moon without Netduinos!I have to ask why the Netudino (or any microcontroller) is being used in a circuit like this? It doesn't appear to be the right tool to use. Surely this is a job for something like the versatile NE555?
However, there are many friends that don't know how to build even a simple circuit with a 555.
Secondly, perhaps they are attracted by this board and would build a very simple application.
Thirdly, such a context is very useful because it shows clearly some lacks of a Netduino/MF board.
Cheers
- ULight.Me likes this
#20
Posted 28 April 2011 - 01:20 PM
Hey, I bought a co-processor for one of those to make my galaxy creation simulation work in a week instead of a monthDid you remember the "ancient" PC-XT @ 4.77MHz, with 640K ram???
I'll have to learn about thoseHowever, there are many friends that don't know how to build even a simple circuit with a 555.
Yeap, that is me, simply learning .net in an interesting way (.net in all forms, normal, phone and MF, cool and having fun)Secondly, perhaps they are attracted by this board and would build a very simple application.
This is the goal of this experiment. Find out what works and what is missing, all for the ease of programming whatever we get our hands onThirdly, such a context is very useful because it shows clearly some lacks of a Netduino/MF board.
I'm looking at a 3D Printer right now and it is because I played with a netduino that I might have on in a few months
It is not a problem of our lack of knowledge about what to use when ... it is a question of finding out how we can adapt our tools to help even more
I Love This Community (ILTC)
- ULight.Me likes this
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users