I am using the vex sonic
I am giveing him a 1 us trigger from a fpga de2
and when I check the returned pulses in the scope I get that if there is no obstacle the pulse length is about 47ms from it 37.4 ms is the ‘1’ state meaning
a distance of about 6 [m] which is logical becuase it’s max range is 3 [m] .
as long as the sensor output leg is at high logic triggering won’t do nothing right ?
so in my code i need to give the sensor a trigger once every ~50 ms if no obstacle was detected and if an obstacle was detected I need to give faster triggering depanded on the distance of the obstacle right …
correct my if I am wrong becuase I just can’t seem to make it work with my program
There is no need to change the frequency of checking the sensor.
Starting a distance check once every 50ms should be fine.
If you set up a sonic reflector at 1 meter,
and give a single input 1us pulse
do you get a single output high pulse, with the high pulse length is proportional to the distance?
If you have no sonic reflector, the output high pulse length is 37.4ms (you said) which represents the max range. The output low pulse width is controlled by how often you trigger it with an input, right?
I don’t know the sensor well enough, but I wouldn’t jump to that conclusion,
so unless you test it yourself, I’d suggest avoiding starting a new distance conversion if the previous one is still in progress.
Thanks for the replay
I didn’t check the forum for some time now.
The last time I checked the sensor code it was working and I was even able to change detection distance I am now in the process of including another motor and optical encoder to my state machine that works for motion
The addition is for angle control
I want to see how the angle encoder is reacting and its actual resolution (suppose to be 4 degree).
About the sensor I am sure from the tests I have made that as long that the sensor didn’t get a returned pulse or a distance of 6 m hasn’t pass its leg will stay in one logic and the sensor won’t react for another trigger.
The down time I mention was because I give pulse every 50 ms so the triggering time minus distance from the obstacle is the down time and according to that I can give a 40 ms triggering time.
and your right there is no need to change triggering time but it can be more efficient to immediately send another trigger after I got a obstacle warning or after max time as pass - so in this case changing the triggering time is ok.