View previous topic :: View next topic |
Author |
Message |
bal_square
Joined: 05 Dec 2018 Posts: 11
|
PIC12F675 timer |
Posted: Mon Jan 14, 2019 6:49 am |
|
|
I'm a newbie with PIC. I need to simulate simple speedometer using PIC12F675. I have frequency generator, I know that I should use timer and interrupts, but can't understand how to make it work. (I use the standard 6000 impulses/km ). Can someone help me with code? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9232 Location: Greensville,Ontario
|
|
Posted: Mon Jan 14, 2019 7:18 am |
|
|
You can use the 'search' button, light blue above ... and use 'speedometer' and you'll get several 'hits'.
You can also use Google to search for 'speedomter' or 'tachometer' code for CCS C PIC.
You'll probably have to 'do the math' to get the maximum count (highest speed) for the PIC's clock and timer. At 6,000 /km a 16bit timer could only count 6 km.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Mon Jan 14, 2019 7:27 am |
|
|
Seriously I also have to ask what you actually want to 'do' with the value
obtained. The 675, is only an 8pin chip. With the supply pins, and a pulse
input to detect speed, you don't have many pins left to output a result.... |
|
|
bal_square
Joined: 05 Dec 2018 Posts: 11
|
|
Posted: Mon Jan 14, 2019 7:30 am |
|
|
Ttelmah wrote: | Seriously I also have to ask what you actually want to 'do' with the value
obtained. The 675, is only an 8pin chip. With the supply pins, and a pulse
input to detect speed, you don't have many pins left to output a result.... |
I can use serial register for outputing result. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Mon Jan 14, 2019 8:51 am |
|
|
No.
The 675, does not have a UART. So only software serial. Doing this while
trying at the same time to do 'timing' based code, will be very hard.
If you want to do this get a PIC with a UART like the 12F1822 or 1840.
You are making things hard for yourself, trying to do this in a 12F675....
If you look at most of the speed examples, they will use the CCP to make the
measurement much easier. Again the 675 does not have a CCP.
The simplest way of generating speed with the least latency, is to measure
the time between two edges on the incoming signal. Speed is the
reciprocal of time, so can be updated with every incoming edge. |
|
|
|