Hello!
1. The circuit for wiring a 7-seg display and a micro controller must exist in thousands of versions on the net.
Now how many digits do you have to manage?
As for the source code, you don't need any. The best for you would be to understand what you are doing
and why you are doing it.
- Learn what a port is
- Learn what a LED is, how it works, etc
- Wire a single LED to your PIC, try to write a tiny program to blink it.
- Write another program to blink 2 leds independently to make sure you got it.
- Wire your 7-seg display (1 digit first). Try to blink all the segments independently.
- For any number, make a summary of the segments you have to blink (i.e. for 0,
you'll have to blink abcdef, for 1 bc, for 2 abdeg, etc...
-> At that point you know how to display one number.
- Now try to display 2 numbers with 2 7-seg displays.
-> You may use 1 port per segment if you have enough pins (with 32 IO, it should just fit if you have nothing else)
-> you may use 1 common port for data for all the displays and multiplex their common pins...
In this case, you need 7 I/O pins for the sets and 4 I/O for the enable signals.
- Upgrade for the number of 7-seg units you want to use
2. For your motor, since the rotation is very slow compared to the processor clock, you should
use a timer. The time between 2 pulses of your sensor (1 per rotation) will be 4/100 or 1/25,
which means 40 ms. If the timer runs at, say, 20 MHz, then you will get 20 000 000 / 25
clocks, therefore 800 000 clocks. This gives you a quite good accuracy. After that, you know that
800 000 clocks corresponds to 1500 rpm, and therefore it's easy to calculate speed from
the timer value.
Dora.