CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

how to display milliseconds?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
softclement



Joined: 21 Nov 2012
Posts: 2

View user's profile Send private message

how to display milliseconds?
PostPosted: Wed Nov 21, 2012 5:29 am     Reply with quote

how to display milliseconds?
able to print Seconds.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Nov 21, 2012 7:48 am     Reply with quote

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
softclement



Joined: 21 Nov 2012
Posts: 2

View user's profile Send private message

Milli-seconds
PostPosted: Wed Nov 21, 2012 9:48 pm     Reply with quote

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
   }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Nov 22, 2012 2:20 am     Reply with quote

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
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Nov 22, 2012 10:31 am     Reply with quote

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
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Thu Nov 22, 2012 10:28 pm     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Nov 23, 2012 2:03 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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