Connect with us

Question about pic16f676

Discussion in 'Electronic Basics' started by capitano, Jul 25, 2003.

Scroll to continue with content
  1. Rich Grise

    Rich Grise Guest

    C'mon, folks! The first requirement was "No PIC's", and the first 4
    responses are "Use a PIC".

    Doing it with BCD counters (like 7490) and decoders (like 7447) is
    almost trivial. I'd be asking, what's the signal source? Pulse train?
    For that, just count pulses over some known interval. Analog voltage
    level? ADC and bin/bcd translator (unless somebody makes a 3-digit
    BCD ADC. Hmm ... "Digital voltmeter" springs to mind...)

    If you really want to get fancy-schmancy, I saw some guy design
    a circuit using just counters, latches, and some pulse trains to
    actually count pulse intervals, then digitally divide a time base
    by the result to give a readout in frequency. I still don't
    understand the circuit, but it's definitely doable.

    Good Luck!
    Rich
     
  2. ^^^^^^^^^^^^^^
    I hope you can show me how you would do this... I'm really interested. He
    has two pulses, and a fixed distance between them, and wants to determine
    the speed and put it up on some 7 segment LEDs. He wants to use big 10V Vf 7
    segment displays.

    I'm actually planning to write some PIC code for the original poster to do
    this, but if there is a simpler way, it would be great to know. The current
    plan AFAIK is to do it with a PIC, some shift registers, and some open
    collector buffers.

    Its for a slot car track. There will be 4 of them showing the speeds. Pretty
    cool, actually. I'm hoping to get some cool photos for my site out of the
    deal.

    Regards,
    Bob Monsen
     
  3. -------------
    That's because the people who tout PICs are actually digitally
    untrained and don't grasp simple digital design basics with the
    classic digital building-blocks, and they hide their ignorance
    behind "PICs", when that's actually all they know how to use.

    Why else would they ignore his first requirement!??
     
  4. Rich Grise

    Rich Grise Guest

    Ok, if you've got a pulse train to count, just cascade some BCD
    counters, and decode their outputs to 7-seg.

    However,

    the fact that there's just the two pulses means that you'll have to
    time the interval, and then it gets kinda nontrivial. I saw a guy do
    this, but he was a much better designer than I am. He started by using
    the two pulses to gat a counter of, say, X milliseconds. Then this
    number (of milliseconds per (whatever the distance is)) gets loaded
    into a preloadable, unit-cascadable, down-counter, where some
    given clock is divided by whatever number (of milliseconds) comes
    from the first bank of counters. This is long division the hard
    way, and at that point, I'd say it's time to use _some kind_ of
    micro. Either that, or feed the divided interval to yet another
    counter bank, which is just your "trivial" counter bank.

    I think.

    I did a little poking around (on the web) and found that from
    scratch, you can do a PIC for a couple hundred bucks in programmer/
    development board/software. You could build a PIC programmer from
    scratch, but it'd cost nearly a hundred bucks in parts and your time.
    You need THREE power supplies, EACH of which can be digitally set to
    one of two different voltages. IOW, it's a pain in the ass. But it would
    be a judgement call as to whether you want to tackle that particular
    pain in the ass (starting from scratch with a PIC development
    system) or the pain in the ass of designing and building a divide-by
    -N counter bank, with all its chips and soldering and stuff.

    There must be an easier way. But, it could be fun to do, and will
    definitely be an education, either way!

    Good Luck!
    Rich
     
  5. Yes, somebody over on .design mentioned you could do this. I was dubious
    until he patiently described it to me several times. Its like doing division
    by repeated subtraction. Not too hard to conceptualize, really. However,
    with the precision required (thousandths), you have to divide the mearured
    ms by a 33 bit number. It would require lots of counters. Its a fairly
    complex digital design, requiring various busses, 32 bit digital
    comparators, etc. Then, you have to worry about generating the BCD display.
    Its not a trivial thing to do. The fellow who suggested it said it would all
    be much simpler with a PIC chip, which I'll agree with.
    No, its way cheaper than this. You can get a programmer/development
    system/chip, enough to do this project, from microchip for about $40.
     
  6. Perhaps this is a good reflection of the people you've worked with, but I
    don't think its generally true. Microcontrollers are really pretty awesome
    devices, and are far cheaper than those 'classic digital building-blocks',
    at least when you consider the functions that can be performed by them.

    The PIC12F675 costs a couple of bucks, and, in less demanding applications,
    can replace discrete counters, timers, A/D chips, display driver chips,
    configuration eeproms, temperature sensors (!), X-10 controllers, PLDs, D/A
    & signal generators (with the addition of an external R-2R ladder), PWM
    controllers, etc, etc, etc. Most of this can be accomplished with NO
    external parts...

    They can be reused over and over again, making them the perfect logic for
    the hobbyist, and an easy way to prototype for the professional.

    Your statement above could also be applied to FPGA or CPLD devices, which
    are often used to replace those "classic digital building-blocks". You
    probably wouldn't accuse the folks who use these devices of simply covering
    up their ignorance...
    I think the gang gave the subject a fair going over in .design. Its such a
    natural solution for a microcontroller that people were questioning why the
    OP didn't want to use them. I don't remember anybody ignoring the
    requirement, however.

    Well, oddly enough, it turns out its now my business. When somebody asked
    (perhaps this posting by Costas,) the OP indicated he was against PICs just
    because he didn't really understand them, and also didn't really understand
    how difficult the solution would be without something like them. I offered
    to write the PIC code for him, and we've been communicating off newsgroup. I
    think it'll work out quite well.
    Regards,
    Bob Monsen
     

  7. I suggest you try to build his project using "classic digital
    building-blocks". Then you will probably understand why so many are
    suggesting a microcontroller...

    Costas
     
  8. Really? That sounds allot like the Rube Goldbergs that refuse to use
    the proper device (in this case a micro) and instead set about building
    a ridiculous contraption that costs >20 times as much as the micro
    solution. You'd think that the "digitally trained" would have the
    ability to work with a micro, after all it's mostly a collection of
    logic gates. Or are they really just hiding their own ignorance of
    complex digital logic by slamming micros every time they are mentioned?
    Why do you bother using logic chips? Wouldn't it be more craftsman-like
    to build your logic from discretes? If you don't like micros, no
    problem, but don't assume that you are correct in your opinions and
    attempt to force them upon the world.
     
  9. Lord Garth

    Lord Garth Guest

    Only rarely has any PIC fluent person supplied actual code in a posting.
    There are many schematics posted on A.B.S.E in contrast...

    Gee, I wonder why?
     
  10. Byron A Jeff

    Byron A Jeff Guest

    --> -> >
    -> > 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
    ->
    ->
    -
    -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.

    Well the initial assessment really isn't correct. The one great thing about
    PICs is that you can get them in any and every package size. For a one off
    project, a 40 pin 18F452 or 16F877 would do fine. No need to artifically
    cram into a tiny package space.

    BAJ
     
  11. Byron A Jeff

    Byron A Jeff Guest

    -C'mon, folks! The first requirement was "No PIC's", and the first 4
    -responses are "Use a PIC".

    Because given the requirement, a microcontroller of some type makes sense.
    The OP simply declared no PICs because of lack of exposure.

    But a PIC is the ultimate jellybean part. So as I posted somewhere else
    in this thread, the OP can leverage what they learn on this project into
    a bunch of future projects.

    -
    -Doing it with BCD counters (like 7490) and decoders (like 7447) is
    -almost trivial. I'd be asking, what's the signal source? Pulse train?
    -For that, just count pulses over some known interval. Analog voltage
    -level? ADC and bin/bcd translator (unless somebody makes a 3-digit
    -BCD ADC. Hmm ... "Digital voltmeter" springs to mind...)

    So you've already thrown like 10 discrete IC's (counters, decoders, ADC,
    pulse train, bin/bcd translator) at the problem. A good modern uC has all
    of that and more in a single package.

    -
    -If you really want to get fancy-schmancy, I saw some guy design
    -a circuit using just counters, latches, and some pulse trains to
    -actually count pulse intervals, then digitally divide a time base
    -by the result to give a readout in frequency. I still don't
    -understand the circuit, but it's definitely doable.

    Again the point. Especially when the OP has to build multiple units, why
    add complexity to the point of not understanding?

    Beginners need to learn that the best way to succeed is to get the hardware
    simple and stable. While I understand that folks like Ciarcia prefer solder
    as their programming language, the bottom line is that simple/compact hardware
    plus software is generally the path to success.

    BAJ
     
  12. Byron A Jeff

    Byron A Jeff Guest

    Hi Steve. How are you?

    The requirement was challenged because it didn't make sense. It's like saying
    that "I want to cut down this large oak tree, and I only want to use a nail
    file to do it." Despite the fact that the nail file can be Rube Goldberged
    into cutting down the tree, reasonable folks will ask "Have you thought about
    a chainsaw?"

    You even throw out using state machines mapped into EPROMs from time to time.
    It's just another example of encapsulating digital logic into a programmable
    medium.

    The OP made it clear that this wasn't an abstract exercise. It looked like he
    needed four sensors to measure speed for a soapbox derby type setup. It was
    a job to do. The best way to do the job was to make the hardware as simple
    a possible. Microcontrollers have all of the timing, capture/compare, decoding,
    and display power needed to get the project done.

    Whether or not you know a K-map from an xor gate, it would be foolhardy not
    to suggest simplifying the hardware to get the job done.

    BAJ
     
  13. Being one of those people that has actually posted PIC code for people
    on usenet, I take exception to your statement. At any rate, I wouldn't
    expect to find PIC source code in A.B.S.E. The www.piclist.com archives
    are chock full of free code, plus there are people that will write
    simple code for free. Not to mention the scores of PIC sites and all
    the free code and help that's available there.
    Given the attitude of some here about micros, I'm really not much
    surprised by that. Not too many people are willing to force help upon
    others that don't want it. Especially when they have to take time out
    and write the code to do so.

    I can understand that analog guys might feel a bit uncomfortable with
    micros. I cannot understand a self-professed digital logic "expert"
    belittling micros by making untruthfull and illogical statements about
    the motives of those that use them. As if this person wouldn't use a
    decade counter when a pile of flip-flops and gates combined with the
    right training and lots of time could accomplish the same thing for only
    ten times the cost. I doubt that Steve would really do that, but I'm
    just pointing out how dumb his statements sounded to me.

    michael
     


  14. To add to this, for those of us who have spent years doing logic IC designs,
    it is impossible not to appreciate the immense power, flexibility, elegance,
    and beauty of a microcontrolled-based design. Granted, there is a place for
    logic ICs (in high-speed designs, for example, although there are FPGAs for
    that too). But in the original poster's case, a micro is the natural way to
    go. I'm sure when the OP sees Bob Monsen's PIC-based design and realises how
    elegant the micro approach is, he'll change his mind in an instant.

    Costas
     
  15. ------------
    Agreed, but then why would people who know how to use them show a
    peculiar avoidance of the original digital building blocks? There
    seems to be no connect between one and the other in your justification.

    They intentionally went out of their way to avoid answering the
    question that was asked when a newbie to electronics wants to know
    the ORIGINAL way to perform a digital task! Usually people who KNOW
    these things like to show off and show them several levels of more
    and more sophisticated answers.

    But I have found that whenever I find a person who wants to use a PIC
    for ABSOLUTELY EVERYTHING that he simply is unable to tell me another
    way to do it when I conftont him. He will do such things when in high
    speed time critical static Boolean ideal situations as try to find a
    faster PIC instead of use something as simple as a latch and a gate!!

    ------------------
    I know all this, this is not what my question is about.

    --------------------
    Except they are NOT PLDs and cannot be treated as them so cavalierly,
    they have the problems of machine-level timing and limitations based
    on not being static answers to state-driven problems.

    --------------------------------
    Not at all, but they would show the newbie the original building blocks
    and THEN they'd show them how those can be implemented in PLDs in the
    same ways!

     
  16. -----------------
    I've built hundreds of things that way, AND used lots of 8051 cores,
    Z80's, as WELL as PICs. There's nothing about his needs I don't
    understand, but when you are asked a fucking question, first answer
    it, or else just keep your mouth shut.

    -Steve
     
  17. -------------------------------
    He asked how to do it, he didn't say he had to. He certainly didn't
    want to produce something for sale, so what's your beef?

    ----------------
    Do you resent his newbie status THAT BADLY?? Why? This is s.e.basics!!
    Or are you stupid enough to imagine that *I'm* some newbie, and if
    so, you REALLY don't know ME!!

    ------------------------------------
    You're a young foolish one. You have NO idea who *I* am, do you?

    I just hate to see newbies dissed for wanting to know how we got
    here, and just being handed a "cure-all" and being told to shut up.
    I've used lots of uP's and uC's, from Z80's and 8085's to 8051 cores,
    and even Z8's and 6502's once upon a time, BUT!: I've also often
    designed a permanent solution for a dedicated problem many hundreds
    of times with discrete SSI and MSI logic, and I'd hate to think that
    people will stop knowing what the perfect static/dynamic solution to
    a problem is, without just emulating a solution with a processor that
    just happens to run fast enough so you can't tell that it is fudging.
     
  18. Byron A Jeff

    Byron A Jeff Guest

    ->
    -> -> > Rich Grise wrote:
    -> > >
    -> > > C'mon, folks! The first requirement was "No PIC's", and the first 4
    -> > > responses are "Use a PIC".
    -> > -------------
    -> > That's because the people who tout PICs are actually digitally
    -> > untrained and don't grasp simple digital design basics with the
    -> > classic digital building-blocks, and they hide their ignorance
    -> > behind "PICs", when that's actually all they know how to use.
    -> >
    ->
    -> Perhaps this is a good reflection of the people you've worked with, but I
    -> don't think its generally true. Microcontrollers are really pretty awesome
    -> devices, and are far cheaper than those 'classic digital building-blocks',
    -> at least when you consider the functions that can be performed by them.
    -------------
    -Agreed, but then why would people who know how to use them show a
    -peculiar avoidance of the original digital building blocks? There
    -seems to be no connect between one and the other in your justification.

    But that justification is quite more than enough. Programmable logic of
    some sort is the solution to most every problem that involves hooking up
    multiple discrete digital components.

    -They intentionally went out of their way to avoid answering the
    -question that was asked when a newbie to electronics wants to know
    -the ORIGINAL way to perform a digital task! Usually people who KNOW
    -these things like to show off and show them several levels of more
    -and more sophisticated answers.

    No. Actually we all questioned why not use a microcontroller and the answer
    came back as lack of exposure.

    -
    -But I have found that whenever I find a person who wants to use a PIC
    -for ABSOLUTELY EVERYTHING that he simply is unable to tell me another
    -way to do it when I conftont him. He will do such things when in high
    -speed time critical static Boolean ideal situations as try to find a
    -faster PIC instead of use something as simple as a latch and a gate!!

    Interesting point! Personally I don't do that because I'll simply pull the
    appropriate gate and use it. OTOH I generally will try to stuff as much
    as possible into the programmable hardware because it let's me trade off
    physical hardware for virtual software.

    -
    -> The PIC12F675 costs a couple of bucks, and, in less demanding applications,
    -> can replace discrete counters, timers, A/D chips, display driver chips,
    -> configuration eeproms, temperature sensors (!), X-10 controllers, PLDs, D/A
    -> & signal generators (with the addition of an external R-2R ladder), PWM
    -> controllers, etc, etc, etc. Most of this can be accomplished with NO
    -> external parts...
    -------------------
    -I know all this, this is not what my question is about.

    Actually to a point it is. The question is should a beginner bother to start
    with the raw digital components when it's possible to get so much packaged
    in a single integrated unit.

    It's really the same as the programming question: should one have to learn
    machine language and assembly before programming in higher level languages.
    It's certainly not cut and dried situation.

    -
    -> They can be reused over and over again, making them the perfect logic for
    -> the hobbyist, and an easy way to prototype for the professional.
    ---------------------
    -Except they are NOT PLDs and cannot be treated as them so cavalierly,
    -they have the problems of machine-level timing and limitations based
    -on not being static answers to state-driven problems.

    All true. In short they are not the right answer for every job. But I posit
    that they are the right answer for such a significant classification of
    jobs that they should be embraced. Even when a uC isn't the complete solution
    it most often can be integrated as part of the solution.

    Steve, I agree that the saavy digital designer needs to have the whole arsenal
    of tools in the box. I even agree that in an academic environment, that the
    bottom up foundational approach is probably the correct way to approch it
    (maybe. I'm waffling.) But when it's a job, and it needs to be done now, then
    teaching time is over and you pick the fastest, most stable solution to put
    together.

    Note that in my original post, I suggested that he use the PC hardware and
    interface to the parallel port. The less hardware, the more likely that the
    task actually gets done.

    -
    -> Your statement above could also be applied to FPGA or CPLD devices, which
    -> are often used to replace those "classic digital building-blocks". You
    -> probably wouldn't accuse the folks who use these devices of simply covering
    -> up their ignorance...
    ---------------------------------
    -Not at all, but they would show the newbie the original building blocks
    -and THEN they'd show them how those can be implemented in PLDs in the
    -same ways!

    You're a teacher, n'est pas? I can hear you teaching. I get frustrated when
    my students want to know little more than what icon to click and what they
    need to do to make a good grade.

    But there is a time and place for such things. When you have to build and test
    4 of these boxes presumably in a short time frame, you pull out the simplest
    hardware to get the job done.

    BAJ
     
  19. --------
    Okay. Bad cold.

    -------------------------
    I always take such requests as being learning/teaching opportunities
    by newbies who want to learn how it was done previously so they can
    best understand modern approaches and be free of microprocessor
    "boundedness" which I see all too often.

    --------------------
    Sure, I do this to expand the newbie's vistas, because he may not
    get a course that teaches him the fundamental truth that memory IS
    Processor, and that dividing those functions is actually artificial.

    --------------------
    True. If it were simply "a job".

    ------------------
    Maybe. It depends, for instance, on what newsgroup you're speaking
    on, and in the case of s.e.basics, it is a teaching situation. This
    suggests that one answers the "child's" questions, rather than
    sidetracking them with something they may not be ready for, and
    spoiling their curiosity.

    -Steve
     
  20. Lord Garth

    Lord Garth Guest


    Personally, I would use whatever micro filled the bill. Simply realize
    that a statement like "Use a PIC" does nothing to solve a problem.
    If a PIC can do the job and you're so inclined, draw and post the schematic
    and include the necessary source code.

    BTW, does anybody have a copy of TDL BASIC which was for the Z-80
    some 20 years ago? It is ROMable and only about 12k...
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-