24 hour clock with 4digit 7-seg display
24 hour clock with 4digit 7-seg display
Hello.
Im new to flowcode and im trying to make 24 hour clock with 4 digit 7-segment display as a school project.
Is it possible to make whole thing with flowcode and if it is, could someone send me some sample what it should look like?
Im new to flowcode and im trying to make 24 hour clock with 4 digit 7-segment display as a school project.
Is it possible to make whole thing with flowcode and if it is, could someone send me some sample what it should look like?
The code is finished now and working almost perfectly. Just having a small problem and hoping if anyone could answer.
When running the clock (in flowcode) some numbers like 1 show as 7.. but when i switch the delay to slower it shows like 1 but it blinks the segment A ( with numbers 5 and 6 it blinks segment B ) just before the segment turns off. Is this just software side or is there something wrong with my code?
Going to test the code in action next week after getting my circuit finished
When running the clock (in flowcode) some numbers like 1 show as 7.. but when i switch the delay to slower it shows like 1 but it blinks the segment A ( with numbers 5 and 6 it blinks segment B ) just before the segment turns off. Is this just software side or is there something wrong with my code?
Going to test the code in action next week after getting my circuit finished
- 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:
Hello Keke
I have tested the 7 segment displays with a slow RC clock and there is no flicker at the end of displaying the 1. Are you using the latest version of Flowcode. You can upgrade to the latest version by downloading and installing the following file.
http://www.matrixmultimedia.com/softwar ... nstall.exe
Adding a small delay (eg 4-5ms) after each write to the 7 segment display should also help to make the numbers clearer and more defined.
Hope this helps.
I have tested the 7 segment displays with a slow RC clock and there is no flicker at the end of displaying the 1. Are you using the latest version of Flowcode. You can upgrade to the latest version by downloading and installing the following file.
http://www.matrixmultimedia.com/softwar ... nstall.exe
Adding a small delay (eg 4-5ms) after each write to the 7 segment display should also help to make the numbers clearer and more defined.
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Tested this in action... it seems when i add the switches to flowcode the segments start to blink and on my hardware whole clock goes nuts.
i have two switches, one for minutes and one for hours. Hour switch is connected to same port with segment A (pin 6) and minutes to same with segment B (pin 7)
where should i connect these switches?
PS: i tested this on the flowcode programming/testing board
i have two switches, one for minutes and one for hours. Hour switch is connected to same port with segment A (pin 6) and minutes to same with segment B (pin 7)
where should i connect these switches?
PS: i tested this on the flowcode programming/testing board
- 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:
Hello
Have you got any spare I/O that is not being used.
I am guessing that the current config is this.
PortB 0 - 7 - Cathodes
PortA 0 - 3 - Anodes
What about pins RA4 and RA5.
Have you got any spare I/O that is not being used.
I am guessing that the current config is this.
PortB 0 - 7 - Cathodes
PortA 0 - 3 - Anodes
What about pins RA4 and RA5.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 24 hour clock with 4digit 7-seg display
I am in the process of developing a stop watch with min secs and 1/1000th of a second digit displayed.
1/ I am using a 16X2 alphanumeric display. I need help on the refresh routine for displaying the count from the timer interrupt. Any suggestions on how to organise the LCD display subroutine would be helpful.
2/ What prescaler and clock freq will ensure an accurate 0.001 sec count please (I am thinking of using a 4MHZ freg with a prescaler setting of 1:16)?
3/ Any pointers on how to set up the main flowcode program or tips to ensure that the timing is accurate would be of great help.
4/ I want to divide a variable then use the remainder. For example:
TempVar = Mins/10
TempVar2= %Mins or remainder of Mins.
Is there a flowcode feature that allows the use of remainders?
6/ The start stop will be controlled by a button and a 433mhz reciever/decoder to allow automatic timing.
ANY advice, tips or flowcode snippets would be much appreciated.
Thank you.
1/ I am using a 16X2 alphanumeric display. I need help on the refresh routine for displaying the count from the timer interrupt. Any suggestions on how to organise the LCD display subroutine would be helpful.
2/ What prescaler and clock freq will ensure an accurate 0.001 sec count please (I am thinking of using a 4MHZ freg with a prescaler setting of 1:16)?
3/ Any pointers on how to set up the main flowcode program or tips to ensure that the timing is accurate would be of great help.
4/ I want to divide a variable then use the remainder. For example:
TempVar = Mins/10
TempVar2= %Mins or remainder of Mins.
Is there a flowcode feature that allows the use of remainders?
6/ The start stop will be controlled by a button and a 433mhz reciever/decoder to allow automatic timing.
ANY advice, tips or flowcode snippets would be much appreciated.
Thank you.
- 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: 24 hour clock with 4digit 7-seg display
Hello Ziggy
In answer to your questions
1) The easiest way is to use a macro to do all of the cursor positioning and data outputing, using global variables to hold the data you want outputting.
2) The best thing you can do is play around with the clock speed in Flowcode. When you go into the Timer0 Properties it will tell you the interrupt frequency based on the prescalar and clock speed.
3) Timing will be accurate if A) Your interrupt service routine is kept to a minimum, B) You are using an XTAL or HS Oscillator.
4) This is not possible with 8 bit digital logic, You options are to A) multiply the number so the remainder will be an integer, B) use the 32-bit floating point library for Flowcode (see forum posts in support area).
In answer to your questions
1) The easiest way is to use a macro to do all of the cursor positioning and data outputing, using global variables to hold the data you want outputting.
2) The best thing you can do is play around with the clock speed in Flowcode. When you go into the Timer0 Properties it will tell you the interrupt frequency based on the prescalar and clock speed.
3) Timing will be accurate if A) Your interrupt service routine is kept to a minimum, B) You are using an XTAL or HS Oscillator.
4) This is not possible with 8 bit digital logic, You options are to A) multiply the number so the remainder will be an integer, B) use the 32-bit floating point library for Flowcode (see forum posts in support area).
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 24 hour clock with 4digit 7-seg display
Thanks for the input. I looked at the examples that came with flowcode 3 in the program files on my computer. They are excellent. I recommend that anyone who needs help with sorting out timing for example will be able to adapt example 22 to achieve what they need. The examples are very very helpful and illustrate the capabilities of flowcode.
Re: 24 hour clock with 4digit 7-seg display
I have adapted tutorial 22 for my stop watch project. I have implement a start button macro with debounce. I am finding it difficult stopping the program as a stop watch. Could anyone suggest how I could implement the stop and reset button please?
Thank you
Thank you
- Attachments
-
- stop_button.JPG (21.66 KiB) Viewed 18420 times
-
- stopwatch.JPG (17.17 KiB) Viewed 18423 times
- 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: 24 hour clock with 4digit 7-seg display
Hello Ziggy
The Stop button has to disable the timer0 interrupts. This will stop the internal variables from counting and can be done by using an interrupt flowchart icon.
The Reset button has to assign 0 to all of the internal count registers. Eg secs, mins, hours etc.
The Stop button has to disable the timer0 interrupts. This will stop the internal variables from counting and can be done by using an interrupt flowchart icon.
The Reset button has to assign 0 to all of the internal count registers. Eg secs, mins, hours etc.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 24 hour clock with 4digit 7-seg display
OK i got the clock working but theres still one problem... The display isnt realy bright, in daylight its impossible to see the number but in dark room its possible... Could it be because i got just 1ms as delay between each 7-segment display. Maybe if i make the delays bit longer it could be brighter?
Before making the circuit i tested the 7-segs manualy and they were pretty bright, you could see the numbers in daylight from far away with ease.
Before making the circuit i tested the 7-segs manualy and they were pretty bright, you could see the numbers in daylight from far away with ease.
- 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: 24 hour clock with 4digit 7-seg display
Hello Keke
Yes increasing the delays can have an effect on the brightness of the displays. Up to 4 or 5 ms per 7-seg normally does a good job. If you can see the displays flickering then lower the delay value slightly.
Our hardware 7-segs have transistors to help boost the current to the anode pins. Have you created your own hardware for these displays or are you using some of our hardware.
Sean has also mentioned that special tape is available to make the red lit segment bars stand out more from the background so this may also be an option for you.
Yes increasing the delays can have an effect on the brightness of the displays. Up to 4 or 5 ms per 7-seg normally does a good job. If you can see the displays flickering then lower the delay value slightly.
Our hardware 7-segs have transistors to help boost the current to the anode pins. Have you created your own hardware for these displays or are you using some of our hardware.
Sean has also mentioned that special tape is available to make the red lit segment bars stand out more from the background so this may also be an option for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 24 hour clock with 4digit 7-seg display
Thanks for fast answer.
In my circuit i got 4050CMOS non-inverting hex buffers between the PIC and 7-seg displays, they should work same way as transistors do.
Im gonna test increasing the delays tomorow since cant do that today.
In my circuit i got 4050CMOS non-inverting hex buffers between the PIC and 7-seg displays, they should work same way as transistors do.
Im gonna test increasing the delays tomorow since cant do that today.
Re: 24 hour clock with 4digit 7-seg display
Sorry for double post but...
When i try to compile it the flowchar to .hex it gives me these errors
File name: K:\opinnäytetyö\KELLO.c
Generated by: Flowcode v3.0.3.27
Date: Friday, February 08, 2008 10:04:45
Licence: 50 User
Registered to: Pyynikin ammattioppilaitos/TAO
NOT FOR COMMERCIAL USE
http://www.matrixmultimedia.com
Launching the compiler...
..................
BoostC Optimizing C Compiler Version 6.52 (for PIC16 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2006 Pavel Baranov
Copyright(C) 2004-2006 David Hobday
Licensed to FlowCode User under Single user Full License for 1 node(s)
Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only
internal error: can't parse input file name 'KELLO.c'
KELLO.c
Starting preprocessor: "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\pp.exe" KELLO.c -i "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\include" -d _PIC16F628 -la -c2 -o KELLO.pp -v -d _BOOSTC -d _PIC16
.....................................................................................................................................................................................................................................................................................................................................
KELLO.c(627:9): error: unknown identifier 'TMR0IE'
KELLO.c(627:9): error: unexpected '.' operator
KELLO.c(627:2): error: failed to generate expression
KELLO.c(627:2): error: invalid operand 'intcon.TMR0IE'
KELLO.c(627:15): error: failed to generate expression
KELLO.c(668:21): error: unknown identifier 'TMR0IF'
KELLO.c(668:21): error: invalid operand 'TMR0IF'
KELLO.c(668:18): error: failed to generate expression
KELLO.c(668:18): error: invalid operand '<<'
KELLO.c(668:13): error: failed to generate expression
KELLO.c(668:13): internal error: failed to generate 'if' expression
KELLO.c success
.
failure
Return code = 1
Vuokaavion C-koodin kääntäminen ei onnistu johtuen seuraavista virheistä:
Jos vuokaaviossasi on C-koodia, käy tämä huolellisesti läpi. Jos vuokaaviossasi ei ole C-koodia tai olet täysin tarkastanut sen, ota yhteyttä tekniseen tukeen.
FINISHED
it seems to be giving error about my TMR0 interrupt, when i take it off it compiles without any problems...
anyone knows solution to this
When i try to compile it the flowchar to .hex it gives me these errors
File name: K:\opinnäytetyö\KELLO.c
Generated by: Flowcode v3.0.3.27
Date: Friday, February 08, 2008 10:04:45
Licence: 50 User
Registered to: Pyynikin ammattioppilaitos/TAO
NOT FOR COMMERCIAL USE
http://www.matrixmultimedia.com
Launching the compiler...
..................
BoostC Optimizing C Compiler Version 6.52 (for PIC16 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2006 Pavel Baranov
Copyright(C) 2004-2006 David Hobday
Licensed to FlowCode User under Single user Full License for 1 node(s)
Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only
internal error: can't parse input file name 'KELLO.c'
KELLO.c
Starting preprocessor: "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\pp.exe" KELLO.c -i "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\include" -d _PIC16F628 -la -c2 -o KELLO.pp -v -d _BOOSTC -d _PIC16
.....................................................................................................................................................................................................................................................................................................................................
KELLO.c(627:9): error: unknown identifier 'TMR0IE'
KELLO.c(627:9): error: unexpected '.' operator
KELLO.c(627:2): error: failed to generate expression
KELLO.c(627:2): error: invalid operand 'intcon.TMR0IE'
KELLO.c(627:15): error: failed to generate expression
KELLO.c(668:21): error: unknown identifier 'TMR0IF'
KELLO.c(668:21): error: invalid operand 'TMR0IF'
KELLO.c(668:18): error: failed to generate expression
KELLO.c(668:18): error: invalid operand '<<'
KELLO.c(668:13): error: failed to generate expression
KELLO.c(668:13): internal error: failed to generate 'if' expression
KELLO.c success
.
failure
Return code = 1
Vuokaavion C-koodin kääntäminen ei onnistu johtuen seuraavista virheistä:
Jos vuokaaviossasi on C-koodia, käy tämä huolellisesti läpi. Jos vuokaaviossasi ei ole C-koodia tai olet täysin tarkastanut sen, ota yhteyttä tekniseen tukeen.
FINISHED
it seems to be giving error about my TMR0 interrupt, when i take it off it compiles without any problems...
anyone knows solution to this
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: 24 hour clock with 4digit 7-seg display
Hello Keke,
Ben is not available today so I will try to pick up this project.
The first thing i have noticed with your error report is that TMR0IF and TMR0IE are not defined for the PIC16F628. The required definitions are T0IF and T0IE respectively. Are you using a custom interrupt or C code?
If this does not help could you attach a copy of your code to the next posting and I will check it.
Ben is not available today so I will try to pick up this project.
The first thing i have noticed with your error report is that TMR0IF and TMR0IE are not defined for the PIC16F628. The required definitions are T0IF and T0IE respectively. Are you using a custom interrupt or C code?
If this does not help could you attach a copy of your code to the next posting and I will check it.
Re: 24 hour clock with 4digit 7-seg display
Ben,
I have successfully implemented the stop and reset button respectively, thanks for the hint. I want to use a 4 MHZ crystal to generate a 100ms interrupt. I downloaded a piece of software called "Pic Timer Calculator Version 4". The software recommends a timer offset of 100, a prescaler ratio of 1:64 and calculated that a 99.5222 Hz timer freq will allow 1 instruction cycle time to equate to 10048 micro seconds which is not far off the interrupt time I want. In Flowcode, a prescaler setting of 1:64 for a 4 Mhz crystal allows an interrupt frequency of 61.0352 Hz. How do I implement the equivalent of a timer offset and will I be able to achieve a 10048 micro seconds interrupt?
I have successfully implemented the stop and reset button respectively, thanks for the hint. I want to use a 4 MHZ crystal to generate a 100ms interrupt. I downloaded a piece of software called "Pic Timer Calculator Version 4". The software recommends a timer offset of 100, a prescaler ratio of 1:64 and calculated that a 99.5222 Hz timer freq will allow 1 instruction cycle time to equate to 10048 micro seconds which is not far off the interrupt time I want. In Flowcode, a prescaler setting of 1:64 for a 4 Mhz crystal allows an interrupt frequency of 61.0352 Hz. How do I implement the equivalent of a timer offset and will I be able to achieve a 10048 micro seconds interrupt?
Re: 24 hour clock with 4digit 7-seg display
The link for the software I mentioned in the above post
http://users.picbasic.org/projects/PicT ... merCal.htm
http://users.picbasic.org/projects/PicT ... merCal.htm
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: 24 hour clock with 4digit 7-seg display
The 61.0352Hz interrupt rate is based on the assumption that timer 0 is continually counting from 0 to 255 and generating an interrupt each time it overflows back to zero.
With a Xtal frequency of 4MHz, the system clock dividion of 4, and the selected prescaler division of 64, timer 0 is being clocked at 15625Hz (64us). Division by the 256 count required by Timer 0 results in the 61.0352Hz interrupt frequency.
If Timer 0 is preset to the value 100 at the start of each interrupt cycle, it will only require a further 157 count to overflow and generate the next interrupt. 157 x 64us = 10048us. (setting 101 will give 9984us).
To achieve this, set up the Timer 0 overflow interrupt with the specified prescaler value and write your interrupt macro. The first code block in the interrupt macro should be a C code block with the following command:
tmr0 = 100;
This will quickly change the timer register value from the normal overflow value of 0 to the required value of 100.
This is not a perfect solution because of the finite time taken to respond to the interrupt, but is accurate to a few us and is relatively stable.
With a Xtal frequency of 4MHz, the system clock dividion of 4, and the selected prescaler division of 64, timer 0 is being clocked at 15625Hz (64us). Division by the 256 count required by Timer 0 results in the 61.0352Hz interrupt frequency.
If Timer 0 is preset to the value 100 at the start of each interrupt cycle, it will only require a further 157 count to overflow and generate the next interrupt. 157 x 64us = 10048us. (setting 101 will give 9984us).
To achieve this, set up the Timer 0 overflow interrupt with the specified prescaler value and write your interrupt macro. The first code block in the interrupt macro should be a C code block with the following command:
tmr0 = 100;
This will quickly change the timer register value from the normal overflow value of 0 to the required value of 100.
This is not a perfect solution because of the finite time taken to respond to the interrupt, but is accurate to a few us and is relatively stable.