View unanswered posts | View active topics It is currently Thu Apr 24, 2014 3:24 pm






Reply to topic  [ 3 posts ] 
Need help programming simple function 
Author Message
Rookie

Joined: Sat Mar 12, 2011 12:22 pm
Posts: 17
Post Need help programming simple function
It's been a while since i last used RobotC and I forgot pretty much everything.

What I need is a program that does this:

if Ultrasonic_1 < 22 cm then;
wait 8 sec;
end_if;

if Ultrasonic_2 < 22 cm in between the 8 sec then;
reset program;

else;
motor_1 := speed=100, coast, 6 rotations, forwards
wait for bumped touch sensor
motor_1 := speed=100, coast, 6 rotations, backwards
motor_2 := speed=100, coast, 6,7 rotations, forwards
wait 4 sec
motor_2 := speed=100, coast, 6,7 rotations, backwards

end_if;


I have tried in NXT-G, but I can't figure out this simple sequence. What bothers me is this part: if Ultrasonic_2 < 22 cm in between the 8 sec.

Can I get any help please?


Thu Nov 29, 2012 6:38 am
Profile
Rookie

Joined: Sat Mar 12, 2011 12:22 pm
Posts: 17
Post Re: Need help programming simple function
Never mind, I solved the problem in NXT-G. I found this count-function as a start: http://www.brickshelf.com/gallery/brdav ... resses.png

I made my own additions so it now looks like this.

- I added the C-motor to see if the program ended where I wanted it to.
- The two "Logic 1" blocks at the end of the top loop writes "false"
- To make the count function work with the ultrasonic sensor, I added a "wait for Sensor > 22 cm"
- The loop for the count-function is 6 seconds.
- The "Greater than or equal" block says that "number 1" should be greater than 0.

It works perfectly. I tested it multiple times.
Would be awesome seeing it in RobotC though to get the language refreshed

Image


Thu Nov 29, 2012 2:57 pm
Profile
Rookie

Joined: Sat Mar 12, 2011 12:22 pm
Posts: 17
Post Re: Need help programming simple function
Perhaps I should mention what I need to have done.

Imagine a transport belt and a visio camera. The belt drives a bottle into a chamber were it gets registered by the camera. If the bottle is broken or in any other way damaged, the belt will drive the bottle out of the chamber the way it came.

There's a sonic sensor sitting at the entrance of the chamber registering bottles. After 8 seconds, the bottle should either have stayed in the chamber or not. If the bottle stays in the chamber, a couple of motors will control the doors to the chamber. If not, nothing will happen and the program starts from the beginning once again.


Thu Nov 29, 2012 3:22 pm
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.