Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: javafiend on March 15, 2008, 07:45:26 PM

Title: Manual calibrate Sharp IR
Post by: javafiend on March 15, 2008, 07:45:26 PM
How do you manually calibrate the Sharp IR?  I would like to use it for my obstacle avoidance whenever an object comes within a predefined range.

Thanks.
Title: Re: Manual calibrate Sharp IR
Post by: Admin on March 16, 2008, 08:04:46 PM
1) Check the datasheet

and if its not in there already . . .
2) make a chart by measuring distance vs signal from your ADC (using UART)

now using data from 2), either make a lookup chart, or put it into an equation:
http://www.societyofrobots.com/sensors_interpret.shtml
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 17, 2008, 06:10:55 AM
what do u exactly mean by calibration?
you just have to wait a fixed amount of time after the sensor is setteled in a position then you read the value using adc.
this time is mentioned in the datasheet and its about 50 ms
Title: Re: Manual calibrate Sharp IR
Post by: javafiend on March 17, 2008, 09:12:56 AM
Ok, sounds like the first thing I need to do is set up UART for my bot.  Back to the tutorials for me ;)


EDIT::
Uh oh, just peaked back at the UART tutorial and noticed that TX and RX are on the same pins as my servos.  I'm running four wheels and ultimately using all five pins for servos.  How can I use UART and run all of them at the same time?
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 17, 2008, 10:29:51 AM
why the heck dont you change the servos controls into another port ?????????
Title: Re: Manual calibrate Sharp IR
Post by: javafiend on March 17, 2008, 01:25:23 PM
why the heck dont you change the servos controls into another port ?????????

Because I'm running 5 servos and only have 5 ports.  Am I missing something on the $50 robot board that gives me expanded space for servos?
Title: Re: Manual calibrate Sharp IR
Post by: airman00 on March 17, 2008, 01:40:20 PM
there are unused pins on the AVR microcontroller used in teh 50 dollar robot
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 17, 2008, 01:42:54 PM
calibration means findinout out what ur mcu reads for different values of distance now how u do it??/

keep ur sharp ir at a known distance and using uart see wats the reading of ur mcu keep doing this at different distances and find out the trend in the readings

ex-

distance              reading
      10 cm               90
      12 cm               100
      14 cm               120
      18 cm               150

draw a graph using these readings by taking distance in the X axis and Reading in the Y axis and suppose u have to avoid something within a distance of 6 cms then take 6 cms in The X axis and find out corresponding reading

use that value in the code and thats wat calibration means

and about the  TX AND RX ,try to make the yart circuit on another breadboard and use ur mcu there for the calibration


Title: Re: Manual calibrate Sharp IR
Post by: benji on March 17, 2008, 05:05:22 PM
Quote
Because I'm running 5 servos and only have 5 ports.
as long as i believe a servo only need one pin to control it
so as long as you have 5 ports only , you can control up to 5*8 = 40 servos only ;D
Title: Re: Manual calibrate Sharp IR
Post by: airman00 on March 17, 2008, 05:08:42 PM
Quote
Because I'm running 5 servos and only have 5 ports.
as long as i believe a servo only need one pin to control it
so as long as you have 5 ports only , you can control up to 5*8 = 40 servos only ;D

thats 8 servos per pin ONLY if you buy an external servo controller

what javafiend want is for the microcontroller to control the servos directly
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 17, 2008, 05:24:37 PM
doesnt he mean motors like the hitec ones? which have an embedded driver ?if no
why dont you buy one of those as they are cheap and easy to use??
making your own servo driver is a whole project itself
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 17, 2008, 10:19:05 PM
well servo control is quite easy, u should not have any problems at all and abt the motor driver ya using it is difficult but not impossible , it can be done too
Title: Re: Manual calibrate Sharp IR
Post by: javafiend on March 18, 2008, 07:36:49 AM
So what I'm hearing is that I should use UART to just get the initial sensor data for calibration.  If I wanted to keep UART constantly connected, I would need a separate servo controller.

