Recalling delay time after first cycle

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

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Recalling delay time after first cycle

Post by Tony Brown »

I am trying to make a time lapse photography timer which triggers an ir remote for my nikon camera, it will repeats the selected time delay continously until a stop button in pressed.

My problem is I am unsure of how to make the program repeat the selected delay once the first cycle how been completed.

Anyone have any ideas.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Recalling delay time after first cycle

Post by Enamul »

Hi,

It seems that you want to use a delay timer after which an output will be created to trigger IR...but didn't mention for how long...?

This will repeat continuously..while monitoring an input i.e. a stop button..

Is that the idea..I can help you..

Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

Gary Freegard
Posts: 45
Joined: Mon Nov 07, 2011 6:36 pm
Has thanked: 1 time
Been thanked: 30 times
Contact:

Re: Recalling delay time after first cycle

Post by Gary Freegard »

Hi Tony

The attached file meets your basic requirements.
It consists of 4 macros
  • timer_update- this is the macro called by the timer interrupt, converts interrupts into seconds and then checks the seconds against target, if target reached then disable timer, pulse the output and then re enable timer.
    timer_enable- this sets the timer interrupt
    timer_disable- this disables the interrupt
    output_pulse- this puts a pulse out on port A
In main the loop checks to see if a button on port B has been pressed, if it has then stop.

The reason I disabled the timer and then enable it in the timer_update macro, is so that the the duration of the output pulse does not affect the delay period. So in this case the delay period starts once the pulse has finished. If the pulse period is to be a part of the delay then remove the two Call Macro for the timer that are above and below the Call Macro for the output_pulse.

The maximum delay is 65535 secs (18hours 12min ish)

I hope this gets you started.

Gary
Attachments
Photo_Delay.fcf
(15.39 KiB) Downloaded 405 times

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

Hi

Thanks for advice. Basically what I want is a start up screen that tells you to enter required delay time, so time duration can vary, when the selected time has been reached I want the IR device to be triggered, and then the count starts over again until the delay time has been reached again, repeating the time delay until stop is pressed.

So far I have sorted the timing out, by using tmr2 with a xtal at 4Mg I can get a cycle frequency of 50Hz. I can making it trigger, but onces its triggered I dont know how to loop back to the delay time and repeat the process.

Im new to flowcode so its hard to get my head round sometimes.

Thanks for your help

Tony

Gary Freegard
Posts: 45
Joined: Mon Nov 07, 2011 6:36 pm
Has thanked: 1 time
Been thanked: 30 times
Contact:

Re: Recalling delay time after first cycle

Post by Gary Freegard »

Hi Tony

If you post what you have already got then it shounldn't take too long to alter.

Gary

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

Hi Gary

I have just been trying to get the flowcode file that you included to work on flowcode 5 but it seems not to be working, does it work on your version of flowcode?

Regards

Tony

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Recalling delay time after first cycle

Post by Enamul »

HI,

I have modified Gary's code so that you can set delay time using 3 buttons "UP", "DOWN" and "OK". In LCD you will be able to see the setting option at start up. After setting, display will show timing start indication and time run indication..when reached at set time display will indicate IR trigger which will output trigger at RA0 for 1 s but you can change according to your requirement..
Then the time will start again and keep repeating the process until you press the button "STOP". If you pressed stop, display will show that and program will stop forever...if you want to restart the process you have to ON & OFF the power..or you can use reset button in MCLR of PIC which help you to reset the program...

Hope this will help..if you are not clear about anything don't hesitate to ask me..

Enamul
Attachments
Photo_Delay.fcf
(25.92 KiB) Downloaded 399 times
Enamul
University of Nottingham
enamul4mm@gmail.com

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: Recalling delay time after first cycle

Post by medelec35 »

Hi Tony,
I have some questions.
What target device are you using? Im assuming you would like to stick with 4MHz?
How would you like to enter/change delay period and start/stop triggering e.g via up/down switches or keypad?
In addition to manually stopping auto trigger would you also like option to automatically stop after so many triggers. E.g
enter 100 to stop after 100 triggers, or enter 0 to only stop after pressing stop button.

