Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help with MCU Logic

Status
Not open for further replies.

shom_show

New Member
Myself Sumanta Kumar Show from IIT Kharagpur, Mining Dept. is forwarding the logic which we want to implement in the Micro-controller. Its is as follows -

Suppose I have two ports name PORT1 and PORT2. Now the ports status will change by the following way:-


PORT1 PORT2 COMMENT

5 V or Logic1 5 V or Logic1 Initial condition

0 V or Logic0 5 V or Logic1 Timer Start

0 V or Logic0 0 V or Logic0 Timer Stop


Now the time gap between timer start and timer stop will be in nano-second range. I want to display this time delay on a display device. This will be done one time.

It will not be done in a continuous manner. If need another experiment will perform manually by pressing power on/off switch or pressing reset button. Please send me

your valuable suggestion (any device that makes it easy to attain the objective), if possible through Email.

Thanks in advance.
 
Last edited by a moderator:
A micro controller running at 20mhz has an instruction clock that's 50 nanoseconds. You said your measurement range is in the nano second range but didn't state your resolution requirements. Even if you used interrupts on the timer line you'll be lucky to get 100-500 nanosecond resolution. For high resolution timing you could use an external counter run by a seperate clock. 100mhz will give you 10ns resolution 1ghz will give you 1ns resolution. The start and stop functions would have to be run by discrete logic.
 
That depends on what microcontroller you're using. You assume he's using a uC with 1 instruction per clock cycle. If this were a PIC, the instruction clock would be 5MHz, which would be 1 instruction every 200nS.

If this were an 8051, it would be 1 instruction every 600nS.

Let's try to figure out what uC the OP is even using before we start making assumptions.
 
Jon, I already provided the figuring, I assumed a best case scenario and asked what the true timing resolution requirements are, that's what we are waiting on. If the resolution required is truly in the nano-second range, meaning actual single nano seconds, the 1ghz statement stands for a clock rate to a stand-alone counter, if the resolution is as course as the 10ns range it's 100mhz. For practical timing on a chip that uses 20mhz as an instruction clock which is common, nano second accuracy is not possible, except for perhaps very course measurements such as less than or more than the 999-1ns range, meaning it could in theory under optimal conditions determine start/stop within 4-8 instruction cycles in that range, greater or less than 500ns but not more than 1usec.

It would have to be interrupt driven on an efficient chip, the interrupt/instruction delays can be accounted for.

Once again we are at a point in a thread where there is NOT enough information to proceed.
 
Last edited:
OP seems to want us to email him the answer - which is, of course, to use a low-voltage FPGA with a gated free-running 1ghz counter driven by an internal PLL using an external reference oscillator, and have the counter latch synchronous to a port or compiled CPU.
 
Depending on accuracy requirements, an analogue integrator and an ADC could be a solution.

Mike.
 
Hi to all,

Actually the resolution I required is from (1-100)ns. Currently I am using ATMEGA32 microcontroller and the Simulator is AVR STUDIO4. Can anyone please guide

how I should proceed to accomplish the task of measuring time in nanoseconds.
 
You can not measure time with that resolution using an Atmega directly. Please re-read the above thread posts which explain that in order to measure with that fine a resolution you need a timer running at a clock speed of 1GHZ.. That's well above and beyond the possibility of what can be done with a micro controller. You can buy 1ghz oscilator chips for about 35 dollars You would need to also find a counter that will run at that frequency and discrete logic to trigger the timer which you could use a micro controller to read the timer value.

Given the price of FPGA dev boards nowdays however that would be a good route as well.
 
Hi,

Can the time be measured in nanoseconds using PIC18F2455. If yes, please provide me with some documents or sample programs on measuring time through the

same device. Hoping to get your response.
 
Hi,

Can the time be measured in nanoseconds using PIC18F2455. If yes, please provide me with some documents or sample programs on measuring time through the

same device. Hoping to get your response.

To easily measure time events in nanoseconds with just the controller you need a CTMU module on a PIC18 device. I don't think there are any PIC18 chips with both USB and CTMU.
 
To easily measure time events in nanoseconds with just the controller you need a CTMU module on a PIC18 device.

No, the CTMU uses internal counters and the PIC18 doesn't go anywhere near 1ghz.
 
No, the CTMU uses internal counters and the PIC18 doesn't go anywhere near 1ghz.

The CTMU uses I/C time constants and doesn't need internal counters or the PIC clock speed to be very fast, just very fast switches and simple logic for the current source. Please take the time to understand how it works.
 
Last edited:
I'm sorry - shom_show, nsaspook has a fine suggestion. It uses an analog approach, requires some calibration, needs care with pin capacitance, but it is probably still easier to implement than anything else in this thread. Even if you have to use a second chip just for USB communication this CTMU module still looks like a winner.
 
Hi,

I have found a MCU of PIC24FJ256GB110 FAMILY which has both USB and CTMU. Can anyone please help me out how to program on this chip for measuring time in

nanoseconds. Please refer me to any links or documents if you have. Hoping to get your response.
 
**broken link removed**

This demo was in some app note but I don't know where the firmware source code is.
 
You didn't tell OP where to find the microwave components to do it.

I was thinking a high speed FET switch with a simple resistor capacitor arrangement. Not linear but that can be taken care of in software.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top