Shop OBEX P1 Docs P2 Docs Learn Events
Can Sharp GP2D12 proximity sensors be used with Prop chips without additional h — Parallax Forums

Can Sharp GP2D12 proximity sensors be used with Prop chips without additional h

noobmunchernoobmuncher Posts: 124
edited 2009-12-26 14:42 in Propeller 1
Hello,

So I have a few Sharp GP2D12 proximity sensors laying around and also a Digital Infra-Red Rangefinding (DIRRS+) version.
Will both types work with the propeller chip without additional hardware? If so does anyone have code samples that will work with whichever will work?

[noparse]:)[/noparse] Thank you!

Comments

  • LeonLeon Posts: 7,620
    edited 2009-12-24 10:58
    URLs?

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • Mike GMike G Posts: 2,702
    edited 2009-12-24 13:13
    An analog to digital converter (A/D) is needed to convert the GP2D12 analog output to a distance reading. The GP2D12 datasheet has a lot of really good info.

    There are several A/D examples on the object exchange http://obex.parallax.com/objects/category/9/
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-24 19:19
    So these objects will work to convert it then? Or are they just to work with A/D converter?
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-24 21:42
    Here is the code that I am trying to emulate in spin, this is a bs2 program to output the distance into a terminal window.

    '{$STAMP BS2}
    '********************************************
    'HVW TECHNOLOGIES INC.
    'DIRRS Plus demo software version 1.0
    'Date: March 2000
    'Author: Dan Henne
    'www.HVWTech.com
    '********************************************
    '
    '********************************************
    'This software is used with the DIRRS Plus when it is configured
    'for Original DIRRS mode. The input from the DIRRS Plus is
    'triggered by a high low transition with the resulting
    'distance measurement shifted into the DIST variable.
    '********************************************


    DIST VAR BYTE 'Variable used to store DIRRS result
    T VAR BYTE
    clock CON 1
    datain CON 0

    OUTPUT clock 'Pin 0 connects to Pin 2 of DIRRS Plus
    INPUT datain 'Pin 1 connects to Pin 4 of DIRRS Plus

    START:
    High clock 'Start Vin must have high-low transition
    Pause 3 'Wait for high to be recognized
    Low clock
    For T= 1 to 30 'Begin 30 ms wait
    Pause 1
    If IN0=1 Then JUMP
    'If Vout is HIGH, measurement is complete -jump
    Next 'Measurement not complete, wait another 1 ms

    JUMP:
    Shiftin datain,clock,2,[noparse][[/noparse]DIST\8]
    'Shift 8 bits into DIST via pin P1, clocking with P0, MSB first
    Debug "Distance= ", dec DIST,cr
    'Display distance (in decimal form) in debug window
    Goto START 'Start over
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-12-24 23:17
    That code is for a version of the Sharp sensors that had a digital output. It is not for a GP2D12. The output pin from the GP2D12 will be seen by a Propeller as transitioning from high/low at one fixed distance.

    John Abshier
  • SRLMSRLM Posts: 5,045
    edited 2009-12-26 02:35
    If you use the MCP3208 ADC chip then there are several good objects that you can use, depending on the number of channels that you need: obex.parallax.com/objects/search/?q=MCP3208

    Plus, Parallax sells the MCP3208 ADC chip.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Powered by enthusiasm
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 03:38
    John, yes I know it is, I have 1 digital output one which I linked to earlier in the thread and am trying to use as well. SRLM thanks i might order one of those so I can use these, one of the microcontrollers I used to use must have had A/D built in and I just didn't realize it.

    But my question still remains, if anyone has any ideas for outputting distance to a terminal from a digital sharp sensors (such as this one www.hvwtech.com/products_view.asp?ProductID=91) it would be much appreciated. smilewinkgrin.gif
  • TubularTubular Posts: 4,717
    edited 2009-12-26 03:47
    noobmuncher,

    This thread from a year ago involved interfacing 24 of the "analog" sharp sensors to the prop via 3 MCP3208's (as SRLM suggested).
    http://forums.parallax.com/showthread.php?p=772040

    There's code there too
  • noobmunchernoobmuncher Posts: 124
    edited 2009-12-26 03:59
    This should work great, thanks you!
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-12-26 14:42
    I just looked at the link to the DIRRS+ page. I did not download the product manual. It supports asynchronous serial. For that you could use simple serial or full duplex serial. It also supports synchronous serial. That would use code similiar to what you posted earlier. The key is to read the DIRRS manual and the sample code.

    John Abshier
Sign In or Register to comment.