Finally what is the idea on pulse duration (in milliseconds or microseconds) to guarantee reliable triggering?
Martin

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

That sounds good, I was going to use push buttons to select the time delay and any other function I wanted to include in the program. I want the final program to fire an ir remote ( I bought an ir remote so I could take it apart and use for this project), and I could also have a manual trigger too like you suggested. I selected 4Mhz as I was going to us one of the pics internal frequencies. Can you answer this question for me, what is more accurate the internal clock or an external xtal.

Thanks in advance.

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: Recalling delay time after first cycle

Post by medelec35 »

Hi Tony.
Tony Brown wrote:what is more accurate the internal clock or an external xtal.
Thanks in advance.
By far the crystal is more accurate than resonator or internal osc.

I found this on the Web:
It is a matter of accuracy and intended application. The built-in oscillator has three limitations: a) it can only work at 8 MHz, b) it is only accurate to about 1-2%, and c) it varies with temperature.

A resonator is better, with 0.5% typical accuracy, while a quartz crystal is 0.01% accurate. If you are keeping time, for example, that's the difference between being off by 3.6 hours at the end of one month, or being off by 4 minutes.
You may of course have more choices then just 8MHz internal osc

For your application, since it's not a flowchart for a clock, then you may find internal oscillator will be good enough.
The advantage being component count is reduced.

Or a resonator could be used. these are cheaper than crystals, and the caps are built in so these are not required.


There was a spelling mistake in one of my questions
medelec35 wrote: Finally what is the idea on pulse duration (in milliseconds or microseconds) to guarantee reliable triggering?
Should have been Finally what is the ideal on pulse duration (in milliseconds or microseconds) to guarantee reliable triggering?

This is also important,
Too fast and will not have time to trigger flash or too slow... Well you know what problem that will cause :P

The 4MHz xtal will be good enough. Using timer2 we should be able to get the accuracy required.

Reason for having say 19660800 crystal is:
1) Faster speeds enable you to do more things withing your code during non servicing of interrupts.
2) Timer frequencies are more accurate since they divide exactly. E.g 75.000Hz & 300.000Hz etc.
Martin

Gary Freegard
Posts: 45
Joined: Mon Nov 07, 2011 6:36 pm
Has thanked: 1 time
Been thanked: 30 times
Contact:

Re: Recalling delay time after first cycle

Post by Gary Freegard »

Hi Tony

The example I sent was working, not sure why it isn't now, but it was to show you the basic continuous timer from which you could build on.

I have used Flowcode and E-Blocks to create a camera trigger, but this was to capture pictures of water (aswell as wine and beer) drops/splashes.
wine_small.jpg
wine_small.jpg (11.9 KiB) Viewed 16079 times
This required the use of a photogate to detect the drop which started the timer, then at a set millisec interval (this was adjustable) the camera was triggered, using a 40 millisec pulse.

Gary

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

Hi Gary your pic looks pretty good :-)

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: Recalling delay time after first cycle

Post by medelec35 »

Hello Tony,
I have added some additional features to V2.
These are:
When power is first applied, if timer has been set then values will be retained.
Added functions Stop, Go, Set New delay (so no need to interrupt supply to enter new delay time) &
Take Picture.
Delay timer V3.png
(26.89 KiB) Downloaded 9016 times
Martin
Attachments
Delay timer V3 .fcf
(48.35 KiB) Downloaded 350 times
Martin

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

Hi Martin

Thats BRILLIANT just what I wanted, THANKYOU very much for all your time and effort.

Many Thanks

Tony

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: Recalling delay time after first cycle

Post by medelec35 »

Hello Tony,

Your welcome.

I have had a thought.
What about if the go key is also used for decrementing time in time adjust mode if long press and start timing if short press?
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: Recalling delay time after first cycle

Post by medelec35 »

Hi Tony,

I had a few mins spare today.
So here is V4!
Time lapse V4.png
(30.67 KiB) Downloaded 8972 times
I have added an up/down feature.
If you have 10 seconds, and you want 9 seconds, then insted of going 10, 11....... 59, 01 etc.
If you hold Go key in until display changes from Up to Down then just need to press seconds key once.
Not sure if Got timing of short and long press right, so its best tested with your hardware.

