LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control the ultrasonic sensor using two available digital pins?

Hi,
 
in my project I will create a sensor block to be imported into NXT software for a RGB color sensor, which would have to use both of the two digital pins i.e. pin 5 and pin 6 of the input port on the NXT brick. I've already checked the hareware schematic of the ultrasonic sensor, and found that those two pins are connected to the build-in I2C bus, one of them is the so-called SDL(Serial Data Line), and the other SCL(Serial Clock Line).
 
Could some one tell me how to control the ultrasonic sensor by using those two digital pins and how does the corresponding sensor block look like?
0 Kudos
Message 1 of 5
(8,218 Views)
Hi Lee,

in my project I will create a sensor block to be imported into NXT software for a RGB color sensor, which would have to use both of the two digital pins
 
Could some one tell me how to control the ultrasonic sensor by using those two digital pins and how does the corresponding sensor block look like?

Whether you're creating a device to connect to "the Brick", or understanding how the Ultra-sonic sensor is used, it would probably be good to understand the I2C protocol.  The attached pdf from Phillips is pretty thorough, though there are more "friendly" instructions on the web.

Basically the Brick, acting as I2C master, tells an I2C slave to send some data; the master (Brick) also supplies the "clocks" for the data transfer.

For development, an oscilloscope will be very helpful - a logic-analyzer works well too.

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 2 of 5
(8,203 Views)

thanks for your advice, tbd Smiley Happy! Acturally, I want to connect a new developed RGB color sensor onto the NXT brick. You are right. I have to make it clear, how NXT brick works with sensors by using I2C protocol.

 

0 Kudos
Message 3 of 5
(8,196 Views)
Hi,

I've read the specification of I2C bus, briefly. But I'm still wondering, wether there're functions avaiable for the digital pin control, which are included in the NXT Toolkit. Of course, there're several APIs for low level NBC language, that could be useful for harware interfacing between NXT brick and custom sensors or other devices. However, is it possible to control the digital pins by using LabVIEW with NXT Toolkit, directly? That will be very kind if someone could release the code of a custom sensor block to be imported into NXT software.

0 Kudos
Message 4 of 5
(8,181 Views)

Hi Indianna,


I'm still wondering, wether there're functions avaiable for the digital pin control

Do you want to control the brick's port-pins like individual digital-IO lines?  If so, I don't know how - maybe some kind soul will help!

Note: The NXT-toolkit NXTSystemCall method: NXTCommLSWrite perfoms the two most fundamental I2C Write and Read operations.  NXTCommLSWrite performs an I2C write if "ReturnLength" is 0.  NXTCommLSWrite performs an I2C read if ReturnLength > 0 (NXTCommLSRead accesses the NXT's input buffer.) 

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 5 of 5
(8,174 Views)