Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
8 years ago

implementing distance sensor in my code

Hello all,

I really need your help, i'm kind of in the dark here

i want to implement 'Sharp's' Distance sensor {DataSheet attached} in my project

and i honestly don't know where to begin coding.

If to look at the great picture - i want to be able to know when the object is 20 CM from the sensor and then perform an action( turning LED or anything else).

can anyone please guide me? or giving me something to read? any video i can watch?

it will be highly appriciated!

i'm using DE2-115, BTW.

8 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I hope you're intending to use the digital version of the sensor - which does all the work for you. Connect 'Vo' to a spare I/O on your DE2 board. In the FPGA you can drive an LED directly from this signal.

    Cheers,

    Alex
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Alex,

    can you ellaborate?

    what do you mean the digital version?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Exactly. Connecting the analogue version to the DE2-115 won't be easy as the board doesn't have any ADC's on it. Assuming you have the choice, use the digital version.

    Cheers,

    Alex
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Alex,

    just ordered the digital version of the sensor,

    what's next ?

    :)

    how can i get indication of how distant is the object?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thank you alex!

    if i understood you correctly, it will trigger a led light as it 24 cm far from an object.

    but would i be able to drive an output on my FPGA board when i realize an object is exactly at, let's say 20 cm?

    i dont really understand how to monitor the incoming signals and process them.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    With the digital version you're limited by the sensor - it will only give you an edge when it's a specified distance away (see the datasheet).

    To measure the distance of the object you need the analogue version and to use the Vo signal from that you need an ADC, which the DE2 board doesn't have. You would have to add an external ADC to that board or use another development board with an ADC.

    Cheers,

    Alex