Author Topic: sharp IR math  (Read 4483 times)

0 Members and 1 Guest are viewing this topic.

Offline BANETopic starter

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
sharp IR math
« on: July 16, 2008, 04:44:24 PM »
Hello, this is really simple.  I have a sharp IR sensor thats value is set to a byte.  What i want to do is convert this number to inches and the tricky part (what i really wanted input on) if you can make a program filter or decipher or something sense objects lease than 6".  Any ideas?

Bane

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: sharp IR math
« Reply #1 on: July 16, 2008, 04:50:56 PM »
http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html

note: in the results section the math is based on 10-bit a2d where on the $50 robot mcu is using 8-bit

however in the avrlib a2d.h file there are functions for both.

Offline bens

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 335
  • Helpful? 3
Re: sharp IR math
« Reply #2 on: July 16, 2008, 04:55:35 PM »
Figure out what voltage your sensor outputs when something is 6" away and have your program do something if the output voltage ever equals or exceeds that amount (assuming that by "lease than" you really mean "less than").

- Ben

Offline vidam

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: sharp IR math
« Reply #3 on: July 16, 2008, 07:46:33 PM »
Here is a related question. I've been using hex workshop and parsing the file. I often get confused on when to use a byte or unsigned int or short to fit the data into structures that I'm parsing. Little endian also screws me up. Can anyone explain when to use these data types for different fields in a hex file.

Thanks,

Offline bens

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 335
  • Helpful? 3
Re: sharp IR math
« Reply #4 on: July 16, 2008, 10:22:32 PM »
Why are you working directly with hex files?

Offline vidam

  • Supreme Robot
  • *****
  • Posts: 423
  • Helpful? 1
  • Robotronics.org
    • DC/MD/VA Robotics and Automation Team
Re: sharp IR math
« Reply #5 on: July 16, 2008, 11:14:53 PM »
I work with hex files to reverse engineer and troubleshoot products.

Offline bens

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 335
  • Helpful? 3
Re: sharp IR math
« Reply #6 on: July 16, 2008, 11:33:31 PM »
If you're looking at the flash hex file, it contains machine instructions.  You basically need to figure out how to generate the assembly from it.  Open it in AVR Studio and it will do this for you.  I don't think you're going to achieve anything all that productive by trying to troubleshoot or reverse-engineer hex files directly.  I imagine you could probably write the program itself faster than you could decode the hex and figure out how the assembly works.

If you're looking at EEPROM hex, it contains data in whatever format the user decided to store it in.  There's no way to tell from the hex file itself what the data means or what the data types are.

- Ben

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,704
  • Helpful? 173
    • Society of Robots
Re: sharp IR math
« Reply #7 on: July 17, 2008, 05:52:30 AM »
BANE, you can use my code straight from my Axon software:
http://www.societyofrobots.com/robotforum/index.php?topic=2822.msg36335#msg36335

 

SMF spam blocked by CleanTalk