![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
softclement
Joined: 21 Nov 2012 Posts: 2
|
how to display milliseconds? |
Posted: Wed Nov 21, 2012 5:29 am |
|
|
how to display milliseconds?
able to print Seconds. |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Nov 21, 2012 7:48 am |
|
|
Please give us a bit more to work with.
Types of PIC, display, compiler version etc?
School project, hobby, work, your level of expertise?
The CCS forum guide gives useful hints on how to get help. Read it.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
softclement
Joined: 21 Nov 2012 Posts: 2
|
Milli-seconds |
Posted: Wed Nov 21, 2012 9:48 pm |
|
|
Hi, I'm able to see seconds, I want to show Milli-seconds continuously like seconds instead of multiplying 1000s:
Code: |
#include <18F2520.h>
#fuses HS
#use delay(clock=6144000)
#define INTS_PER_SECOND 23.4375 // (6144000/(4*256*256))
int16 seconds;
BYTE INT_count;
#INT_rtcc
void clock_isr()
{
if (--INT_count == 0)
{
++seconds;
INT_count = INTS_PER_SECOND;
}
}
#define EN PIN_A1
#define RS PIN_A2
void lcd_cmd(CHAR a); // function declaration
void lcd_print(CHAR rstr[]);
CHAR msg[20];
void main()
{
set_timer0 (0) ;
setup_counters (RTCC_INTERNAL, RTCC_DIV_256|RTCC_8_BIT);
enable_interrupts (INT_RTCC) ;
enable_interrupts (GLOBAL) ;
output_low (RS);//set LCD to command mode
lcd_cmd (0x30);//set LCD to 1x8 LINE DISPLAY (8 bit) ok
lcd_cmd (0x01);//clear LCD screen
lcd_cmd (0x02);//move cursor to home position
lcd_cmd (0x0c);// set cursor to blinking off
lcd_cmd (0x06);//move cursor right side automatically by 1
seconds =0;
WHILE (1)
{
output_low (RS);//set LCD to command mode
lcd_cmd (0x02);//move cursor to home position
sprintf (msg, "%LU %LU", seconds, SECONDS*1000 ); // SECONDS & MILLISECONDS
// MILLIESECONDS SHOW CONTINIOUS COUNTER INSTEAD OF MULTIPLYING 1000
lcd_print (msg);
}
}
void lcd_cmd(CHAR a) // TO enaable LCD microcontroler // function definition
{
output_b (a);
delay_ms (10);
output_high (EN);
delay_ms (10);
output_low (EN);
}
void lcd_print(CHAR rstr[])
{
INT i;
FOR (i=0; rstr[i]!='\0'; i++)
{
output_high (rs);//set LCD to data mode
lcd_cmd (rstr[i]);//printing the charact to display LCD
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19368
|
|
Posted: Thu Nov 22, 2012 2:20 am |
|
|
Seriously, as answered in the other thread you launched asking the same question, you haven't got a hope....
Look at the data sheet for your LCD. Look for figures marked 'response time - rise', and 'response time - fall'. These will typically be something like 60 to 120mSec. These are how long it takes the LCD to change from 'off' to 'on', and 'on' to 'off' respectively. LCD's like this, just cannot display data changing faster than this. Even much more complex types (like the ones in a TV), still have something like 8 to 20mSec response time. Things just cannot be changed on the screen faster than this. There is no point anyway, since you cannot see changes at these speeds.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Nov 22, 2012 10:31 am |
|
|
Quote: | I want to show Milli-seconds continuously like seconds instead of multiplying 1000s: | Why?
Please explain, then we may be able to guide you.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Thu Nov 22, 2012 10:28 pm |
|
|
If it is some sort of continuously updating display, then as others have pointed out you can't get there with an LCD. Even with a LED display which does support the response time, the best you could hope for is possibly reading tenths of seconds. If on the other hand, you are trying to measure a period to the ms level, then instead of counting in seconds, count at 1khz for a second then display with the decimal point moved to the left 3 digits (assuming you are updating at a 1hz rate for example). Above somewhere around 15 hz or so (not sure of exact number), the human eye integrates it into a continuous moving image (like a TV).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19368
|
|
Posted: Fri Nov 23, 2012 2:03 am |
|
|
Yes. It is one of those 'at times you may perceive things faster than this, but not see things'. Movies use 24, 25, or 30, fps, but your peripheral vision can 'perceive' things quicker. You can occasionally out the edges of your eyes see 'flicker' up to perhaps 100Hz, However motion integration starts as slow as perhaps 10 to 12Hz. Actually reading a digit (central vision), takes at least 1/10th second, but look sideways at a TV screen, and you can be aware of it flickering. As I said in the other thread, it is worth looking at digital stopwatches that give 100Hz updates. They don't display 1/100th second digits, normally just a scrolling pattern like \ | / - \ etc., in the last digit. It is only when you hit the 'stop', that the actual digits are shown. Trying to display mSec, or even tens of mSec, is completely pointless.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|