Spring Effect using revolute Joint

I am trying to get spring effect using revolute Joint. Basically i have attached a wooden log to a bolt using revolute Joint , I want it to oscillate between some 0 to 30 deg.

I am trying like this

Code:
float speed = aSpringPlatformJoint->GetMotorSpeed();
        float angle = aSpringPlatformJoint->GetJointAngle();
        if((speed < 0.0f  && angle <= aSpringPlatformJoint->GetLowerLimit()) ||
           (speed > 0.0f  && angle >= aSpringPlatformJoint->GetUpperLimit())
           )
        {
            // reverse motor speed whenever we overshoot limits
            aSpringPlatformJoint->SetMotorSpeed(speed * -1.0f);
        }



However it is not smooth and natural . Suppose some other body falls on the wooden log then it should oscillate more like a spring , how can we achieve this.
Thanks
It might be easier to use a distance joint, with the frequency and damping ratio set appropriately.
Thanks for your reply .

I tried this solution this works pretty well

Code:
 float angle = aSpringPlatformJoint->GetJointAngle();
 aSpringPlatformJoint->SetMaxMotorTorque(750);
 aSpringPlatformJoint->SetMotorSpeed(angle > 0 ? -200 : +200);



Can u explain how we can use distance joint to achieve this
I came across this thread
http://box2d.org/forum/viewtopic.php?f=3&t=7545
But i didn't find the solution ..
This one might be useful
http://box2d.org/forum/viewtopic.php?f=3&t=7211&p=31810

Original thread: https://box2d.org/forum/viewtopic.php?t=8847