[SOLVED] counters for PIC uC.

Status
Not open for further replies.

Raady Here

Full Member level 5
Joined
Jun 8, 2013
Messages
242
Helped
26
Reputation
52
Reaction score
26
Trophy points
28
Location
India
Visit site
Activity points
1,571
PIC30F5011/ MPLAB 8.8

Hi,
Motor gives analog signal to my uC- I have to measure it voltage and frequency of signal, voltage is measured now by configuring ADC pins and reading through ADCBUF values.
how to measure frequency.

For measuring its frequency, I searched through some links where those say it can be done by frequency counter with configured timer0 as a counter, but none of them had any clear understanding.
if any body worked on frequency counter send me a link or sample where I can understand concept better about configuring timer as counter.

Regards,
Raady
 

There is already a .asm program:


Frequency measurement in assember (ASM) for PIC
 


should i use the same adc pin for measurement of frequency?

It's not quite clear what you mean by (to paraphrase) "..frequency of motor signal..".
Are you talking about the rpm ? Is this a DC motor/ AC motor/ BLDC motor ???

Once you clarify this it will be easier to give helpful suggestions
 

Motor gives pulse output for frequency measurement ? If yes, in PIC16F and PIC18F it is interfaced to T0CKI or T1CKI pin and respective timer is configured as counter. I have never worked with dsPIC. Maybe dsPIC has same pins or similar input pins.
 
Last edited:

if the signal is pulses no need to use an FFT (required for complex analogue signals)
you can connect the pulse data to a dsPIC "interrupt on change" input to count pulses
use a timer to count the pulses over known time period and hence calculate frequency
 

It's not quite clear what you mean by (to paraphrase) "..frequency of motor signal..".
Are you talking about the rpm ? Is this a DC motor/ AC motor/ BLDC motor ???

Once you clarify this it will be easier to give helpful suggestions

my client hadn't mentioned any hardware details of their hardware kit as how they are taking the measurement , they just gave me a output pin where I get an analog signal which i connect the same to my adc pin (on my board).
I am attaching a pdf ,

based on the 'voltage' and 'parameter' i want to check, i will automate the switches, if the measuring parameter falls in the correct range the voltage levels will be in the 'range values' else it will show 4.9v which means incorrect range. once i detect the exact range i make calculations to detect the actual value of the parameter based on the voltage level detected.

for parameters - 'IR', resistance, inductance, rotor resistance, i have made calculations and its is detecting correctly as i wanted.
but for parameters - Vibration, temperature, sound, current, i need to check frequency along with voltages if it falls in the range.

as i have only one pin where i can make measurement, with the same can i measure voltage and frequency.

in the links i have read, to measure frequency, from my understanding, they are configuring an interrupt pin and timer for counter and based on that they are measuring frequency, but in those cases the signal is digital.
but in my case i have only one pin which gives me a analog signal.
what can i do ?

- - - Updated - - -


but horace1 ,
i am not getting any digital signal.
FFT is quiet tricky for to understand
http://www.microchip.com/CodeExamplesByFunc.aspx

are there any simpler way to understand ??
 

Attachments

  • Motor tool analyzer.pdf
    109.9 KB · Views: 57
Last edited:

if the pin is an ADC input you can use the same pin for voltage and frequency (clearly you cannot use the same pin as an ADC input and "interupt on change")
you can read ADC sample into a buffer and calculate the voltage (average, RMS, ?) and frequency
if the signal is fairly clean and you don't want harmonics you can look for crossing a set voltage (looking for rising and falling edges with Hysteresis in case of noise) and using a timer determine the period of the signal and hence its frequency
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…