How can I set inch unit or metric(cm) unit to Sonar sensor?

View: New views
3 Messages — Rating Filter:   Alert me  

How can I set inch unit or metric(cm) unit to Sonar sensor?

by NXTelectroneer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am building a NXT remote control program but atempt a problem.

I am now success to reading sensors even ultrasonic(sonar) sensor.

But I want to set the sonar to imperial(inch) unit or metric(Centimeter) unit.

Or, want to know how to reading from the sonar in inch or cm unit.

Of course, I am reffered the Direct command documentation, Ultrasonic I2C protocol document...and so on

but it is so difficulty to understand and use it's contents.

anyway, I try it, but failure.

I also search for google and some famous LEGO NXT web site, but can't find exactly answer.

They say with some lib or tool like NXC, java, C++ lib... etc. but I don't have them.

What I want to know is the data give the sonar in LSWRITE command or in the return package.

aaaaaahh... I am tired... please let me know...

Re: How can I set inch unit or metric(cm) unit to Sonar sensor?

by Philippe Hurbain :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I am now success to reading sensors even ultrasonic(sonar) sensor.
>
> But I want to set the sonar to imperial(inch) unit or metric(Centimeter)
> unit.

The sensor itself returns only cm values. To use inches just multiply the result
by 100 and divide by 254 (1 inch = 2.54 cm, but since we are dealing with
integers we use 1/2.54 = 100/254)

Philo

Re: How can I set inch unit or metric(cm) unit to Sonar sensor?

by NXTelectroneer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Philippe Hurbain wrote:
> I am now success to reading sensors even ultrasonic(sonar) sensor.
>
> But I want to set the sonar to imperial(inch) unit or metric(Centimeter)
> unit.

The sensor itself returns only cm values. To use inches just multiply the result
by 100 and divide by 254 (1 inch = 2.54 cm, but since we are dealing with
integers we use 1/2.54 = 100/254)

Philo
Thank you very much your reply.

Have a nice day!! :)

NXTelectroneer