Maker Pro
Maker Pro

Question about pic16f676

C

Costas Vlachos

Jan 1, 1970
0
capitano said:
If I use the ADC feature, how many output ports can I have ?
http://www.microchip.com/1010/pline/picmicro/category/embctrl/8kbytes/devices/16f676/index.htm

Just to clarify, I need 11 ports - for a 3-digit seven segment led display i.e.
7 for the "sements bus" and 3 to select each digit, and one for the dot.




I had a quick look - If you use only one ADC input (1 channel) and no Vref+,
then you have exactly 11 pins available for digital i/o. With some clever
multiplexing you can get a few more pins if necessary. For example, you can
easily use the 7 segment bus pins as inputs to poll switches etc. when the
display is off.

Nice IC the F676, having 8 ADC inputs on a 14-pin package...!

Costas
_________________________________________________
Costas Vlachos Email: [email protected]
SPAM-TRAPPED: Please remove "-X-" before replying
 
T

the Wiz

Jan 1, 1970
0
capitano said:
If I use the ADC feature, how many output ports can I have ?
http://www.microchip.com/1010/pline/picmicro/category/embctrl/8kbytes/devices/16f676/index.htm

Just to clarify, I need 11 ports - for a 3-digit seven segment led display i.e.
7 for the "sements bus" and 3 to select each digit, and one for the dot.

No, you need 11 control leads to the led display. A little bit of binary logic
would let you select one of 3 digits with 2 leads, and one of 7 segments with 3
leads. This would require more sophisticated logic, but would allow you to
control the display with 5 leads.


More about me: http://thelabwiz.home.mindspring.com/
VB3 source code: http://thelabwiz.home.mindspring.com/vbsource.html
VB6 source code: http://thelabwiz.home.mindspring.com/vb6source.html
VB6 - MySQL how to: http://thelabwiz.home.mindspring.com/mysql.html
My newest language - NSBasic for the Palm PDA: http://thelabwiz.home.mindspring.com/nsbsource.html
Drivers for Pablo graphics tablet and JamCam cameras: http://home.earthlink.net/~mwbt/
johnecarter atat mindspring dotdot com. Fix the obvious to reply by email.
 
C

capitano

Jan 1, 1970
0
I had a quick look - If you use only one ADC input (1 channel) and no Vref+,
then you have exactly 11 pins available for digital i/o. With some clever
multiplexing you can get a few more pins if necessary. For example, you can
easily use the 7 segment bus pins as inputs to poll switches etc. when the
display is off.

Nice IC the F676, having 8 ADC inputs on a 14-pin package...!

Costas

Don't I need to connect am oscillator though ? If so we have at the most
9 outputs ?
 
C

capitano

Jan 1, 1970
0
No, you need 11 control leads to the led display. A little bit of binary logic
would let you select one of 3 digits with 2 leads, and one of 7 segments with 3
leads. This would require more sophisticated logic, but would allow you to
control the display with 5 leads.

Two questions come to mind,

Is there a device that take 2 inputs and will switch on one of for outputs,
i.e. a unique output or each binary value ? and

Is there a device that will drive a seven segment led display from a 4 pin
binary input ?
 
C

Costas Vlachos

Jan 1, 1970
0
capitano said:
Don't I need to connect am oscillator though ? If so we have at the most
9 outputs ?



Nope. Use the internal one. It's 4MHz and accurate to 1%. If you need more
accuracy you can either sacrifice one pin and use an external crystal osc,
or connect the crystal to the PIC in which case you sacrifice two pins. If
your application is not very time-critical, the internal 4MHz osc should do
just fine and you'll have 11 pins available.

Costas
 
C

Costas Vlachos

Jan 1, 1970
0
capitano said:
Two questions come to mind,

Is there a device that take 2 inputs and will switch on one of for outputs,
i.e. a unique output or each binary value ? and

Is there a device that will drive a seven segment led display from a 4 pin
binary input ?



There are ICs that can accomplish both of these tasks. I can't recall part
numbers, been a very long time since I last used them. Perhaps someone else
can comment on that. Do a search for "BCD to decimal" and "BCD to
7-segment". But, since you're using a PIC, I'd say think smart and try to
make as much use of it as possible. Instead of using discretes, why not use
a bigger PIC like the 16F872 or F876 instead? Everything in one IC, nice and
neat. And fully reprogrammable. Want to change the way "6" looks like on
your displays? Simple! Just reprogram the PIC with zero cost. Try to do the
same with discretes...

Costas
 
C

capitano

Jan 1, 1970
0
There are ICs that can accomplish both of these tasks. I can't recall part
numbers, been a very long time since I last used them. Perhaps someone else
can comment on that. Do a search for "BCD to decimal" and "BCD to
7-segment". But, since you're using a PIC, I'd say think smart and try to
make as much use of it as possible. Instead of using discretes, why not use
a bigger PIC like the 16F872 or F876 instead? Everything in one IC, nice and

Yes, an 18 pin pic will solve all possible problems. I am currently in the learning
phase, so all I have is pickit1, which doesn't do more than 14 pins, but I think
it will be sufficient after all (as we discussed in the other "sub-thread").
 
