counter and 7-segment decoder problem

Thread Starter

muttu.sarve

Joined Aug 5, 2011
4
HI every one,
I'm new to pic programming and i'm working on a project. i'm planning to use pic16f877.and please suggest me which oscillator i can use in this project.
the project is go like this...the project consist of 4*4 keyboard, 5 output LEDS, 8 digital outputs to drive another circuit, seven (7) digit 7-segment
display, 1 sesor input which will get a signal from sensor. which is used to find out motor rotation. the sensor is connected to 24v ac motor(1400rpm).
As the shaft of the motor rotate once then the sensor work once. the sesor input is taken as counter and which will be dispay in the 4 digit 7-segment.
as pic16f877 has 32 I/O pins so i need to use 7-segment decoder in this project. the problem is..
1. i want to know the circuit diagram for 7-segment decoder with sample code for this project.
2. when the motor rotates with full speed then within 4second shaft will rotate 100 times so i'm dont know how to program for this. mean while my sensor is working as
counter and i need to display the same count in 7 segment display. so please help me.. its urgent.
thanking you..
 

Thread Starter

muttu.sarve

Joined Aug 5, 2011
4
thanks for replying.. i got enough time now to work on this project.. as i'm working on it so please help me to solve this issue.. there is a lot more other things to do in this project. i just post the part of my project which is i'm not getting how to solve..
 

WBahn

Joined Mar 31, 2012
29,979
Given that a straight-up 7-digit 7-segment display has more pins that the number of I/O pins you have, there must be something you haven't told us (or taken into account). Is this a display module with an I/O interface?

You also need to consider how much resolution you need and how much latency you can tolerate. For instance, if it is important to display the difference between 1000rpm and 1001rpm and you only get one count per revolution, then you have to count at least 1000 revolutions, which would take most of a minute to do. On the other hand, if you have to have a display that is responsive to changed on the order of ten seconds, then you won't be able to do this and will have to settle for less resolution (if tolerable). So first figure out what your requirements are and whether or not your existing hardware is capable of meeting them at all.

Next, consider the different basic approaches you could take. You could count for a specified number of seconds and then do some math and display the result, or you could time how long it takes to reach a specified count and then do some math and display the result. Each has advantages and disadvantages.

What you want to try to do is design a method that keeps the math simple for your system. Consider what happens if you count the number of revolutions in 1/10 of a minute (i.e., 6 seconds). Then the count is equal to the number you want to display divided by ten. But what happens if you take a number and display it such that it appears shifted to the left by one digit and the right-most digit is forced to be zero?
 

Thread Starter

muttu.sarve

Joined Aug 5, 2011
4
i have attached block diagram with this and please go through it and do help me to solve this issue.. and also let me know the algorithm for code to achieve this display problem..


thank you :)
 

Attachments

RiJoRI

Joined Aug 15, 2007
536
I seem to remember having some 7-segment LEDs with a built-in decoder. This would take a 4-bit digital input and display it properly. I don't know if they are made any more, but it's worth a search. Another way would be to program a PAL for a decoder, or to use a smaller PIC to do the work. You could probably simplify the display code in the '877 to an LED#+DIGIT and send it serially to the LED controller PIC.

Finally, how about a serial-in, parallel-out shift register?

--Rich
 

WBahn

Joined Mar 31, 2012
29,979
From your diagram, the main objective appears to be a desire to reduce pin count for the display portion from 14 pins down to something smaller. How much smaller is needed? You have already seen how to use a 3-to-8 decoder to drive the cathode lines. I would recommend having code 000 be unused so that if your segment selection pins are all set to zero that no segment lights up. As it is, you would have to set them all HI, which isn't bad since they are all the same, but it might be a bit confusing. On the other hand, you can number your digits to make either choice appear logical.

Getting back to pin-reduction goal, you have 7 pins for the segment anodes, but how many bits are needed to represent the set of states that are required? Assuming you have no decimal point or other special segments, you only have ten states and that, in turn, requires 4 bits of information, namly the binary values from 0000 to 1001. This would seem like a problem that lots of people would have faced for a very long time and my guess is that someone has long since figured out how to convert a four bit binary value into the pattern of drive signals for a 7-segment display. You might try doing a Google search for binary to seven segment decoders (and keep in mind that, in this context, BCD and binary are the same thing since you shouldn't be sending anything other than the ten codes they have in common).

A good exercide for you would be to design the logic that is needed for such a device yourself, even if you buy a commercial chip to implement it. You have seven outputs and each is a function of four inputs with six "don't care" states out of the sixteen total. That makes the logic for each output pretty tractable.

Oh, and make sure the polarity of the driver chip you get is correct. Some of them have a pin that you can use to select the polarity while others are specifically intended for either a common-anode or common-cathode display.
 
Top