View unanswered posts | View active topics It is currently Tue Sep 23, 2014 10:49 am






Reply to topic  [ 3 posts ] 
timers not sure I understand them also LED on and off 
Author Message
Rookie

Joined: Thu Mar 31, 2011 7:08 am
Posts: 10
Post timers not sure I understand them also LED on and off
Do I need to clear the timer when I wait for an example

motor[port4] = closegripper; //close gripper around can
ClearTimer(T4); //clear timer
wait1Msec(80); //

So do I clear the timer each time and if so how does it know which timer. I am a little confused or is the "wait1Msec" different than a timer

I think my problem really is a timer issue I just am not sure how to set them up

Also can any one tell me how to turn on and off a LED


Wed Apr 27, 2011 10:17 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: timers not sure I understand them also LED on and off
Take out the ClearTimer line and you will be fine. The wait1Msec(80) statement will do the right thing to "wait for 80 msec".


Thu Apr 28, 2011 1:02 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: timers not sure I understand them also LED on and off
There is a difference between timers and wait1MSec(). When you implement Wait1MSec, your program(or at least the task that you are in) goes to sleep for the amount of milliseconds specified. So in effect, your program pauses for that much time. Timers will not cause your program to pause, but will be counting in the background. They are used when you need to know how long it's been, but don't want to interrupt your program (they can also be used to stop your program from entering another task, but don't worry about that unless you need to). You can have 4 timers: T1, T2, T3, and T4. As soon as you call ClearTimer(T1), the timer T1 resets and starts counting from zero. You can access the value of a timer by saying time1[T1].

as for the LED, you need to configure the sensor port which the LED is in on the microcontroller as a digital output. You can do this in the motors and sensors setup. To turn it on, you write SensorValue[LED1] = 0, and use whatever name you named the port instead of LED1. To turn it off, use SensorValue[LED1] = 1.

_________________
sudo rm -rf /


Thu Apr 28, 2011 5:51 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.