Reaction & Detection Times

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Reaction & Detection Times

Post by JDR04 »

Could somebody take a look at my flowchart and tell me how I can improve the trigger reaction time please.

I used a scope to measure from the rising edge of the signal in to the rising edge of the trigger signal out. I took about 10 measurements and then got an avarage delay time 860ms. Can this be improved?

I've also noticed that the signal in has to have a duty of at least 440ms for the trigger signal out reacts. I was hoping for much quicker reaction and detection times but maybe I've done something wrong in my flowchart??

I have attached the flowchart for you guys to check out.

Once again, appreciate your guys time to help me on this............John
Attachments
IRTRIGGER.fcf
(14.5 KiB) Downloaded 302 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
Not got time to have a good look at your flowchart.
But what I did notice is the clock speed (4MHz) in project options don't match the osccon setting (0x70 = 8MHz)
Since osccon is forcing internal osc of 16F690 to run at 8MHz, you will need to change the clock speed from 4MHz to 8 MHz

I take a better look this evening an see if i can help or not.
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Thanks Martin...standing by...............

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
Can you give me ideal max and min times in milliseconds for each of the three delay please?

Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Ideal maximum settings would be

Trigger delay = 5 seconds
Trigger ON Period =10
Trigger Lockout = 60

Ideal minimum settings would be

Trigger Delay =0 seconds
Trigger ON Period =1ms
Trigger lockout =1ms

If it would be advisable to upgrade the chip I'm open to your suggestions.

Thanks a lot for your time........John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

What I was thinking of is pot readings takes a certain time.
Therefore the pot reading can be done when the switch is in the off position.
With switch in the on position, then wait for trigger using wait until high component macro.
Then min delay could be just a few microseconds.
Won't know exactly until flowchart modified then simulated.

Does that sound more ideal?

Martin
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

JDR04 wrote:deal maximum settings would be
Trigger delay = 5 seconds
Trigger ON Period =10
Trigger Lockout = 60
Just confirming is that
Trigger ON Period =10ms
Trigger Lockout = 60ms
?
What about the resolution?
100us
1ms
10ms
etc
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Hi Martin, sorry for not being clearer.

The ideal trigger delay period would be 0 to 5 seconds
The ideal trigger ON period would be 1millisecond to 10 seconds
The ideal lockout period would be 0 to 60 seconds.

If you are asking if the pot settings can be made before the circuit is switched on then that's fine, no problem at all.

I dont know what you mean by resolution. I'm assuming that it means how accurately the settings can be made, if that is the case, as accurately as possible would be nice.

Hope this helps, and thanks again for your time.....John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
No problem.

can you try the attached flowchart please.
Another reason for the extra delay time in your flowchart was the setting of the debounce time.
If you look at the switch Ext properties you will see Debounce (ms) this is the minimum time that has to elapse before pin connect to the switch is re-checked, but only with the switch macros i.e ReadState, WaituntillHigh & WaituntillHigh
I have changed your debounce from 100ms to 0 ms since action is required from very first transition from low to high.

The resolution (delay time steps) are:
Trigger Delay = 5ms (0s to 5.1s)
On Delay = 10ms (1ms to 10.2s)
Trigger Inhibit Duration = 60ms (0s to 61.4s)

By all means have a play, but I'm unable to test until tonight.
So no guarantees it will work.

Martin
Attachments
IRTRIGGER 1.1.fcf
(14.5 KiB) Downloaded 301 times
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Thanks Martin, I'll have a play around for a day or two and get back to you.

Thanks so much for all you have done.......John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
No problem.
Unfortunately I don't have the hardware to replicate your setup.
How did the testing go?
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Hi Martin, did some testing with the scope. The reaction times are absolutely unreal. Better than I expected. I did a little program with a 12F683 where I can inject a trigger signal where I can inject a singal signal with adjustable duty. I have have been using this to help with the measurements.

