Go to Post "FIRST is like a pizza, we all think different toppings should be on it" - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-03-2006, 21:39
jeffmorris jeffmorris is offline
Registered User
no team
 
Join Date: Sep 2005
Location: staten island, ny
Posts: 62
jeffmorris is on a distinguished road
Radio Control and Ultrasonic Sensor

I wrote a program using Easy C 2.0 that lets me control a car using radio control until the ultrasonic sensor detects that the car is going to crash into something and stops the motors so that the car doesn't crash into something. One problem: because the value of the sensor reading is still under 20 after the motors are stopped, I can't control the car using radio control. Any suggestions?

Code:
#include "Main.h"

void main ( void )
{
      int loop = 1; 
      int ultrasonic; 

      //Connect Input Wire to Digital Output 11
      //Connect Output wire to Interrupt 1
      //Near = 2, Far = 100
      StartUltrasonic ( 1 , 11 ) ; // interrupt 1= output label on sensor, DO11=input label on sensor
      while ( loop == 1 )
      {
            ultrasonic = GetUltrasonic ( 1 , 11 ) ;
            if ( ultrasonic > 20 )
            {
                  Arcade2 ( 0 , 2 , 4 , 3 , 2 , 0 , 0 ) ;
            }
            else
            {
                  SetMotor ( 2 , 127 ) ;
                  SetMotor ( 3 , 127 ) ;
            }
      }
}
Reply With Quote
  #2   Spotlight this post!  
Unread 24-03-2006, 21:53
Francis-134's Avatar
Francis-134 Francis-134 is offline
Lifer
FRC #0190 (Gompei and the Herd)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Worcester, MA
Posts: 602
Francis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond reputeFrancis-134 has a reputation beyond repute
Re: Radio Control and Ultrasonic Sensor

If, after you tell the robot to stop, you tell it to move backward until the ultrasonic does not read 20, it should work. Or, you could change the "stop" part to "go backwards for one second".
__________________

Email | Twitter | Facebook | YouTube | Twitch
iTunes Podcast | Snapchat

A proud alumnus of teams 134 and 40 || Mentor of Team 190 || Director of Fun for BattleCry@WPI
Reply With Quote
  #3   Spotlight this post!  
Unread 25-03-2006, 06:54
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Radio Control and Ultrasonic Sensor

Another way of doing it is to break up the Arcade command into two sets of commands, reading the joystick value and driving the motors. Then whenever the ultrasonic sensor is reading a low value, only allow joystick values that drive backwards or away from the target. For forward joystick values, send stopped, the way you are doing now.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #4   Spotlight this post!  
Unread 25-03-2006, 11:06
jeffmorris jeffmorris is offline
Registered User
no team
 
Join Date: Sep 2005
Location: staten island, ny
Posts: 62
jeffmorris is on a distinguished road
Re: Radio Control and Ultrasonic Sensor

I got Radio Control and Ultrasonic Sensor working properly. Here's the code:

Code:
#include "Main.h"

void main ( void )
{
      int ultrasonic; 
      int joystick02; 

      //Connect Input Wire to Digital Output 11
      //Connect Output wire to Interrupt 1
      //Near = 2, Far = 100
      StartUltrasonic ( 1 , 11 ) ; // interrupt 1= output label on sensor, DO11=input label on sensor
      while ( 1 == 1 )
      {
            ultrasonic = GetUltrasonic ( 1 , 11 ) ;
            joystick02 = GetRxInput ( 1 , 2 ) ;
            if ( ultrasonic > 20 )
            {
                  MotorRcControl ( 0 , 2 , 1 , 0 ) ;
                  MotorRcControl ( 0 , 2 , 2 , 1 ) ;
                  ServoRcControl ( 0 , 4 , 3 , 0 ) ;
            }
            else
            {
                  SetMotor ( 1 , 127 ) ;
                  SetMotor ( 2 , 127 ) ;
                  ServoRcControl ( 0 , 4 , 3 , 0 ) ;
                  if ( joystick02 > 127 )
                  {
                        MotorRcControl ( 0 , 2 , 1 , 0 ) ;
                        MotorRcControl ( 0 , 2 , 2 , 1 ) ;
                  }
                  else
                  {
                        SetMotor ( 1 , 127 ) ;
                        SetMotor ( 2 , 127 ) ;
                  }
            }
      }
}
Is it possible to get another Ultrasonic Sensor for the rear end of the car? I think that in another thread on this forum, someone couldn't get two Ultrasonic Sensors working together without special programming.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi