go_away

Author Topic: 50 $ sharpir servo problem  (Read 1597 times)

0 Members and 1 Guest are viewing this topic.

Offline matz91Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
50 $ sharpir servo problem
« on: June 26, 2010, 10:27:28 AM »
hello SOR
I'm new to the forum. For some time I'm working on $ 50 + robot sharp Ir. In fact I bought a servo Hit HS 422 (this could be the problem?) and a sharp Ir sensor 2Y0A21. I programmed the robot as on the tutorial, but once switched on despite several attempts it is impossible to calibrate because of limit stops >:(. I also found that the sensor works perfectly so it should not be a problem.
battery provides 7.2Vto the servo and 5.0V to the sensors.
Finally, the robot if programmed as Photovore works perfectly.
I saw that many people have had the same problem as this: http://www.societyofrobots.com/robotforum/index.php?topic=8355.0 or this http://www.societyofrobots.com/robotforum/index.php?topic=8371.0 but there isn't the solution to the problem.
please help me because I have a presentation in a few days.
(Forgive me for my bad English)

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: 50 $ sharpir servo problem
« Reply #1 on: June 26, 2010, 10:59:18 AM »
When you calibrate the sensor's threshold value you must hold in front of the sensor an object at the farthest distance you want the robot to detect that object. For example, say you want to detect a box starting at 10 inches and closer to the robot. You place the box at that distance in front of the robot, start the code and it will auto calibrate to detect the object from 10 inches going closer to the robot.

Does this help?
Check out the uBotino robot controller!

Offline matz91Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: 50 $ sharpir servo problem
« Reply #2 on: June 26, 2010, 11:30:50 AM »
I tried what you say, but when the servo reaches the limit, (servo is not modified) does not move. I also tried using white material at different distances but with no results. I did test with a infrared camera to see if the sharpir sensor worked and it's work. could be a code problem? can be need in the code, specific values for the servo hs422 (although the features are almost identical with the hs311)?Power could be a problem? ???

Offline matz91Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: 50 $ sharpir servo problem
« Reply #3 on: June 27, 2010, 12:48:05 PM »
can anyone help me please  :-[

Offline dellagd

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 731
  • Helpful? 5
  • Come to the dark side... We have cookies!
Re: 50 $ sharpir servo problem
« Reply #4 on: June 27, 2010, 02:51:45 PM »
I don't think I fully understand your problem, but an unmodified servo will only rotate within a 90 degree slot (sometimes 180 degrees).

make sure that when you mount the servo that the servo is centered. once it is centered, mount the IR sensor facing straight out. Then you will have 45 degrees to move to the right and 45 degrees to move to the left.
« Last Edit: June 27, 2010, 02:55:26 PM by dellagd »
Innovation is a product of Failure, which leads to Success.

If I helped, +1 helpful pls

I Won!
3rd place! I'm taking $100

Offline matz91Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: 50 $ sharpir servo problem
« Reply #5 on: June 27, 2010, 02:56:25 PM »
this isn't the my problem. i have the same problem of post http://www.societyofrobots.com/robotforum/index.php?topic=8355.0. but in this topic or in other similar topics there isn't the solution to this problem.
however thank you for you answer

Offline dellagd

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 731
  • Helpful? 5
  • Come to the dark side... We have cookies!
Re: 50 $ sharpir servo problem
« Reply #6 on: June 27, 2010, 03:08:20 PM »
oh I see. Exactly like that other post?
Innovation is a product of Failure, which leads to Success.

If I helped, +1 helpful pls

I Won!
3rd place! I'm taking $100

Offline matz91Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
« Last Edit: June 27, 2010, 03:15:26 PM by matz91 »

Offline matz91Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: 50 $ sharpir servo problem
« Reply #8 on: June 27, 2010, 03:33:17 PM »
if the servo is not the hs311 but is the hs422, must make some modifications to the 50_sharpir code?

Code: [Select]
/
****************************************************************************
*
*   Copyright (c) 2007 [url=http://www.societyofrobots.com]www.societyofrobots.com[/url]
*   (please link back if you use this code!)
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License version 2 as
*   published by the Free Software Foundation.
*
*   Alternatively, this software may be distributed under the terms of BSD
*   license.
*
* $50 Robot with Sharp IR using Stampy Technology v1, May 19th, 2007
* Simple case-based method for a robot to do edge detection.
*
*
****************************************************************************/

//SoR Include
#include "SoR_Utils.h" //includes all the technical stuff

//global variables
int sharp_IR_reading=0;

int scan_thresh=0;//threshold value of scanning sensor

int scan_angle=30;//position of scanner, in units of servo command
int max_scan_angle=57;//maximum position scanner can rotate to (57)


//this function causes scanning servo to center on edge of object
void scan(void)
{
//lower (-) goes right
//higher (+) goes left
//30 far right, 50 straight, 56 far left (until it jams)

/*psuedocode
object is detected
scan right object detected
object not detected
scan left until object detected*/

sharp_IR_reading=a2dConvert8bit(3);

if (sharp_IR_reading > scan_thresh)//object detected
{
if (scan_angle>41) //overflow protection
scan_angle-=2;//scan right
}
else //object not detected
{
if (scan_angle<=max_scan_angle) //maximum servo angle
scan_angle+=2; //scan left
//else //if scanned all the way, this forces it to start over
// scan_angle=30;
}

//servo scan code
servo_scan(scan_angle);
}


//automatically calculates threshold value before run
void autocalibrate(void)
{
scan_thresh=a2dConvert8bit(3);//sensor reading
}

int main(void)
{
//LED_on();

initialize();

delay_cycles(42000);//two second wait delay

/*********ADD YOUR CODE BELOW THIS LINE **********/

//find thresholds
autocalibrate();

//LED_off();


while(1)
{
scan();

//object on left
if(scan_angle > 57)
robot_turn_left();

//object on right
else if(scan_angle < 41)
robot_turn_right();

//object is centered
else
robot_go_straight();

delay_cycles(400);//a small delay to prevent crazy oscillations
}
/*********ADD YOUR CODE ABOVE THIS LINE **********/

return 0;
}


/*********************COMMAND LIST*************************

delay_cycles(cycles);
Delays - you can make your robot wait for a certain amount of time with this function.
Put the number of computational cycles to delay in the ().
23 cycles is about .992 milliseconds
to calculate: 23/.992*(time in milliseconds to delay) = cycles
Check servo datasheet where it says: 'Direction: Clockwise/Pulse Traveling 1500 to 1900usec'

servo_left(speed); and servo_right(speed);
Commands your servos to rotate at a certain speed.
Vary speed (which represents a delay in cycles) from 20 to 50.
Left is for port D0 and right is for port D1.

robot_turn_left(); and robot_turn_right(); and robot_go_straight();
Dont want to deal with speed?
Just call this function and it will 'just work.'

LED_on(); and LED_off();
Turns on and off your LED. The LED is on port D4.
By bringing port D4 low, you are turning on the LED.


variable=a2dConvert8bit(pin);
Reads analog pin. For example, set 'pin' to 5 to read PC5.
'variable' will store the value.

***********************************************************/


 


Get Your Ad Here

data_list