Dual Timer

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Dual Timer

Post by armagon29 »

Dear All:

I need some help with this projects I which to build a double timer with LCD this means pic will control 2 timer who Works in sequence, the minutes and seconds can be adjusted by the user
Example
Timer A 10:30 (10 minutes and 30 seconds
Timer B 5:15 (5 minutes and 15 seconds)

Timer A count down to zero , when the count is 0 Timer A rest to 10:30 (original time A) and Timer B start to count down, when the Timer B count 0 Timer B reset to 5:15 (original time B) and this sequence can be stopped by the user
Timer A 10:30 β†’ 00:00
↓
Timer B 5:15 β†’ 00:00
↓
Timer A 10:30 β†’ 00:00
↓
Timer B 5:15 β†’ 00:00
↓
Sequence can be stop when the user wants and If is posible to the user adjust the loops (how many loops the secuence have)

I don’t have experience with Time interruption and Clock routines, Can some one help me please

Thanks

Note:
I have e-blocks : switch, LCD, and relay board, I which to use them¡¡¡

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dual Timer

Post by Benj »

Hello

Which programming software/compiler are you using?

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

Flowcode Ver3Β΅

Thanks

Armagon

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

And EB006-00-5 E-Block Multiprogrammer

Thanks

Armando

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dual Timer

Post by Benj »

Hello

Using the digital clock example you should be able to catch when the the seconds and minutes variables and correct for you timing, then reset the variables and allow them to count up again.

The digital clock example is available from "Prog Files/Matrix Multimedia/FlowcodeV3/Examples"

TUT_01.FCF - RC - Lighting an LED, using output icons and LED hardware macro icons.
TUT_02.FCF - RC - Outputting a value to a port.
TUT_03.FCF - RC - Controlling single output pins.
TUT_04.FCF - RC - Assigning a value to a variable and outputting to a port.
TUT_05.FCF - RC - Reusing variables and outputting to a port.
TUT_06.FCF - XTAL - Reading a switch input and outputting to an LED.
TUT_07.FCF - XTAL - Use of 'AND' masking on a variable.
TUT_08.FCF - XTAL - Inputs with masking.
TUT_09.FCF - RC - Counting in binary.
TUT_10.FCF - XTAL - Counting in binary using delays.
TUT_11.FCF - XTAL - Automatic counting loop structure.
TUT_12.FCF - XTAL - Binary multiplication.
TUT_13.FCF - XTAL - Binary multiplication with overflow.
TUT_14.FCF - XTAL - Bit shifting with overflow.
TUT_15.FCF - XTAL - Bit shifting "Knight Rider" effect.
TUT_16.FCF - XTAL - "Knight Rider" effect using connection points.
TUT_17.FCF - XTAL - Displaying a number on a 7-segment display.
TUT_18.FCF - XTAL - Counting 0 - 9 on a 7-segment display using loops.
TUT_19.FCF - XTAL - 1 second timer0 interrupt example using 7-segment display.
TUT_20.FCF - XTAL - 4 digit counter using timer 0.
TUT_21.FCF - XTAL - Printing a message to an LCD.
TUT_22.FCF - XTAL - Digital clock using LCD and timer 0.
TUT_23.FCF - XTAL - Binary counter using INT input pin Interrupt
TUT_24.FCF - XTAL - Generating an audio tone.
TUT_25.FCF - XTAL - Use of embedded C and Assembler code.
TUT_26.FCF - XTAL - Sampling an ADC channel and outputting to an LCD.
TUT_27.FCF - XTAL - Calulations and use of 'AND', 'OR', 'MOD', 'NOT' and 'XOR' operations.
TUT_28.FCF - XTAL - Use of switch component hardware macros.
TUT_29.FCF - XTAL - String manipulation reversing a string.
TUT_30.FCF - XTAL - Automatic string reversal.
TUT_31.FCF - XTAL - String input via switches and LCD.
TUT_32.FCF - XTAL - Password input with allow or deny.
TUT_33.FCF - XTAL - Including external C functions.
TUT_34.FCF - XTAL - Including supplementary code C functions.

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

Dear All:

Thanks for your help, but I look in to example but it still a Little confused for my, I don’t have Idea how to set the time by the user using e-block switch, and then make to count down in 2 clocks?

Thanks again

Armagon

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

Re: Dual Timer

Post by medelec35 »

I have created a dual stop watch with V4
See: http://www.matrixmultimedia.com/mmforum ... 30&p=14586
Although there are two times. one on upper part of 2x16 LCD and one on lower part of LCD. They can be poled so both stopwatches could count independently at thesame time. only difference is you won't' need the 100's second.
I could help you to create V3. The secret in making it work is using a Variable set for array[2]
To help you on your way, I will post a screen shot when get some time today.
Martin

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

Dear sir:

Thanks a lot I waiting for you example

Armagon

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

Re: Dual Timer

Post by medelec35 »

Here as promised:
Attachments
Stopwatch4.FCF Macro - DISPLAYTIME1.JPG
(233.36 KiB) Downloaded 4911 times
LCD Display Stopwatch.JPG
LCD Display Stopwatch.JPG (10.75 KiB) Viewed 14519 times
Martin

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

Dear Sir:

I tried to open 2 files in this post, but the program show me an alert¡ “”Unexpected file format”” could you be so kindly to send them me, I like to see them how them works?

File A: Stopwatch4 using wrong switches.FCF
File B: Test_V4 port_inc.FCF
(Which is the final project?)

Thanks

Armagon

(Note: I can download FCV4 demo for test or may I Upgrade ,my software)

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

Re: Dual Timer

Post by medelec35 »

Project is on going making improvements slowly. Have work commitments. Removed 100th sec so can have more room on display for temperature reading, which I have just added. Only added bank of switches for testing port interrupts so they can be remove, and just add required switches.
Files are not corrupt. If unexpected file format is displayed, then you are not using correct version of flowcode. You will need to install latest V4.1 for sim to work. Won't work on V4.0 or below.
Attachments
Stopwatch5 using wrong switches.FCF
(21 KiB) Downloaded 521 times
Martin

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

Dear Sir:

Thanks for four assistance, but I saw into the file and I made some modification (remove temperature, and count up become to come dawn), but finally the program become a disaster, the project is a simple double count dawn (on/off/on/off…) adjustable by the user, could you be so kindly to help me

Thanks again

Armagon

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

Re: Dual Timer

Post by medelec35 »

If you post your modified Flowchart, I will have a look at what you have done. oop! RB5 in Main should be i/p not output.
Never was good at multitasking :P
Martin

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

Dear Sir:

the file is included, see and check

Thanks

Armagon
Attachments
Dual Timer.fcf
Dual Timer file
(20.85 KiB) Downloaded 486 times

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

Re: Dual Timer

Post by medelec35 »

Reason I have posted original file was to demonstrate two things. 1)Bug with simulator an port change interrupts . 2) to show a unique way (hopefully :P ) of be able to demonstrate how to make a display show two different independent times, with least amount of blocks used. File you have have posted is same as original, except with file name re-changed and B5 changed as i/p. Flowcode is a great tool, but if someone else does all the work, you will not benefit. I don't mind helping, but best advice would be get as far as you can by reading, asking questions etc. When you absolutely can't get any further then post what you have done, which includes: The ports you want to use for I/P's and O/P's with comments what you want switches or any O/P's to do. Target device and frequency? E.t.c. BTW if you was wondering why there is 5uS o/p to D7 in seconds routine, it is only to check with a scope that's a second is a second! It can be removed when completed. Finally although I can create working projects, I'm not in the same league as Ben, Steve or Sean, so not 100% chance of achieving working projects, but all have worked so far. I sometimes still have to read up a bit before going to next step :P
Martin

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

Dear Sir:

I just made a program, I used info from FC examples, please test the file, your comments will help me

Thanks

Armagon
FlowcodeTimer.fcf
File
(18.9 KiB) Downloaded 580 times

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

Re: Dual Timer

Post by medelec35 »

Just had a quick look.
A few things spring to mind.

On your 1st post you stated Timer A 10:30 (10 minutes and 30 seconds). But you only allow entry
of 3 digits. This means you can max 999= 9 Min's and 99 seconds.
What about putting valid time entry routine, which won't allow you to enter 60 seconds or above?

On your display you could have T1=
instead of Timer A =
That would give you more room. E.g
T1=02:30
T2=10:32

It is minutes and seconds count down. As you would know there are 60 seconds in 1 min. so if enter
102 then sequence should go 1:02,1:01,1:00,0:59,0:58..etc
not 102,101,100, 990 980 etc. The 0 is on the end because you have not over written the third digit with a space.

There is no routine in place to wait for key pad release before allowing entry of next number.
Keys will be read very fast! so if u press 3 briefly, then 333 will be entered!

Only one line of display is shown until 1st timer finished. why not have both timers shown form the start.

There should be an option to change time entered at any point. If not you will have to keep disconnecting power to enter new time.
You could use * to change times
If you enter time and change you mind or press wrong number by mistake you can use
# to confirm correct time entered. Until then you can keep entering different numbers which won't be stored until # key pressed.

Source will be external pin of chip, not from oscillator! If using oscillator for timing, then you need to reselect source form timer0 properties. Internal clock is used even if you have a crystal oscillator.
Martin

armagon29
Posts: 56
Joined: Thu May 07, 2009 4:40 pm
Been thanked: 2 times

Re: Dual Timer

Post by armagon29 »

DEar Sir:

I re-work using the clock of FC examples, and I made some modification the time can be set at 999 Sec = 16 Min + 40 Sec

Please check,

Thanks

Armagon
TimerB.fcf
(24.83 KiB) Downloaded 585 times

Post Reply