View unanswered posts | View active topics It is currently Mon Sep 01, 2014 9:51 am






Reply to topic  [ 6 posts ] 
Feature Request: timing. 
Author Message
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Feature Request: timing.
Would it be possible to be able to time in microseconds and nanoseconds? That would be very, very, very useful.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon May 14, 2012 5:49 pm
Profile WWW
Rookie

Joined: Mon May 14, 2012 3:24 pm
Posts: 43
Post Re: Feature Request: timing.
Something like the pulseIn() function would be very useful for ultrasonic sensors. I am not sure what you would want nanosecond timing for but I am aware that some people have been able to make some degree of timers using multiple NOP calls (something like #define nop() __asm__ __volatile__("nop"))

Each nop call is one clock cycle which would be about 62.5 ns on the 328p Uno's (I think).


Mon May 14, 2012 6:19 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Feature Request: timing.
Well, I think that the HD44780 interface requires pulses nanoseconds apart, but I might've read it wrong.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon May 14, 2012 11:43 pm
Profile WWW
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post Re: Feature Request: timing.
ROBOTC uses an overflow system to detect when 1ms has elapsed and that's what runs the ROBOTC clock. I'll look into maybe having a user timer with microsecond precision, but I have a feeling this might be a significant change.

We did recently add (but haven't advertised due to still testing) a "Sleep(nMsec)" function - it should work in the BETA build you're using... this will at least allow you to sleep/delay for a certain number of microseconds vs. the wait1Msec(mSec) commands in milliseconds.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Tue May 15, 2012 9:20 am
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Feature Request: timing.
The Uno uses a 16MHz clock, so the precision is limited to 0.0000000625 seconds with no pre-scaler.

_________________
Matt


Tue May 15, 2012 10:27 am
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Feature Request: timing.
Okay, so no nanoseconds. I think I read the datasheet wrong anyway, because the 3Pi uses the HD44780 interface with 16Mhz clock.

How long does it take the 328P to wake up? That could interfere with the timing, if it's sleeping and then takes extra time waking.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue May 15, 2012 11:45 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.