Martin
Attachments
Delay timer V4.fcf
(54.94 KiB) Downloaded 311 times
Martin

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

Hi Martin

Sorry for delay in responding, just thought I would let you know that I have built the circuit and the program works perfect, cant wait to try it now :-) .

Thanks again for your help.

Tony

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

Does anyone know how to connect the cs lines of a glcd to the pic. I have a 128 x 64 glcd and I am unsure how to connect to,
its not as easy as a standard 16 x 2 lcd.

Thanks

User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times
Contact:

Re: Recalling delay time after first cycle

Post by ionize »

I really like this flowchart (Martin's V4) and I've been trying to wrap my head around all that it is teaching me. I've been trying to figure out how to start the program automatically upon power up after the initial programming and be able to adjust the output trigger time, if possible, from the tac switches and to top it off, how bout a second output (I just thought of that). So far, no success. The only alteration I have done is to use a 16F690 over the 16F88 'cause that's what I have on hand at the moment. Any takers?
Thanks,
Scott

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: Recalling delay time after first cycle

Post by medelec35 »

Hi Scott,
I will modify Flowchart for you, when I get home tonight.
I'm sure we can get it to work the way you would like it to.

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: Recalling delay time after first cycle

Post by medelec35 »

Hi Scott,
I have modified Flowchart, so it will start timing when power is first applied but only if the hours, minutes or seconds has been set up 1st.

I have set it to run on 16F690 with internal osc.

The only issue I can see is if your running a free version of Flowcode.

The hours, minutes and seconds are stored in EEPROM since stored in non volatile memory, values will be retain when power is removed).
Flowcode free does not support EEPROM.

One way round this is to set variables Hours, Mins & Secs with required elapsed time.

Hope this helps

Martin
Attachments
Delay timer V4 Modified1.fcf
(55.83 KiB) Downloaded 280 times
Martin

User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times
Contact:

Re: Recalling delay time after first cycle

Post by ionize »

Thanks Martin :D
I built a similar device using 555's a long time ago and it worked well but this is much more elegant!
Yes, I'm running Flowcode V5 Professional. Sorry for a delayed reply, my internet connection broke down for several hours. (good ole reliable Qwest/ Century Link-NOT)
The C code at the start: isn't that setting the clock speed? I thought you do that in Build/Project Options chip setup. its not on any other of the versions posted.
Works perfectly on my machine. I will build it today and try it tonight.
Scott

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: Recalling delay time after first cycle

Post by medelec35 »

ionize wrote: The C code at the start: isn't that setting the clock speed? I thought you do that in Build/Project Options chip setup. its not on any other of the versions posted.
Works perfectly on my machine.
You are correct in stating osccon is the clock speed setting.

Some target devices default to 1MHz for example 18F4455 which I was using prior to altering Flowchart for you.

The setting osccon to 110 was a very last minute thing.

I set it just in case.

I have had a look at data sheet for 16F690, and it does look like it will work at 4MHz without osccon C component.

So it can be left out.

I personally use the osccon as a matter of habit. :)
Martin

Tony Brown
Posts: 81
Joined: Wed Jun 20, 2012 9:59 pm
Has thanked: 36 times
Been thanked: 5 times
Contact:

Re: Recalling delay time after first cycle

Post by Tony Brown »

Finally had a go at building one of these and have found that if I set the seconds to say 3 seconds delay, the countdown begins, and for about 20 or so cycle (random) the display will read 3210, 3210,3210,321,3210. The trigger still works its just the display that is not working correctly.

Any idea's

Thanks

Tony

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: Recalling delay time after first cycle

Post by medelec35 »

Hi Tony,
What I can do is test V4 using a simulator, then test on hardware when I get home tonight.
Can you post the actual Flowchart that you used please and the hex file it produced.
Only issue I can spot so far is LED should not be connected port A5, as that would be an input only.

You could have a LCD signal corruption issue?
How long is run between LCD and PCB?

Martin
Martin

Post Reply