View Single Post
  #3   Spotlight this post!  
Unread 23-01-2014, 15:20
Peter Cudmore Peter Cudmore is offline
Mentor
FRC #3543 (C4)
Team Role: Teacher
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Arnprior
Posts: 5
Peter Cudmore is an unknown quantity at this point
Re: Programming MaxSonar EZ1 Ultrasonic Rangefinder in Simple Robot Template

We used analog coming out of the 9201 module in the rio wire red to +5 black to fend and the signal to an on the sensor

I have some new coders so I am not bothering with subroutines so we just put the commands in the main program. So this is inelegant code but it works.



float volt,inches;
AnalogChannnel *range ;


Range =new AnalogChannel(1,1);

The command to call and convert to inches is
volt = range ->GetVoltage();
inches = volt/0.009766;

That is the conversion factor and for us seems quite accurate within 3 feet.
Just use inches wherever you need the range data

We can't seem to get readings above that so if anyone has a suggestion for boosting the power of his device to the supposed voltage of 5v I would appreciate an answer to that.
Reply With Quote