View previous topic :: View next topic |
Author |
Message |
patrick001p
Joined: 31 Dec 2019 Posts: 1
|
How can I use the CCS to see the speed of a wheel |
Posted: Sun Feb 16, 2020 9:06 am |
|
|
Hi guys, I'm working on a project, and I'm currently having some doubts.
I wanted a quick code of how can I use my hall effect speed sensor to show the RPM on my interface that I'm working on (It will send by rs232).
But I can't find any program that uses a hall effect speed sensor with a PIC, using the CCS.
I'm using a pic18f46k80 with a 64MHz internal crystal. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sun Feb 16, 2020 9:40 am |
|
|
You are being too specific in your search. Look at ex_capture.c
This shows how to capture the period of a signal using the CCP.
Now 'think about it'. Period = 1/frequency.
Speed is frequency*wheel circumference.
So measure the period between pulses, and after just one rotation of the
wheel, you can calculate 'speed'. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Sun Feb 16, 2020 2:24 pm |
|
|
Search keyword could be 'tachometer'. The actual 'speed sensor' can be ANY device that produces zero to 5 volt transitions for 'there, not there'. Hall effect implies a rotating magnet but code for a reed switch would work. Even the PIC code, tweaked', for the original PC mouse might work.
You'll have to 'tweak' any program though, based upon what you expect the RPM to be and desired resolution. 10.0025 RPM and 134,000.1 RPM are obviously quite different but both are valid speeds.
There are 98 matches to 'tachometer' in the search of this forum.... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Mon Feb 17, 2020 12:27 am |
|
|
The only issue is that a wheel gives a very low frequency, so he
needs to work by using 'period', rather than just counting pulses.
If counting pulses the resolution will be awful, and response very
slow. A lot of the tacho examples use pulses rather than period,
since they are using much faster signals. |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Wed Feb 19, 2020 11:34 pm |
|
|
Hi Ttelmah
I didn't find the ex_capture.c in PICC Examples.
How I can get it?
Best wishes
Joe |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Feb 20, 2020 12:19 am |
|
|
Apologies. I think ex_capture is only for the DsPIC's.
Look at this thread:
<http://www.ccsinfo.com/forum/viewtopic.php?p=78590>
PCM_programmer posts an example measuring period, and then
displaying this as frequency. Then simply multiply this by wheel
circumference to get speed.
You'll have to adjust the factor used in the frequency calculation
for your clock rate. |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Thu Feb 20, 2020 4:22 pm |
|
|
Thank you for the link Ttelmah.
Best wishes
Joe |
|
|
|