Does anyone have a successful Arduino C-code implementation of velocity detection using a CON RSM3650? If so, will you share it?
I have built an Arduino Nano controlled robot from a radio control model level car. My initial design uses two sonar proximity detectors to guide the car around the room counter clockwise looking down. I want the car to go faster. I need to calculate 'closing speed'. It appears that the RSM3650 has the capability and is not too expensive. What do you all say? How tough a job am I setting for myself?
By "closing speed" I assume you mean that you want to measure how quickly the car is approaching the wall and adjust its velocity proportionally, (no wall = full speed, approaching wall = slower and slower speed), correct?
You could estimate the car's velocity by calculating the difference between subsequent sensor readings (or an average of multiple subsequent readings b/c of sensor noise) and dividing it by the time between readings. Essentially, you are finding the numerical derivative of your position indicated by the sonar sensor readings. Then, you could increase or decrease the current to the car's motors based on how close you are to the wall.
To get the time between readings, try using the Time library, or more directly the now() function. Not sure what the resolution of the time is -- might only give you integer seconds as opposed to fractions of a second via a double or float, but it's worth a shot!