Log in

View Full Version : How to read a pulse?


enrique
25-02-2013, 17:36
I would like to know how to read a pulse width with the digital sidecar DIO. Any one know how to do this?

Ether
25-02-2013, 17:44
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.

enrique
01-03-2013, 23:56
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.

Ether
02-03-2013, 00:50
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.

Try opening the "PDF" file you attached.

enrique
02-03-2013, 09:46
Guess its corrupt. Here it is again.

Ether
02-03-2013, 10:25
Guess its corrupt. Here it is again.

What are you trying to use this for ?

Please give some details about what you want to accomplish.

enrique
02-03-2013, 10:32
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.

Ether
02-03-2013, 10:47
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.

Kevin Sevcik
02-03-2013, 10:56
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?

enrique
03-03-2013, 22:15
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.