J

John Damm Sørensen

Jan 1, 1970
0
capitano said:
Two questions come to mind,

Is there a device that take 2 inputs and will switch on one of for outputs,
i.e. a unique output or each binary value ? and

TTL 74139 dual 2 line to 4 line decoder
Is there a device that will drive a seven segment led display from a 4 pin
binary input ?

TTL 7447 7448 7449 BCD to 7 segment decoders

Cheers
John Damm Sørensen
 
C

Costas Vlachos

Jan 1, 1970
0
capitano said:
Thanks, 4MHz will be fine, I didn't realise that there is an internal clock.
What determines if I need a Vref which you mentioned previously ?



The Vref+ is needed whenever you need accurate measurements. You normally
connect the Vref+ pin to a voltage reference source, whose only purpose is
to supply the ADC module of the PIC with an ultra-stable voltage. Any signal
in the ADC inputs will then be "referenced" to that ultra-stable voltage.
The PIC will still be powered by the usual 5V source. If you don't use
Vref+, the ADC will use the 5V as the reference, so any variation in voltage
will be reflected in the measurements as an error. If your application does
not require very good accuracy, you don't need to use Vref+. Just bypass the
PIC with a 4.7uF tantalum (or even a 0.1uF ceramic) as close as possible to
its supply pins and you'll be OK. Make sure you use a well-regulated source
(like that from a 7805 or something similar).

Good luck.

Costas
 
C

Costas Vlachos

Jan 1, 1970
0
A E said:
I'm kind of proud of my multiplexing here:

http://www.dfpresource.org/pdf/clock_sch.pdf

3 wire SPI EEPOT
2 wire I2C clock module
11 wire parallel interface for an LCD module
2 wire full duplex RS-232 port
4 button keypad
3.3V LDO's shutdown pin

23 pins multiplexed onto the 15 pins available with a 16F628 using only
resistors and a capacitor.
:)
I'm really happy about the I2C on SPI, and the RC filter trick to get a
low frequency signal from the rest state of the data bus pin.
I'm also pretty happy about the new internal RC oscillator modes Microchip
has given their new chips, the external 1/4 frequency is just what was
needed for that LCD display.



Nice tricks! The way you handle the 4 switches is exactly what I meant
above. Saves you loads of pins with only 1 extra resistor per switch. Just
make use D4-D7 are outputs only during the LCD updates, so that current
consumption is minimised (in case the user keeps holding the buttons down
for some reason).

In your circuit, doesn't the LCD support 4-bit mode? If so, you can save an
extra 4 pins at the expense of a little bit more complex code (sending two
nibbles instead of one byte at a time).

Happy PIC'ing everyone!

Costas
 
A

A E

Jan 1, 1970
0
Costas said:
Nice tricks! The way you handle the 4 switches is exactly what I meant
above. Saves you loads of pins with only 1 extra resistor per switch. Just
make use D4-D7 are outputs only during the LCD updates, so that current
consumption is minimised (in case the user keeps holding the buttons down
for some reason).

That's right. Updating the LCD happens rarely, only when a switch is pressed.
The rest of the time those bus lines are in input mode with weak pull ups. The
1K has no problems pulling that down, and the PIC has no problems driving that
when in output mode. However, I did find out that the ENB/clock signal doesn't
need to be there all the time, after sending the bytes, I can yank that wire out
of there and the display keeps working, the cursor keeps flashing... Very odd.
In your circuit, doesn't the LCD support 4-bit mode? If so, you can save an

According to the datasheet, there isn't a way to specify that AFAICT. It's a
pretty old module from the 1980's. I can't find anything else for it on the net.
I had them lying around and they were small enough to fit in the box, and
besides, surplus places in Montreal are few and far between, I couldn't find
anything else.
extra 4 pins at the expense of a little bit more complex code (sending two
nibbles instead of one byte at a time).

Adding a SWAPF and a ANDWF and a IORWF
Happy PIC'ing everyone!

Costas

And soon, AVRing too.
 
C

capitano

Jan 1, 1970
0
The Vref+ is needed whenever you need accurate measurements. You normally
connect the Vref+ pin to a voltage reference source, whose only purpose is
to supply the ADC module of the PIC with an ultra-stable voltage. Any signal
in the ADC inputs will then be "referenced" to that ultra-stable voltage.
The PIC will still be powered by the usual 5V source. If you don't use
Vref+, the ADC will use the 5V as the reference, so any variation in voltage
will be reflected in the measurements as an error. If your application does
not require very good accuracy, you don't need to use Vref+. Just bypass the
PIC with a 4.7uF tantalum (or even a 0.1uF ceramic) as close as possible to
its supply pins and you'll be OK. Make sure you use a well-regulated source
(like that from a 7805 or something similar).

Good luck.

Costas
Understood. When you say bypass (I am not very strong on jargon) you simply
mean to connect the capacitor from the plus to the minus as close to the picmicro
as possible. I'll do that. Thanks.
 
S

Steve

