| View previous topic :: View next topic |
| Author |
Message |
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sat Jan 31, 2015 1:29 pm |
|
|
Please help me with the 4 X 7 segments!
Thanks, |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9634 Location: Greensville,Ontario
|
|
Posted: Sat Jan 31, 2015 2:49 pm |
|
|
There are quite a few posts about this....
here's one... http://www.ccsinfo.com/forum/viewtopic.php?t=33495
found by using the 'search' feature keywords 'multiplex 7 segment display' ,selecting ALL words.
I'm not saying it works, is 100% correct BUT it might be a good starting point.
You could also 'google' , '4 digit , 7 segment ,multiplexing' as you're NOT the first and won't be the last doing it!!
When you get it running right, post your code in the 'library' here so others can use it.
Jay |
|
 |
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sat Jan 31, 2015 3:40 pm |
|
|
Jay,
Thanks for your reply, I searched before even posted on this forum (google, this forum, ....etc)!
All I could find was the following:
1- Posts that not been answered yet.
2- Why do not you use LCD.
3- Flow chart of the theory.
.
.
.
That was why I posted here. I need help with a simple to follow code that I can understand and I can adapt it to my project.
Thanks, |
|
 |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat Jan 31, 2015 4:48 pm |
|
|
| Sam_40 wrote: | Please help me with the 4 X 7 segments!
Thanks, | Do a search here on:-
1) Key words "7" "segment".
2) Author "mike walne".
with the "Search for all terms" button clicked
You will get several responses, even some with code examples.
Mike
NB You will definitely need a higher frequency crystal than the one shown in your schematic. |
|
 |
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sat Jan 31, 2015 5:09 pm |
|
|
Mike,
Thank you for your reply,
to quote something you once said
"This is rather like pulling teeth."
For some reason I can not find something that is useful to me :(
Thanks anyway,
Sam |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9634 Location: Greensville,Ontario
|
|
Posted: Sat Jan 31, 2015 6:53 pm |
|
|
gee Sam , Mike tells you how to search for just SOME of the code and using his instructions I got 18 'hits' with a LOT of reasonably good WORKING code.
The 'sahu' thread is good, course you'll need to re-assign the pinouts and use a real xtal( 4MHz, maybe 20 megs) to get it to run right......
There is no way running at 32KHz will work though.
Jay |
|
 |
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sat Jan 31, 2015 8:13 pm |
|
|
Jay,
Believe me; I searched, read and tried till my head start to hurt
I am taking my baby step at programming and I made that clear in my first post.
Little display flicker from the 32768 is OK.
I appreciate all inputs. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20062
|
|
Posted: Sun Feb 01, 2015 2:08 am |
|
|
Clock faster.
There is no point at all in you clocking at 32768. The only reason to use this rate, is to save power on a chip that is running in a micro-power environment, which has to stay awake. Since your display will use 1000* the power that the PIC will use, clocking this slow is pointless.
Now a reasonable display update rate is something like 100Hz. Anything below this will display significant flicker, and too far below, it'll not just be flickering, but flashing. At 32768Hz, the processor executes just 8192 instructions per second. You talk about wanting to drive 4*7 segments, which to even give 25Hz overall display, means each digit must change 100* per second. Just the digit lookup from the data table, takes a dozen plus instructions. I'd say that the slowest processor clock to have even a remote 'hope' of getting a multiplexed display to be close to useable, is probably at least 10* your current clock rate. Multiplexing _needs_ speed.....
You won't get 'little display flicker'. You'll get separate digits displaying one after the other. The eye only gives the persistence of vision needed to make a multiplexed display work, at a reasonable display rate. |
|
 |
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sun Feb 01, 2015 7:46 am |
|
|
Hello,
You are right, the reason I want to use the 32768Hz crystal is to save power as described by the datasheet. The displays will only run during setup and test as described by me on my first post to save power.
FYI; I found a very old post online for a digital clock that uses the PIC16C58 with one 8 bit timer on the chip and the 32768Hz crystal and 4 X 7 segments and 3 switches. The old post has the schematic and the HEX file only. I build it and programmed the PIC16C58A (18 pins) using MPLAP IDE and the PICStart plus Programmer. It been running for about 9 weeks and it is actually very accurate little digital clock. Pressing one switch and it shows the seconds as well. The 4-digit 7-segment display is flickering bad, however I can tell what time it is and I am OK with their operation! I tried to contact the author of that old post without luck; I thought he may be able to help me.
This is my thought regarding my project and please answers these questions:
1- If one timer is used for my project, which one would you suggest using (1X8bit and 2X16bit)? I know if I use the 32768 with 16 bit timer, then I have to overflow the timer to get 1Hz! I do have a few PIC18F chips, The 18Fs datasheets show to use timer1 in 16 bit mode and overflow the counter to get the 1 second counter!
2- Someone suggested using the 32768Hz for the time keeping and higher internal clock for the multiplexing? How to do that?
3- If question 2 is possible, can the internal higher clock and the timer to be used for multiplexing turn on during setup and testing and turn off during operation to save power?
4- Please provide code example with comment so I can understand the code.
I know in theory how it should work, so far I failed in to making my theory into a working code for my project. Like I said I did a lot of reading and research about this matter.
Thanks, |
|
 |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sun Feb 01, 2015 9:16 am |
|
|
| Quote: | This is my thought regarding my project and please answers these questions:
1- If one timer is used for my project, which one would you suggest using (1X8bit and 2X16bit)? I know if I use the 32768 with 16 bit timer, then I have to overflow the timer to get 1Hz!
2- Someone suggested using the 32768Hz for the time keeping and higher internal clock for the multiplexing? How to do that?
3- If question 2 is possible, can the internal higher clock and the timer to be used for multiplexing turn on during setup and testing and turn off during operation to save power?
4- Please provide code example with comment so I can understand the code. |
1) For me you can use either, others may have a preference, I'm not going to argue about it.
2) Connect crystal to oscillator pins. Set up the HF oscillator via fuses. Connect 32K crystal to timer1 oscillator pins (See data sheet). Set up 32k oscillator with SETUP_TIMER1.
3) Yes. See data sheet again. Explains timer1 oscillator is intended to run in sleep mode.
4) This is a help you forum, not a do it for you one. Put in the effort, read the forum guidelines, show us the code you've got, someone here will likely step in to help.
Mike |
|
 |
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Sun Feb 01, 2015 9:17 am |
|
|
| Thanks, |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20062
|
|
Posted: Sun Feb 01, 2015 1:49 pm |
|
|
As a comment, do you have to use the 16F73?.
This is quite an old chip.
Many more modern equivalents exist, that have the same or more features.
Several of these offer the ability to switch between oscillators. You could (for instance) have a 32KHz crystal on the timer, and switch between this and an internal RC oscillator running at a much faster speed.
Most of these later chips also draw less power. |
|
 |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Feb 02, 2015 5:16 pm |
