Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Multiplexing 7 segment display

Status
Not open for further replies.

crash@home

New Member
I am trying to multiplex a 3 digit 7 segment display, because my processor is to be performing additional tasks while multiplexing a delay between switching is undesirable. i have found an article about how to combat this problem from "gooligum.com" but i am still a little hazy, could somebody please indicate how changing of bit 2 indicates a time of 2μs. What i struggle to understand is that with a counter or in this case timer 0 bit 2 will not change its state on every instruction cycle so this logic to me is flawed because the switching wouldn't be at regular intervals.

below is the extract:

But a timer can still be used to good advantage when implementing multiplexing on a baseline PIC. It would be impractical to try to use programmed delays while multiplexing; there’s too much going on. But Timer0 can provide a steady tick that we can base our timing on – displaying each digit for a single tick, and then counting ticks to decide when a certain time (e.g. 1 sec) has elapsed and we need to perform an action (such as incrementing counters).
If the tick period is too short, there may not be enough time to complete all the program logic needed between ticks, but if it’s too long, the display will flicker.

Many PIC developers use a standard 1 ms tick, but to simplify the task of counting in seconds, an (approximately) 2 ms tick is used in this example. If each of three digits is updated at a rate of 2 ms per digit, the whole 3-digit display is updated every 6 ms, so the display rate is 1 ÷ 6 ms = 167 Hz – fast enough to avoid perceptible flicker.

To generate an approximately 2 ms tick, we can use Timer0 in timer mode (based on the 1 MHz instruction clock), with a prescale ratio of 1:256. Bit 2 of Timer0 will then be changing with a period of 2048 μs.

and the example code segment:

Code:
To display a single digit, such as minutes, the code becomes:
        ; display minutes for 2.048 ms
w60_hi  btfss   TMR0,2
        goto    w60_hi
        movf    mins,w
        pagesel set7seg
        call    set7seg
        pagesel $
        bsf     MINUTES
w60_lo  btfsc   TMR0,2
        goto    w60_lo
; wait for TMR0<2> to go high
; output minutes digit
; enable minutes display
; wait for TMR<2> to go low

please help me to understand or point me in the right direction

Thanks
 
Last edited:
I find the quoted text (the extract) confusing. 1ms tick is a nice number, but there is no "standard". And I can't understand how "too long tick period" makes a (7-segment) display flicker. But, if there is a 1 Mhz clock to a counter, then bit 1 will change state at 500kHz (2us period). Bit 2 would be twise that.. 4 us.

EDIT: actually the quoted text says that the period of bit 2 is 2048 us.. not 2us. What was the original question again? I'm confused. If the prescale is 256, then the clock to the counter is 1/256 Mhz.. and the bit 2 will change state at the rate (1/256)/4 Mhz. That makes the rate of change 1024us. The period between same states is then 2048us.
 
Last edited:
my mistake.. my question is, if i am trying to multiplex display digits of a 7 segment display (common cathode) and i want to switch between them at a rate sufficiently fast so as not to be perceived by the viewer but to execute this change without the use of interrupts. so for instance using the timer module and switching on increment of a particular bit, how does that work.

I understand how the display interfaces with the pic, the wiring and the theoretical principles behind multiplexing.

But in practice, without an interrupt, i don't understand how i would be able to achieve this.

Also i understood what you were saying until:

The period between same states is then 2048us.

please clarify. Thanks
 
please clarify. Thanks

If the bit changes from 0 to 1 etc. every 1024us, then the period of repeat is 2048us. Sorry, english is a second language to me. I'm trying to explain the difference between "bit change" and "bit pattern repeat".
 
Its not your english, its just me trying to understanding.

How can monitoring that particular bit change in a counter, be sufficient to multiplexing

in a counter:

1= 00000001
2=00000010
3=00000011


so even in the first three digits you we see that the value of bit 2 has not changed yet, and even after that it is a 1 for the next four cycles

4=00000100
5=00000101
6=00000110
7=00000111

so wouldn't we need the multiplexer to change on every clock cycle, not just by monitoring one bit
 
i think i see the pattern now... i continued the number sequence, its just like a 8 bit truth table, the number 4 (bit 2) will change output every 4 instruction cycles :)
 
i am trying to set the oscillator value of my PIC18f26j11, but am running into much difficulty.
Trying to set an 8MHz value is problematic, i have:

chosen the oscillator to be INTOSC
set the literal '01111100' to osccon

as instructed in the data sheet but any delay sequence i implement, even those created using online delay generators last for less than a second. is there something im missing
Screen Shot 2013-03-12 at 07.48.22.pngScreen Shot 2013-03-12 at 07.48.51.png
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top