Jan 1, 1970
0
What I want to do is display a value (MPH) on three 7 segment numeric
displays: 000 - 999

Here are the criteria

1/ No PIC's
2/ Usual junkbox components
3/ IC's o.k. as long as their not programmed- must be readily available

Value must be derived from the following information:

Distance = 164' (or 1.98 miles - long story but both are correct)
Time = variable

Time value to be generated by photo sensor trigger.

An example of a "correct" value would be for the time value of 23.309,
the speed would be approx. 168

can anyone think of a way to do this?
Oh yeah, two other things. The photo sensor "cue" starts and end the
timing cycle, the value is generated from this duration. A new cycle is
stated from the end of the last cycle. 2- A manual reset via momentary
switch.
 
C

Costas Vlachos

Jan 1, 1970
0
Steve said:
What I want to do is display a value (MPH) on three 7 segment numeric
displays: 000 - 999

Here are the criteria

1/ No PIC's
2/ Usual junkbox components
3/ IC's o.k. as long as their not programmed- must be readily available



Why no PICs? What you ask can be done with standard ICs, but it will be
bigger in size and probably more expensive than a single-chip PIC solution.
And PICs are easy to get anyway. To do it with discretes you'll need some
sort of counter to count with a given frequency that is determined by the
time-to-speed relationship, then some 7-segment driving chips to drive the
displays and some logic gates and/or flip-flops to reset/start/stop the
counter at the trigger times, etc. With a PIC it will all be in a single
teeny-weeny little IC (including the 7-segment driving). Plus you'll be able
to update/change the design by simply reprogramming it.

I'd go for the PIC...

Costas
 
R

Robert Monsen

Jan 1, 1970
0
Jim Large said:
Looks like another homework assignment to me.

-- Jim L.

No, I think he is actually trying to build something. He wants to do a speed
measurement system. The 'No PIC' requirement was simply due to unfamiliarity
with the technology, I believe.

Doing a display using 7 segments is easy with a microcontroller such as a
PIC, using 3 wires. Its a matter of shifting the data you want into a set of
cascaded shift registers.

Without uCs, there are specialized chips such as the 74247 that can be used
to translate the output of BCD counters into the input required for 7
segment displays.

Regards,
Bob Monsen
 
C

Costas Vlachos

Jan 1, 1970
0
Robert Monsen said:
Doing a display using 7 segments is easy with a microcontroller such as a
PIC, using 3 wires. Its a matter of shifting the data you want into a set
of cascaded shift registers.



Why the need for shift registers? I think just a PIC can do everything. Just
use 10 wires (3 for the common cathodes/anodes and 7 for the segment bus).
The code to transfer the data bit-by-bit to the shift registers will
probably be more difficult for him than doing a display refresh routine
(just send the digit data to PORTB and pulse the corresponding common a/c
for some small amount of time, do the same for the other two). Plus you save
the shift register ICs (at the expense of a somewhat dimmer, but very
acceptable, display).

cheers,
Costas
 
R

Robert Monsen

Jan 1, 1970
0
Costas Vlachos said:
Why the need for shift registers? I think just a PIC can do everything. Just
use 10 wires (3 for the common cathodes/anodes and 7 for the segment bus).
The code to transfer the data bit-by-bit to the shift registers will
probably be more difficult for him than doing a display refresh routine
(just send the digit data to PORTB and pulse the corresponding common a/c
for some small amount of time, do the same for the other two). Plus you save
the shift register ICs (at the expense of a somewhat dimmer, but very
acceptable, display).

cheers,
Costas

On a uController, the pins are at a premium. I usually use a PIC12F675 which
has 8 pins, two of which are power pins... Thus, even three pins are alot.
There are schemes that use a single pin to do this, but the
software/hardware support is actually somewhat complex to do it, relying on
frequency encoding the commands.

The code for this is actually quite simple, about 10 lines of assembly code,
and a few lines in the eeprom for storing the 7 segment encodings. If you
are curious, I can post it...

Another nice thing is that you don't have to refresh the display using this
technique, which simplifies the software main loop.

Regards,
Bob Monsen
 
C

Costas Vlachos

Jan 1, 1970
0
Robert Monsen said:
On a uController, the pins are at a premium. I usually use a PIC12F675
which has 8 pins, two of which are power pins... Thus, even three pins are
alot. There are schemes that use a single pin to do this, but the
software/hardware support is actually somewhat complex to do it, relying
on frequency encoding the commands.

The code for this is actually quite simple, about 10 lines of assembly
code, and a few lines in the eeprom for storing the 7 segment encodings.
If you are curious, I can post it...

Another nice thing is that you don't have to refresh the display using
this technique, which simplifies the software main loop.



The lack of refreshing is probably the biggest benefit of the shift register
approach, as the LEDs will be at their brightest and you don't have to take
care of the timing in code. But this requires the PIC, plus the shift
register ICs. For the refresh method, a single 18-pin PIC (= 1 IC) and three
transistors are all that's needed. I prefer the 1 IC approach, but either
way is OK and definitely better than not using an MCU at all.

cheers,
Costas
 
Top