View unanswered posts | View active topics It is currently Tue Oct 23, 2018 9:32 pm

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Need help programming simple function
Author Message
Rookie

Joined: Sat Mar 12, 2011 12:22 pm
Posts: 17
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
Rookie

Joined: Sat Mar 12, 2011 12:22 pm
Posts: 17
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 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

Thu Nov 29, 2012 2:57 pm
Rookie

Joined: Sat Mar 12, 2011 12:22 pm
Posts: 17
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning