Ultrasonic motion sensor.... Help!!

Discussion in 'Embedded Systems and Microcontrollers' started by russel096, Mar 2, 2013.

  1. russel096

    Thread Starter New Member

    Jan 2, 2012
    10
    0
    hello everyone,,

    here's the thing.. we are making a motion sensor project for our course requirement, we got the whole concept from the internet (schematic, codes etc.) you can visit the link (http://electro-mcu-stuff.blogspot.com/2011_05_01_archive.html) to see what it does...

    the problem is,, our professor wanted to replace the sensor used (which is supposed to be an IR sensor) with a ultrasonic sensor.. and i cant revise the code myself for this sensor... I've tried and failed again and again...

    how should i retype the code... all help would be very much appreciated.

    here's the code by the way... (one factor is that its too long for me to understand...)
     
  2. russel096

    Thread Starter New Member

    Jan 2, 2012
    10
    0
    also with the ultrasonic sensor... it would be nice if the trigger distance would be 10cm.
     
  3. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    If I read your code correctly, your proximity sensor has a Boolean state that represents presence or no presence.

    This is dependent on the variables PAIN and BIT_SET_3. I guess BIT_SET_3 is a mask enable, but I cannot locate any other PAIN reference. In other words, I cannot see how you actually read your proximity sensor.

    Regardless of your implementation, the use of an ultrasonic sensor can be very easy. Most models will have an analog or PWM output, which are relatively easy to handle, especially the first.
    If your microcontroller has an A/D converter, simply compare the analog reading from your sensor with a reference value for 10cm and decide on the presence.

    It all boils down to your ultrasonic sensor selection.
    Personally, I have been relatively satisfied by the Maxbotix sensors.
     
  4. russel096

    Thread Starter New Member

    Jan 2, 2012
    10
    0
    from the description of the author in the internet (where we got the project) i think he used a short range sensor so probably he didn't use any measurements on the distance?? (not sure)
    anyway,, your suggesting that i would test the sensor manually for the output voltage at 10cm then use a comparator to make a HIGH or LOW output from the sensor..?? (correct me if wrong)

    also Ive tried connecting the ultrasonic sensor without changing the codes.. its good that everything else works fine except for the servo which i havent connected yet but its always triggered (like its always sensing something) or always ON. Ive used the input and output ports used for the IR sensor for the Rx and Tx of the ultrasonic sensor...

    in any case, could there be a good reference for programming ultrasonic sensors and a good schematic for the ultrasonic sensor...

    BTW... i cannot find the IRF7343,, Ive read that the author only used it for switching off the servo to save battery life... can i just connect the servo directly to the z8f042A directly? would that be fine..? and the voltage regulator is not also available so im planning to use just 3V instead of 3.3V (the description of the MCU says that it can take 2.6-3.7V) for the final project... will it still work?

    thanks for the reply :)
     
  5. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    The ultrasonic rangefinders, such as the SRF-04, with separate Transmit and Receive transducers have a minimum range of about 10" (25 cm).

    You may want to look at the spec sheet for your ultrasonic device to find it's minimum range now, to save headaches later. The reason the distance is limited is to prevent near/mounting system echos, or resonance from transmission from triggering the receive.
     
    russel096 likes this.
  6. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    I don't think you will be able to simply replace the IR sensor with a Ultrasonic one.

    The IR sensor you are using has a digital HIGH/LOW output, simply based on whether the measured distance is greater or lower than 10cm.

    I 'm not aware of any similar ultrasonic sensor. Most will measure a distance exactly (in cm accuracy) and reply to you with that measurement. That may be in the form of an analog signal, serial (TX/RX) or I2C. In some cases, you have to enable the sensor for each measurement.

    For all of the above, a code/hardware refactoring is surely in order.

    The simplest solution would be to use a sensor with analog output, run it through a comparator (as you understood) and send that into you uC. But take into account thatoneguy's post.
     
    russel096 likes this.
  7. russel096

    Thread Starter New Member

    Jan 2, 2012
    10
    0
    I have read the datasheet of the US-100 ultrasonic sensor that i am using... It has a range of 2cm-350cm... But as i said 10cm would be a fine triggeing distance..
    It says that the distance of the detected object is based on the pulse width response on the Rx port... But im not sure how to count the time in secods with the ZDSII Z8 Encore that I'm with the codes...I have seen some examples of delay, it uses For loop but i dont think its in seconds...
     
  8. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    I know zilch about your particular uC. Try to find some ready examples on PWM decoding. Otherwise you 'll have to write an interrupt timing routine to measure the percent of the High Pulse yourself.

    Or buy another sensor, if that's an option.
     
  9. russel096

    Thread Starter New Member

    Jan 2, 2012
    10
    0
    I found a code but it uses a single pin for the Rx and Tx so its useless to me... Others are arduino based and i cant use it either.. i understand how it should work but cant put it into codes... Dont know how to detect how long the Rx is HIGH as the datasheet says that the width of the pulse on the Rx is directly proportional to the distance... I failed using just a normal timer with for loop... Also i think im having problem with utilizing just one pin on the ZDS II, like how do i put into an if statememt that port A3 is High without having to state the other pins... Like in PIC coding of if(PORTA3==0),, how is that in zilog coding?
    As for the PWN.. Ive read thr ZDS II Z8 Encore manual abour PWM, the codes is very long and i really cant understand it
     
  10. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Sadly, I don't have any experience with the ZDS family, so I can't help you there.

    I 'll move this to the microcontroller forum, where you might find some additional help.

    I 'll remind you of the option to change for an ultrasonic sensor with an analog output.
     
  11. russel096

    Thread Starter New Member

    Jan 2, 2012
    10
    0
    ok thanks for doing that doing that.. I'll search for an alternative ultrasonic sensor like you said..
    but anyone who knows ZDS II programming, please help! :)
     
Loading...