Page 1 of 1
Timer 2 Tutorial
Posted: Sun Apr 02, 2017 9:00 am
by Steve001
Morning All
Is there a tutorial for setting and using timer 2 ?
have found a few posts on here and excel sheet etc but these not making sense
wanting to set on Eico modules
Steve
Re: Timer 2 Tutorial
Posted: Sun Apr 02, 2017 1:28 pm
by medelec35
Hi Steve,
Lest assume your are after a 1000Hz interrupt frequency.
1) Run flowchart and add the timer interrupt, select timer 2, then select properties.
2) Download the great timer app from
here.
3) After extracting and running app Select
More check box, just in case the exact frequency is not possible.
4) Enter the Oscillator speed, in the case 48000000
5) On flowchart interrupt properties select the Prescaler rate drop-down and see if maximum is 1:16 or 1:64 then select the maximum correct prescaler on the timer app.
In the case of ECIO 1:16.
6) Enter the target frequency of 1000 on the time app then select Do it!
7)The settings you should set timer 2 (I have highlighted) to are then displayed in the app Results window:
Enter then within flowchart timer 2 properties:
Hope this helps.
Martin
Re: Timer 2 Tutorial
Posted: Sun Apr 02, 2017 2:09 pm
by Steve001
cheers martin will have a go and see how i get on
Steve
Re: Timer 2 Tutorial
Posted: Mon Apr 03, 2017 7:42 am
by medelec35
Your welcome Steve.
Out of curiosity, do you have an interrupt frequency in mind?
Re: Timer 2 Tutorial
Posted: Mon Apr 03, 2017 12:37 pm
by Steve001
not got a clue to be honest was going to try 1000Hz like you said and see if it works correctly - maybe not the correct way to go
wanting to generate an internal event at 20msec's
Steve
Re: Timer 2 Tutorial
Posted: Mon Apr 03, 2017 2:29 pm
by medelec35
Steve001 wrote:wanting to generate an internal event at 20msec's
That would be one way to go.
All you do is place count variable that increments by one within the interrupt macro.
E.e
then have a decision branch
Code: Select all
If Count = 20 then count = 0 : Do whatever as another 20ms has elapsed since last here e.g. toggle an output.
How I derived 20 was 1000/50 = 20
The 1000 = interrupt frequency.
50 = 1/required time period = 1/20E-3
Martin
Re: Timer 2 Tutorial
Posted: Mon Apr 03, 2017 5:35 pm
by Steve001
Thanks martin
bit more clear now thank you for explaining
trying to finish some ongoing projects after erm cough months
Steve
Re: Timer 2 Tutorial
Posted: Sat May 06, 2017 4:29 pm
by Steve001
attached test file not behaving as expected runs at warp factor 10
not sure what is wrong was hoping A0 to be 50Hz and A5 to be 1Hz, have 506 and 102 admittedly not checked on a scope found my lead to be iffy
used Hz on my fluke
Steve
Re: Timer 2 Tutorial
Posted: Sat May 06, 2017 7:24 pm
by medelec35
One way is attached.
Hopefully only thrusters are engaged this time.
Martin
Re: Timer 2 Tutorial
Posted: Sat May 06, 2017 9:12 pm
by Steve001
cheers martin
simulation looking better will try on hardware tomorrow
what does this do ?
Code: Select all
(int_count1Hz = 0) || (int_count1Hz = 100)
Steve
Re: Timer 2 Tutorial
Posted: Sat May 06, 2017 9:16 pm
by medelec35
Hi Steve,
Mentioned
in
this post
Martin
Re: Timer 2 Tutorial
Posted: Sun May 07, 2017 4:21 pm
by Steve001
working thank you martin
Steve
Re: Timer 2 Tutorial
Posted: Sun May 07, 2017 10:16 pm
by medelec35
Hi Steve,
Glad its working for you.
Thanks for the update
Martin