49Views3Replies

Author Options:

how to control ultrasonic the servo should be steady if not detected by hands,upon closer your hand servo is get faster? Answered

i need a code for ultasonic motor, controlling the servo motor. it should be steady if not detected by hand, and upon your hands getting closer to the ultrasonic the servo mototr getting faster. thank you

3 Replies

user
iceng (author)2017-09-19

Execute this unique simple algorithm..

As the echo return time is collected use that value directly in the motor OFF PWM timer...

Example ; Your hand is coming closer and the return time is shorter and the motor off time is shorter, which means the motor has more power, which makes the motor run faster !

Easy coding in any language Especially Assembly :-)

Select as Best AnswerUndo Best Answer

user
iceng (author)iceng2017-09-19

Yes you need to set some limits..

A limit when the return is from so far away that the audio signal is too weak to be heard by the transducer and the time is effectively OXO infinite = any off time greater then minimum RPM is set to minimum RPM..

Figure out what to do when a return arrives while the Chirp signal is still leaving is for you to solve, have fun !

Select as Best AnswerUndo Best Answer

user
rickharris (author)2017-09-19

More information:

Processor, Ultrasonic unit, Servo type.

This seems fairly simple can you not modify some existing code library?

check US time delay

Calculate distance

Is distance <> a set amount

IF less then move servo.

You will need PWM routines if you want to control the speed of a DC motor.

Select as Best AnswerUndo Best Answer