I'm still going through your flowchart to try and understand it. I'd rather do it this way if its ok with you so I can try and figure out what you have done as far as possible. What I have noticed so far is that the three time settings are all to.............I was using the scope to do the measurements but will do some more and then repost for your help if you dont mind.

Thanks a million......John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John
JDR04 wrote:The reaction times are absolutely unreal. Better than I expected.
No problem.
Glad it's better than expected. :)
Reaction time can be increased a bit more even with ADC's active with the switch in the on position.
The idea is to using int interrupt, and set output high within the interrupt service routine it'self
Then it does not matter if ADC's are being read, since the output is already high.

Not sure what you mean by
JDR04 wrote:What I have noticed so far is that the three time settings are all to.............
Don't know if that's good or bad :lol:
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Hi Martin, did a few more checks on the timing control and so far.........

Trigger ON period....... seems to be fixed at about 32 seconds at minimum and 34 seconds at maximum.
Trigger inhibit period...... seems to be fixed at about 44 seconds.

I checked the voltages at the pins for all three pots and there is definately a change from 0 volts to 5 volts when I adjust the pots so I know the pots arent faulty.

Any thoughts????????

Thanks a lot........John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
JDR04 wrote:Trigger ON period....... seems to be fixed at about 32 seconds at minimum and 34 seconds at maximum.
Trigger inhibit period...... seems to be fixed at about 44 seconds.
I have already got a 16F690 set up so I just connected An0, An1 & An2 to 0V for all minimum duration.
Here are the results on my hardware in real time:
Trigger Results.png
(144.54 KiB) Downloaded 3384 times
The Green ring is showing the time difference between 1st pressing the switch (Digital 5) and output (Digital 2 responding) which is 23.875 us.
As you can see I pressed the switch 500ms later (purple colour), and the output (Trigger on) went high again.
The on duration lasted for 1.021ms (Red line)

If the inhibit lasted for longer than 500ms, the output would have not re-triggered.
So it look likes hardware is working as intended.

Tomorrow I will connect 3 pots up and vary them to see if HW is still working as expected.

Martin
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi
I have set all three ADC to random voltages.
If you would like to set yours to the same voltage levels then we can compare results.
I’m using EB006 programming Eblock so my VDD is a little lower than 5V its 4.74V
Probably because I’m running the programming board via USB for convenience.
VAn0 = 1.86V
VAn1=2.23V
VAn3=0.47V
Since VDD is 4.74V I have used that value for my calculations:
Trigger Delay = 1023/4.74*1.86*5 = approx. 2007 ms
On Duration = 1023/4.74*2.32*10+1 approx. 5008 ms
Inhibit Delay = 1023/4.74*0.47*60 approx. 6086 ms
Below are the actual timings on hardware:
As you can see actual times are:
IR Trigger Test2 setting ADC.png
(131.47 KiB) Downloaded 8020 times
Trigger Delay = 2001 ms
On Duration = 5002 ms
Inhibit Delay not measured
Not that far from calculated values at all.

Also tested UInt variable ms delays and with variable set at 60000.
60 seconds duration has been tested and confirmed.

When you do some more testing, Can you post results along with volatages on AN0, An1 & An2
Also a circuit diagram showing all the pin connections may help

Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Thanks Martin, I'll get that done and repost my results.....Cheers and thanks a ton.John

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Hello Martin, here are my test results. I have also included a schematic as to how I wired up my circuit. Maybe something wrong there???

Settings

Set VDD at 4.738

AN0 at 1.88V
AN1 at 2.24V
AN2 at 0.48V

Input pulse at 100ms duty

Results

Trigger ON period 32 seconds
Trigger Inhibit 42 seconds

Must be something I've done with my circuit as the results are wildly different from yours. I used your flowchart to program the chip. Also tried two different chips but same result.

Just so you are aware.......I've removed the GREEN LED from the flowchart as it wasnt really needed.

