|
|
View previous topic :: View next topic |
Author |
Message |
Dargar
Joined: 12 Dec 2003 Posts: 25
|
Can I use CCP to do this, or do I have to use "brute fo |
Posted: Thu Sep 08, 2005 6:16 pm |
|
|
I'm looking into doing some ultrasonic measurments of strand-burning on propellants.
Basically I have this situation:
* I "chirp" the ultrasonic tranceiver for 15 micro second, then I "listen" for 60 micro seconds, then I chirp again, repeat while(1)..
I have some logic that basically gives me a +5V while (!Chirp) on A, and +5V when reflection comes back on B. Using some more logic, I get C = A xor B to give me a pulse thats +5V in the time between the chirp and the reflection. Now, just, for a second assume that C does all that... I need to measure the width of C as accurately as possible..
I am not sure, but it feels like I should be able to do this with the CCP? But honestly, my first idea was to just brute-force and look at a logic input pin, and when it goes high, start a high-res counter, when it goes low again, stop counting and store count for later. repeat. The counter would have to have a resolution in the 0.5 microseconds range to give accurate enough data. (2MHz for all those who like math as much as me..)
I glanced on the CCP part of the datasheet, but honestly, it confuses the heck out of me.
So, CAN the CCP do this, or should I just try to do the brute force way..
Thanks!
(I own the PCWH compiler, so everything up to the dsPIC is a valid target for this project..) _________________ Owner of PCWH v. 3.224
Consider myself beginer\intermediate as far as CCS and Microchip PIC's goes.
Bachelor in Space Engineering and Undergraduate Masters in Space Engineering
soon to be undergrad Aerospace |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Thu Sep 08, 2005 11:04 pm |
|
|
You can use 2 separate CCPs on your PC. The first one will be producing the envelope, which is on for 15us, and off for 60us. The second one will be producing the high-frequency carrier for the chirp. Then you just AND them.
If by “chirp” you mean a frequency sweep, then you need a for-loop, which will be changing the frequency in your CCP.
What's the frequency (or frequency range) of your chirp? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Sep 09, 2005 7:37 am |
|
|
If you are more comfortable with the brute force method, your PIC has the horsepower required, and you want to get the job done quickly and easily then that is what I would recommend.
If you want to learn to use the CCP then this is a good time it learn.
Assuming both methods work the only advantage to CCP is that the PIC is free to do other things while the CCP is running. Does the PIC have anything else to do during that time? There is nothing sillier than a uP spining in a while loop waiting for an interrupt! _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Guest
|
|
Posted: Fri Sep 09, 2005 8:58 am |
|
|
kender:
Either I am missunderstanding your post or I was not clear enough in mine... I think it is the later.
I've had some sleep, modified my thoughts a bit, and will try again:
Imagine 2 signals on 2 lines, A and B.
A = "high" for 15us, low for 60us high for 15us .....
B = Goes "high" when the A goes "high" and then goes low when the (correct) reflection comes back.
Signal B is generated by external logic (or at least that is how I imagined it now, since the reflection width will be very small and there is noise so I need to do level-triggering). Now, all I need to know is how long B was high, preferably with a resolution equal to or better than 0.5us.
As for the frequency of the "chirp", I do not know yet. An existing system I have seen uses a single pulse that is 20us long, I personally thought that ultrasound transducers had to be driven by some periods of a high frequency, for instance a "train" that is 20us long consisting of 100kHz sine or something.
The idea of sweeping is interesting, I might be able to use that to determine the optimum frequency while testing, but I have no need to sweep in the final application.
SherpaDoug
I would like to learn so I guess I can at least start out with using the CCP. As for other things to do, it needs to save the times and communicate with a computer. Prefarably it should be able to offload data (or save data) fast enough that it can be on continously. (then data-reduction can be done on the computer.)
In the datasheet they talk about how there are different "events" that can trigger the CCP... but I would need both the "trig on pos flank" as well as the "trig on neg flank" on the same pin to get the pulse width... and I cant see from the data sheet whether or not this is possible. -This is probably because I am not looking in the right place, so I will keep looking.
Thanks for your input! |
|
|
Guest
|
|
Posted: Fri Sep 09, 2005 8:59 am |
|
|
kender:
Either I am missunderstanding your post or I was not clear enough in mine... I think it is the later.
I've had some sleep, modified my thoughts a bit, and will try again:
Imagine 2 signals on 2 lines, A and B.
A = "high" for 15us, low for 60us high for 15us .....
B = Goes "high" when the A goes "high" and then goes low when the (correct) reflection comes back.
Signal B is generated by external logic (or at least that is how I imagined it now, since the reflection width will be very small and there is noise so I need to do level-triggering). Now, all I need to know is how long B was high, preferably with a resolution equal to or better than 0.5us.
As for the frequency of the "chirp", I do not know yet. An existing system I have seen uses a single pulse that is 20us long, I personally thought that ultrasound transducers had to be driven by some periods of a high frequency, for instance a "train" that is 20us long consisting of 100kHz sine or something.
The idea of sweeping is interesting, I might be able to use that to determine the optimum frequency while testing, but I have no need to sweep in the final application.
SherpaDoug
I would like to learn so I guess I can at least start out with using the CCP. As for other things to do, it needs to save the times and communicate with a computer. Prefarably it should be able to offload data (or save data) fast enough that it can be on continously. (then data-reduction can be done on the computer.)
In the datasheet they talk about how there are different "events" that can trigger the CCP... but I would need both the "trig on pos flank" as well as the "trig on neg flank" on the same pin to get the pulse width... and I cant see from the data sheet whether or not this is possible. -This is probably because I am not looking in the right place, so I will keep looking.
Thanks for your input! |
|
|
Ttelmah Guest
|
|
Posted: Fri Sep 09, 2005 3:06 pm |
|
|
I did a little ultrasonic rangefinder some time ago, and did the whole thing in a PIC12C508!. It generated the transmission train in software, paused for a moment (remember your system has to ignore the signal that arrives by direct coupling through the board from the transmitter to the receiver), then looked for an edge on the detector, and counted the time in the RTC registers. Now the problems with such systems are:
1) Ignoring the direct signal.
2) Accurate detection of the return - remember there will be noise, and a filter wll have a time lag, that will vary with different amplitude return signals.
Tuning the response of the filter to get the detection fast, yet reject spurious noise was the hardest thing. A lot depends on the surface you are trying to detect.
Now from your description, you will need to consider this in the gating of signal 'B'. Perhaps having a timer that ensures that the signal remains high for a few uSec after the transmission completes.
What you describe is actually easy, by using signal 'B' to gate a clock (could even be the processor clock itself).
You feed this gated clock into a CTC, reset this counter, generate your pulse, and after a period long enough that the return should have arrived, read the counter. Then repeat. If the value from the counter is zero, then no return was detected, otherwise the counter is just the measure of the length of the pulse on 'B', in terms if the clock count.
Best Wishes |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Sep 09, 2005 4:00 pm |
|
|
Ttelmah wrote: |
Now from your description, you will need to consider this in the gating of signal 'B'. Perhaps having a timer that ensures that the signal remains high for a few uSec after the transmission completes.
|
In the commercial sonar world this is called a "Range Gate." The gate is closed when the transmitter starts and doesn't open untill the time the first possible real return would be expected. The receiver is disabled or masked when the gate is closed.
If you are building the transmitter and receiver you may want to damp the transducer after the transmit burst to shorten the ringing of the transducer to better detect small close targets. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Dargar
Joined: 12 Dec 2003 Posts: 25
|
|
Posted: Sun Sep 11, 2005 12:26 pm |
|
|
sounds like it might be more challenging than I had first anticipated.
I am going to measure the burn-rate of propellant in "propellant strand" tests. The distance from the transducer to the top of the propellant will be about 2 inches. The distance from the transducer to the epoxy "interface" when all the propellant has burned away is about 1 inch.
Because sound-waves propagate differently in solids than in air (faster), I expect (based on previous tests with a similar ultrasound setup) the return to come in the interval of 20us (no propellant left) and 56us (not yet ignited).
as far as filters, I am going to use custom op-amp "schmitt triggers", so there will be a very short delay (rise-time of op-amp).
Thanks for your help and encouragements so far. For now, I will have to put the project on the shelf until I have finished some more important tasks. (This will be a hobby project). When I am ready to continue, I will have a lot of what I need to consider right here. I am fairly convinced that I can do this, but if anyone can think of any additional problems (like the damping, I did not think about that... I need to look into that..), please let me know.
As far as the damping, I know for a fact that it will be more than 19us before the return I am interested in. By masking out he Range Gate for 18-19us, I should get rid of the ringing, or at least its amplitude will be low enough not to trigger my schmitt-circuit.. I hope. (The schmitt-trigger output goes to some logic that masks out the "high" signal as long as the Range Gate envelope is high.)
Thanks _________________ Owner of PCWH v. 3.224
Consider myself beginer\intermediate as far as CCS and Microchip PIC's goes.
Bachelor in Space Engineering and Undergraduate Masters in Space Engineering
soon to be undergrad Aerospace |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|