Now what is this about each pin being able to control 8 servos?  Can someone point me to something showing how this works and is implemented - both hardware and software?
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 18, 2008, 08:13:56 AM
Quote
Now what is this about each pin being able to control 8 servos? 

1 pin controls 1 servo ,1 port controls 8 servos

when you say 1 pin controls 8 servos this means that you are using the same control signal to all servos
so the 8 servos would act the same
i dont think you meant that anyways.

check the website for more info about servos
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 18, 2008, 09:07:43 AM
well u dont need to connect the usart always , just do ur sensor calibration in another ckt by using uart then use them in ur program

and do u understand the difference between port and pin????

8 pins === one port

like portd which has pins from 0-7
Title: Re: Manual calibrate Sharp IR
Post by: javafiend on March 18, 2008, 09:43:40 AM
and do u understand the difference between port and pin????

8 pins === one port

Quote
Because I'm running 5 servos and only have 5 ports.

Ah, that may be where I originally confused the issue.  I should have said I only have 5 pins.
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 18, 2008, 11:55:52 PM
i really reccomend usig a breadboard to make the usart circuit and testing ur sensors there
Title: Re: Manual calibrate Sharp IR
Post by: paulstreats on March 19, 2008, 05:17:19 PM
If you are using the board from the $50 robot. There are mcu pins not connected up to anything. Its up to you to add more headers to connect them up.
look at the picture below:

(http://www.societyofrobots.com/images/sbs_avr_schematic_small.png)

pins pc0,pc1,pc2,pc3,pd2,pd3,pb0,pb1,pb2,pb3,pb4,pb5,pb6,pb7 arent connected to anything. They can all be connected to extra headers for you to use for servo's etc..
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 19, 2008, 10:55:34 PM
yes andtry uising usart
Title: Re: Manual calibrate Sharp IR
Post by: Admin on March 23, 2008, 08:33:49 AM
In addition to what paulstreats and airman00 said, you can also use the analog ports to control servos - you just need to reconfigure them to digital ports in software (sor utils file explains it).

You can control like ~14 servos I think with the $50 Robot (I didn't count, but its around that number).
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 25, 2008, 06:44:49 AM
analog port means the analog to digital converter pins isnt it?
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 25, 2008, 10:31:37 AM
no , i guess admin meant the digital to analog ones, which are related to the timer(called pwms)
Title: Re: Manual calibrate Sharp IR
Post by: paulstreats on March 25, 2008, 11:13:28 AM
you can use the analogue input pins. you just need to configure them as digital i/o and set them to output
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 26, 2008, 06:54:30 AM
ook thats easy to do by software
Title: Re: Manual calibrate Sharp IR
Post by: javafiend on March 26, 2008, 09:41:48 AM
It sounds like the microcontroller pins are kind of multi-purpose.  For example, I was concerned about using PB6 and PB7 (XTAL1 and XTAL2) for anything besides whatever XTAL is.  Perhaps I am in over my head :(
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 28, 2008, 04:59:34 AM
for ur 1st bot or whatever...
always remember the KISS principle or ull end up with a robot whose motors even dont turn properly
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 28, 2008, 09:16:28 AM
what is this KISS principle?
Title: Re: Manual calibrate Sharp IR
Post by: airman00 on March 28, 2008, 09:20:08 AM
what is this KISS principle?

Keep It Simple Stupid
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 28, 2008, 09:25:45 AM
Quote
what is this KISS principle?


Keep It Simple Stupid

lol ,, tricky one
Title: Re: Manual calibrate Sharp IR
Post by: superchiku on March 28, 2008, 09:50:58 AM
hmm... really really Tricky
Title: Re: Manual calibrate Sharp IR
Post by: javafiend on March 28, 2008, 12:38:56 PM
I'm not sure what to google for to find examples of pins being used for more than one thing.  Can anyone help me out or throw out a link or two?
Title: Re: Manual calibrate Sharp IR
Post by: benji on March 28, 2008, 03:51:05 PM
its all in the datasheets
check some mcus datasheets