|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Measuring a Pulse Width
I'm trying to measure the length of a pulse from a waveform generator to the mini-rc. The signal is a simple square wave; 5 Vp-p, 25 Hz. Unfortunately, I can't seem to get interrupts on the mini-rc to detect any of the edges.
I have the function generator directly connected to the mini-RC. I am verifying the signal on an oscilloscope. Unfortunately, I just can't seem to generate interrupts unless I am removing the PWM cable from the RC. Which makes me believe the software is working at least half correctly. I think it has something to do with the internal pull-up resistor inside the RC. Can anyone shed some light on this? Thanks. |
|
#2
|
|||||
|
|||||
|
Re: Measuring a Pulse Width
Quote:
I'm tired and should be studying analog filters for my exam tomorrow, so the only help I can offer now is the digital input schematic from Innovation First: http://www.ifirobotics.com/docs/anal...al--i-o-rc.pdf It doesn't look like the pull up resistor is messing your readings, unless you're actually using a square wave that swings 2.5 V up and below ground. Hope that didn't sound too confuse. |
|
#3
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
... just kidding. Measure the potential between the two grounds. If you see just a couple millivolts, you should be cool. |
|
#4
|
|||||
|
|||||
|
Re: Measuring a Pulse Width
Quote:
Quote:
|
|
#5
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
If I am reading the comment by Manoel and your response correctly, I have to assume you are injecting a 5vp-p signal running from +2.5 to - 2.5 vdc. If so, I would say you have a -2.5vdc off set. This could work if the electronics in the mini-rc consider anything above 2.4 vdc a high. But my guess is it won't. It probably needs something closer to 4.5vdc to be considered a high. Is there a way to adjust the offset to 0vdc? That way your signal will be running from 5vdc to 0vdc. Therefore, the mini-rc will see a high of greater than 4.5 vdc and a low of less than .5 vdc. Both should be good values for high and low. |
|
#6
|
|||||
|
|||||
|
Re: Measuring a Pulse Width
Quote:
|
|
#7
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
|
|
#8
|
|||||
|
|||||
|
Re: Measuring a Pulse Width
Quote:
Quote:
![]() ![]() Anyway, you are really using a 5V pulse train and my initial concerns were pointless. Which leaves me without ideas of what is going on. ![]() Could you possibly hook the waveform generator to an optoisolator just to make sure there's nothing else interfering? |
|
#9
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
When I asked about th offset, the reason was that an offset of 2.5vdc can prevent a circuit from ever seeing a transition from high to low or low to high. Here's why. Lets assume that the interrupt, or digital, input on the mini-rc identifies a signal as a high when it is above 4.25vdc and a low as below .5vdc. Now a 5v p-p signal with a 2.5vdc offset is running from 2.5 to 7.5 vdc. So, it never sees a level below .5vdc and therefore never sees a low. On the other hand, if the offset is -2.5vdc, the signal runs from -2.5vdc to +2.5vdc, so the input never sees a high. In either case, the pulse train never cycles the input high and low so that neither the rising nor falling edge can be detected. If, in fact, the signal at the input is connected as Mike indicates and the signal is running from 0 vdc to 5vdc, then I too am at a loss as to what is the problem. BTW, I am not building this, Mike D. is. Mike, I was also wondering if you could just run the signal to a small transistor circuit that just short the signal input to gnd, and released it back to 5vdc instead of running the signal generator directly to the input. This would eliminate any problem with the signal generator being able to sink the needed current to pull it low. (This shouldn't be an issue, but I have seen stranger things) It will also isolate it like the opto that Manoel suggested. In fact, the opto isolator would be easier to implement. |
|
#10
|
|||||
|
|||||
|
Re: Measuring a Pulse Width
I'm almost 99% sure that the signal runs from 0Vdc to 5Vdc. Tomorrow morning, when I am back in my school's lab, I will verify that this is completely true.
For some background, I am attempting to write software for the Parallax Inc. PING))) sonar sensor. The pulse width of it's response corresponds to the distance between itself and an object. Currently, I am using bench top equipment to operate the PING))). A function generator triggers the PING))) to measure and an oscilliscope measures the returning pulse width. The sensor is accurate wthin an inch. At only $25, this sensor looks very exciting for FIRST applications. The difficulty in this project is the mini-RC signal pin will be both an output and input. I have been able to trigger the sensor from the RC. Unfortunately, the mini-rc hasn't been capable of reading the response. By simulating a response from the sonar sensor using the function generator I am hoping to isolate the problem in my code. Last edited by MikeDubreuil : 12-07-2005 at 16:04. |
|
#11
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
Wow, that is a cool little sensor, and low cost as well. I like the simplicity of it's design and operation. I can see your difficulty with using the mini-rc I/O as both an I and an O. This is what I might try: Use a second I/O as and output to trigger the PING))). Tie it to the same input pin as the input you are using, then write your code to ignore the triggering 2 to 5 micro second pulse. Only allow it to sample a pulse longer than 100 micro seconds. (It looks as though the minimum pulse width from the PING))) is 115 micro seconds.) Now, if you can figure out how to switch the I/O from out to in and back, then your job gets easier. Let us know how your testing goes and how the project as a whole turns out. |
|
#12
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
-Kevin |
|
#13
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
-Kevin |
|
#14
|
||||
|
||||
|
Re: Measuring a Pulse Width
Quote:
. Some generators have a selection for coupling, AC/DC, much as a scope has. In AC, there is no offset and the signal is averaged around 0 vdc. In DC, you set the amount of offset, + or - relative to 0 vdc. Your correct, when DC coupled, a +2.5vdc offset would be needed to shift a 5vp-p signal to run from 0vdc to 5vdc.Thanks for the link to the IR receiver code. I have been wanting to learn more about CCP functionality and usage. This should go a long way in building my understanding. Now that I've learned a wee little bit about C, I can at least follow most of what is happening. |
|
#15
|
|||
|
|||
|
Re: Measuring a Pulse Width
Function generators? Scopes? All that to try and get a FRC to use a sonar range sensor? Most pic basic interpreters and compilers have a pulse in and pulse out function in the language. The stamp sample code is very easy but, with the FRC and C this common simple device is giving people fits. I have a Daventech SRF04 which is very similar to the stamp device except it has a separate trigger and pulse pin. I soldered 4 wires to it. Plugged it into a bread board with a Pic 18F452 basic interpreter chip and wrote the following code.
func main() dim range loop: sonar 0,1,range print "Distance=",range/64,"inches" pause 20 goto loop endfunc In about 1 hour I was testing it out. This post points out a major problem with the FRC as it is now. EE's love it, non professionals fight it. I don't have any answers but, to take First further with sensors and autonomous mode, something needs to change. The challenge to sensors should not be the hardware-software implementation but, the application of the info they give us to come up with strategies for the game. Too many teams this year chose an autonomous mode strategy of doing nothing. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |
| printf bug - beware! | WizardOfAz | Programming | 8 | 10-03-2004 09:50 |
| SHU measuring stick | sanddrag | Rules/Strategy | 13 | 08-01-2003 21:23 |
| does center barrier have lumber on floor entire width? | archiver | 2001 | 5 | 23-06-2002 22:45 |
| PUlse counting | junkyarddawg | Technical Discussion | 1 | 31-01-2002 15:33 |