Thanks again........John
Attachments
Trigger 2 sch.jpg
Trigger 2 sch.jpg (22.61 KiB) Viewed 12971 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
Looking at your circuit I can see the issue.
The ADC values are read only when A5 is at 0V since you have a switch on your flowchart.
On your hardware it looks like A5 hard wired to +5V!
Therefore ADC Values are never read, so the varaible will just contain a permanent random number
I did state:
medelec35 wrote:What I was thinking of is pot readings takes a certain time.
Therefore the pot reading can be done when the switch is in the off position.
i can change the flowchart if you did not want a switch?

What you can do it pull A5 high with a 10K resistor.Short A5 to 0V, set pots then remove short.

Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Your right again......... The slide switch I had in the flowchart was just to simulate the input signal.

I'll redraw the schematic and repost tomorrow. Are you saying we should get rid of the slide switch? If yes then how will we simulate a trigger signal??

Anyway, thanks again, will post schematic tomorrow. I meant to also tell you that the reaction times I got were just about bang on to what you got. Really pleased with that outcome.

Take care......John

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
Glad you have got it to work :)
JDR04 wrote:Are you saying we should get rid of the slide switch? If yes then how will we simulate a trigger signal??
No, not saying that.
What I'm saying is either the on/standby switch should be present on your hardware (Which i though it was)
Or
If you're not having the switch on hardware, then flowchart will need to be modified accordingly.
That is a call for you to make.

The trigger switch is kept on the flowchart no matter what, as that is required for simulation purposes only

Martin.
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Hi Martin, having reread your last post I think I misunderstood what you meant.

Am I understanding this properly, to set any of the pots, the switch A5 needs to be first shorted to ground. Then once the pots are set, remove short and operate circuit?

If possible, I'd prefer not to do that as it seems a bit clumsy having to fiddle with a switch each time I need to change the pot settings. The only reason I have the switch is to prevent me having to keep removing the batteries. So, in summary, can we avoid having to use a switch each time I need to change a pot setting?

I'm also keen to know if the power on pin 1(VDD) can be read instead of it being connected to pin 2 via pin1? Effectively the way I have done it means pins 1(VDD) and pin 2 (RA5) are shorted together.

Is it possible to avoid this at all?

Thanks again.....John

PS. I will however through the course of the day experiment with it the way you suggested.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Reaction & Detection Times

Post by medelec35 »

Hi John,
JDR04 wrote:If possible, I'd prefer not to do that as it seems a bit clumsy having to fiddle with a switch each time I need to change the pot settings. The only reason I have the switch is to prevent me having to keep removing the batteries. So, in summary, can we avoid having to use a switch each time I need to change a pot setting?
In light of this, I have changed your flowchart.
With This Flowchart you just require a Switch in series with batteries and PCB.
No connections to A5 are necessary.
When you apply power to PCB then the pots are read.
They are constantly read until trigger is detected.
To help reduce reaction time I have use an interrupt on change.
Whilst in triggered state, pots are no longer read until triggered state has ended.

During compiling you will get this message:

Code: Select all

IRTRIGGER 1.2.c(966): WARNING: This interrupt has previously been enabled, so the macro <IOCDetected> may never get called.
That is not an issue at all.
Circuit will not be affected in any way and message can be ignored.

Martin
Attachments
IRTRIGGER 1.2.fcf
(18.88 KiB) Downloaded 204 times
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Hi Martin, I have redrawn the schematic to what I think I understand from your suggestion.

The schematic is attached and would appreciate your comments.

Thanks again....John
Attachments
Trigger 2c.jpg
Trigger 2c.jpg (26.42 KiB) Viewed 12939 times

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Reaction & Detection Times

Post by JDR04 »

Thanks Martin, youre ahead of me,didnt see your latest post. Thanks again. Will try the new flowchart out and let you know.

Once again thanks very much.......John

Post Reply