I would like to know how to read a pulse width with the digital sidecar DIO. Any one know how to do this?
Can you give a bit more detail about why you want to do this, what type of sensor you are getting the signal from, what is the range of widths you want to measure, and what is the period of the pulses ? It has a bearing on the answer.
ok here is the code and the spec. I threw something together using timers, but I was wondering if there is a better way. This is basically using PWM.
GP2Y0D805Z0F.cpp (1.4 KB)
GP2Y0D805Z0F.h (625 Bytes)
GP2Y0D805Z0F.pdf (59.7 KB)
GP2Y0D805Z0F.cpp (1.4 KB)
GP2Y0D805Z0F.h (625 Bytes)
GP2Y0D805Z0F.pdf (59.7 KB)
Try opening the “PDF” file you attached.
Guess its corrupt. Here it is again.
GP2Y0D805Z0F.pdf (365 KB)
GP2Y0D805Z0F.pdf (365 KB)
What are you trying to use this for ?
Please give some details about what you want to accomplish.
One application is to see if something is there. That works good with this code. But I would like to use it to see frisbees going by and knowing if they are backwards or not. There is a problem with using that code for distance. For example if I put “Wait(0.05);”, then it changes my values.
Can you be just a bit more articulate? I could guess what you mean, but I’d probably guess wrong.
If I’m reading that datasheet correctly (it’s hard to be certain of that), then your sensor there is just a simple proximity sensor. It will only switch on when an object is in detection range, and off when it’s not. There’s no pulsing or anything to indicate the actual distance of the object. Atleast, I don’t see any indication of that, for all that it talks about triangulation. Do you have some way of measuring the output to confirm that it’s giving you a PWM signal and not just off-on?
I’m using it as proximity now. I love the size! I have a few of these. If I print the “Get” function then i get a number that goes up and down according to distance from the sensor. However, the values change according to how long the loop takes. So if I add a “wait” to the teleop loop, the values from the sensor change because I’m taking too long to read the pulses to accurately measure the off time.