go away spammer

Author Topic: 50$ robot software tweak  (Read 2870 times)

0 Members and 1 Guest are viewing this topic.

Offline MojaveTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
50$ robot software tweak
« on: May 26, 2008, 11:12:29 AM »
Hello, everyone!

I've built the 50$ robot and everything seems to work fine, except for the fact that i must've gotten the most insensitive photoresistors available. The problem with that is that the integer type under which sensor_left and sensor_right are declared in the source code isn't enough to make a difference, since whatever minute decimal difference there might be between the two readings, is truncated along the way.
So i was wondering if anyone could help me out with a conversion to a float type instead of int. I'm guessing the a2dConvert8bit is responsible for the straight-to-integer conversion, since there's no explicit cast to int, so if anyone could tell me what I could replace that with in order to get a more precise reading, I'd greatly appreciate it.

Thank you in advance

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: 50$ robot software tweak
« Reply #1 on: May 26, 2008, 12:59:33 PM »
The problem is due to the fact that the variance in resistance of your photoresistor is insignificant compared to the resistor value that it is in series with (ie the resistor you soldered onto one leg of your photoresistor) - so the voltage changes you get are very small. Floating point isn't any help - as the analogue to digital convertor will always return integer values - so storing them in a floating point variable will just make you code much bigger but not solve the problem.

If you still have a spare photo resistor of the same make/model  (or can get at the leads of one of your assembled photoresistors) and a multimeter then measure the resistance across the photoresistor when it is in the dark(est) place  and when it is in the light(est) place. Then replace the fixed resistor with a new resistor around the half way point. So if your photresistor varies from 1k to 10k then choose a resistor around 5.6k.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline MojaveTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: 50$ robot software tweak
« Reply #2 on: May 26, 2008, 02:56:51 PM »
Thank you for your answer, Webbot.
Fortunately, after soldering the photoresistor and the regular resistor together on each "eye", i just used duct tape to hold them in place, so it's hardly any trouble at all removing that to get a reading and then replace the resistor with a more appropriate one, so I'll be sure to try that.

Thanks again!

Offline Conscripted

  • Robot Overlord
  • ****
  • Posts: 291
  • Helpful? 10
Re: 50$ robot software tweak
« Reply #3 on: May 28, 2008, 11:13:12 PM »
Fortunately, after soldering the photoresistor and the regular resistor together on each "eye", i just used duct tape to hold them in place, so it's hardly any trouble at all removing that to get a reading and then replace the resistor with a more appropriate one, so I'll be sure to try that.

Is Duct tape conductive?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 50$ robot software tweak
« Reply #4 on: May 30, 2008, 08:00:56 PM »
Just use this tutorial to calculate the resistor value:
http://www.societyofrobots.com/schematics_photoresistor.shtml


The ATmega can do 10 bit ADC conversion, but those last 2 bits usually end up being noise unless you know what you are doing when designing the circuit. If you look at adc.h, you will see how to do the 10 bit conversions.

 


Get Your Ad Here

data_list