Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Frequency Measurement Post ReplyPost New Topic
<< Prev Page of 2
Author
Message << Prev Topic | Next Topic >>
chronic
Guru
Guru


Joined: 21 January 2012
Location: Australia
Online Status: Offline
Posts: 595
Posted: 23 June 2018 at 11:11pm | IP Logged Quote chronic

Just an idea -
Use the signal frequency to drive the pic32mx itself. Run a simple incrementing counter, and gate it using the 1 pps from a gps. At the end of the gate, print the counter and reset it, and wait for the next gate start.


Back to Top View chronic's Profile Search for other posts by chronic
 
Volhout
Newbie
Newbie


Joined: 05 March 2018
Location: Netherlands
Online Status: Offline
Posts: 36
Posted: 25 June 2018 at 9:45pm | IP Logged Quote Volhout

IF the MX has a counter input, it should be possible to simply let it increment on every edge, and frequently read out the counter.
With a 16 bit counter you could do this in 1msec period, and count up to 60MHz.
There are HW limitations to the frequency you can input to the counter, but this can hardly be an issue with a 50MHz+ chip like the PIC32 series.

I build a 50MHz frequency counter this way in a 4MHz PIC16F84 20 years ago.
For frequencies above 40-50MHz, you would need a prescaler (not a 74LS90....your MX is far faster than the separate TTL chips).

You probably could have use of a Cfunction, but I bet you can do it in MMbasic also.
The 1msec reading of the counter register does not need to be accurate, as long as you have an accurate time as a reference.
The 1msec loop is only needed if you have a 16 bit counter. If your HW has a 32 bit counter, you simple read it every second, and divide by the reference time.

something like

main loop
get reference time
clear work register (32 bit)
1msec loop (i.e. 1000 times)
read counter
add to work register
end loop
get current time
subtract reference time = delta time
divide work register by delta time = accurate frequency
end main loop

This you can do in MMbasic, I am sure...


Edited by Volhout on 25 June 2018 at 9:48pm


__________________
If nothing goes right ... turn left
Back to Top View Volhout's Profile Search for other posts by Volhout
 
Warpspeed
Guru
Guru


Joined: 09 August 2007
Location: Australia
Online Status: Offline
Posts: 1795
Posted: 26 June 2018 at 12:32pm | IP Logged Quote Warpspeed

You can also use the 1mS counter overflow to trigger an interrupt, and count up the interrupts over whatever time period you need to get the required final resolution.

__________________
Cheers, Tony.
Back to Top View Warpspeed's Profile Search for other posts by Warpspeed
 
Emady
Newbie
Newbie


Joined: 02 February 2016
Location: United Kingdom
Online Status: Offline
Posts: 16
Posted: 28 June 2018 at 1:46am | IP Logged Quote Emady

Thank you everyone for the many responses and suggestions, there is a lot there to think about. I will try using a divide by 10 or 100 prescaler first and see how that goes. This is within my programming capabilities, just....

I also want to try Scott Harden's counter that he did with a Raspberry Pi, not sure if I have the skills to port his software but will try.

Will post about my experiments when I get to them, work is getting in the way 🙁

Kind Regards,
Elia
Back to Top View Emady's Profile Search for other posts by Emady
 
Volhout
Newbie
Newbie


Joined: 05 March 2018
Location: Netherlands
Online Status: Offline
Posts: 36
Posted: 29 June 2018 at 9:25pm | IP Logged Quote Volhout

In my previous post I suggested to use an internal timer clocked by the 27MHz frequency. That suggestion was premature, and incorrect (the architecture of MMbasic on the PIC does not allow that, thanks Geoff for reminding).

I have to agree with others that na external divider is the solution.
A simple solution is to use the SN74LV8154-EP
It has 2 internal 16 bit counters that can be chained to a 32 bit counter.
The output is 8 bit parallel with 4 select inputs. So you can read out all 32 bits in 4 bytes.

You only need to provide an accurate count gate (i.e. a 1msec pulse) and clear the counter before opening the count gate.

The frequency guaranteed over the wide temp range (-55...+125C) is 25Mhz, so I expect if you keep it at room temperature, it will work fine for 27MHz. It is 3.3V in so you may want to add a small amplifier before it to easily tap into oscillator circuits.

Good luck building....

Volhout





Edited by Volhout on 29 June 2018 at 9:41pm


__________________
If nothing goes right ... turn left
Back to Top View Volhout's Profile Search for other posts by Volhout
 
matherp
Guru
Guru


Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2164
Posted: 11 July 2018 at 12:15am | IP Logged Quote matherp

The latest version of the Armmite code includes support for a high speed frequency counter.

Using SETPIN 93,FIN or SETPIN 93,CIN, pin 93 (PG8) is configured to clock a timer as suggested in the posts above. The timer then generates an interrupt on timer-overflow (16-bits) allowing total counts up to 2^63 before counter overflow (normal Micromite integer).

I've tested the functionality up to 20MHz which is the fastest the PWM on the Armmite will run and it seems to work perfectly.





The concept could be engineered into the firmware of the MM+ and/or MMX but the PIC has far fewer timers than the STM32 so it may compromise other functionality. There is no chance of doing it on the MM2

Edited by matherp on 11 July 2018 at 12:16am
Back to Top View matherp's Profile Search for other posts by matherp
 
PicFan
Regular Member
Regular Member


Joined: 18 March 2014
Location: Austria
Online Status: Offline
Posts: 93
Posted: 11 July 2018 at 6:37pm | IP Logged Quote PicFan

@matherp

SUPER, i have a Board, but no time for tests !


Wolfgang
Back to Top View PicFan's Profile Search for other posts by PicFan
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
<< Prev Page of 2
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.0938 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.09