|
|
For giving the best suggestions it helps if you provide us with as much info as possible. Also non-technical info will help, like:
- Is it a commercial project, hobby or for school?
- Are you building one unit or do you intend to build more, then how many?
- Why the 16F73? This is an older chip and relative expensive at about $3.50. Newer chips with more features, less power and cheaper do exist for about $1.50
You are right that a low clock frequency will save you power. Instead of multiplexing the LED display at a high frequency you could consider to drive the display in a static way. Just add 4x 74HC595 chips or similar to drive all LEDs from 3 PIC pins and you can keep the PIC at a stable 32kHz. Will cost a little bit more more in hardware but save a lot in software design time.
Later on you can save more power by having the PIC go into sleep mode and only wake up once every second when the 32kHz timer overflows.
You didn't mention your PIC power supply, but often this is where most power is lost. A simple 7805 will easily consume 100 times the PIC power at 32kHz.
Make sure you don't have unconnected input pins on the PIC. An open input pin will start to oscillate and consume multiple mA. By default many pins are inputs for safety reasons. Make them outputs or connect a resistor to Vcc or Vdd. |
|
 |
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Mon Feb 02, 2015 7:10 pm |
|
|
Ttlmah,
I do not have to use the 16F73! However I do have a few of them that left from other project.
I may use one of the 18F that I have!
Ckielstra,
Please read my first detail post for all the information about my project.
- Hobby.
- Once I get it to work, I may build 30+.
- I do have a few of them that left from other project.
In my first post, I thought to use LM2672 Power Converter High Efficiency 1A Step-Down Voltage Regulator to drop the 12V battery to 5V for the PIC and the display. Now I have a better idea
I am thinking instead of one 12 volt battery. I am going to use 2 X 6V battery. I am going to connect them in way to use 12V for the motor and 6V for the circuit. I will drop the 6V to a safe voltage for the PIC.
| Quote: | | “Make sure you don't have unconnected input pins on the PIC. An open input pin will start to oscillate and consume multiple mA. By default many pins are inputs for safety reasons. Make them outputs or connect a resistor to Vcc or Vdd.” |
Thanks for the hint, What do you think a 10K would do?
Regards, |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9634 Location: Greensville,Ontario
|
|
Posted: Mon Feb 02, 2015 7:47 pm |
|
|
quickly...
The 10K is used as a 'pullup' or 'pulldown' load to force the pin to a known logic level. If left 'floating', every transition up, down, up, down... will consume a LOT of power.CMOS devices do NOT consume power when either high ot lo, it's the 'transitions' that require power. |
|
 |
|