PIC's ports individual bits manipulation - how to?


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by SteveB View Post
    Are you saying that even these bitwise commands, when actually implemented by the PIC, will write to the whole port?
    Yes - the entire port is updated via port R-M-W when using bcf or bsf.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by flotulopex View Post
    First, the "need for speed" is due to the display refresh rate. The higher the speed is, the less time each digit is going to be light on and so, it will dimm naturally.
    Have you demonstrated this? Your loop has each digit on for about ¼ the time. Frequency should be irrelevant because with higher frequceny, it will be lit less but will be lit more often. Would not you need to turn the digit off before the pause (or between pauses) to affect the dimness? I will have to think about it more.

    PORTA = ~DCD Digit will set 1 bit to a state and all others to the other state; this is an unwanted effect in my case.
    I thought you wanted
    MAIN:
    PORTA = XXXX1110
    PORTA = XXXX1101
    PORTA = XXXX1011
    PORTA = XXXX0111
    GOTO MAIN

    where the upper nibble were inputs? If they are inputs, they will not be affected by your PORTA=~DCD command because, well, they are inputs.

    I didn't think about your solution; it's always amazing to see how many different ways there are to solve a problem. I will try it anyway since I want to know witch is more memory space effective.
    Earlier you mentioned speed is an issue, now you mention code space – the unrolled version will not be very code efficient but it should by slightly faster than the looped depending on How PBP converts them to ASM. If one were to write it in ASM, I know the unrolled method would be faster (at least I know I could write an ASM version faster than a looped. Also the PORTA add commands could be done in two instructions versus more as with the >>, & and | approach). However, I still do not know if your upper nibble of PORTA will always be inputs?
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    flotulopex,The statement: "If I want to make the display brighter, I slow down the loop with the "Scan" pause making the digit to be powered longer." makes no sense if the drive circuitry is designed correctly and the software is truly multiplexing the digit drivers at 100%/number of displays. The only thing that lowering the display frequency will do is at the lower end of about 50 to 40 hz the viewer will start to see the telltale multiplexing action. If at 60 hz. or more the display brightness should not change as far as your eye is concerned. If your display gets brighter as you increase the frequency then your circuitry is not shutting off the digits fast enough. If it gets dimmer as you increase the frequency then your circuitry is not turning on fast enough. This is assuming you have the dutycycle set at 100%/number of displays with no delays. I have designed an automotive gage set using a 16f88 that runs a 4 digit + decimal point multiplexed display that has a 16 step dimming function thru an A/D channel tied to the dashboard dimmer. I chose 63 hz as the lowest frequency to eliminate the STROBING effect during driving.

    Dave Purola,
    N8NTA

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default answers...

    Paul,

    The four higher bits of PORTA are Inputs and when I checked out the levels on my PIC with my logic probe (set to TTL), using ~DCD would make the ports change status. BUT I have to try with another my PIC since one of my digits doesn't light-up normally making me think about a "little" problem... Should get a new one tomorrow.

    About dimming, modifying the scan (refresh) rate of the digits is effectively not a good solution. It's working but, as said in another post, the strobe effect is also accentuated. I have modified my circuit and added transistors in each Common Anode connection. Those four transistors are then levelled by one additional transistor witch is LDR driven. At least, it works fine.

    Dave,

    My approach is maybe not a good one and any example/critic/suggestion is welcome. It's my first project involving a LED display, I didn't even know what multiplexing was before, so got still to learn more... My english is poor, what is a "gage set"?
    Roger

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    flotulopex, It is a set of digital gages used for automobiles. About 3 years ago I gutted a trio of small SUN aftermarket gages in chrome cans and built digital inerds for each. 1 displays water temperature, 1 oil pressure, and 1 battery voltage/current. I beleive the MELABS web site has an intorduction to display multiplexing that you should see and i beleive also some code that you can use as a basis for your program if this helps.

    Dave Purola,
    N8NTA

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by flotulopex View Post
    The four higher bits of PORTA are Inputs and when I checked out the levels on my PIC with my logic probe (set to TTL), using ~DCD would make the ports change status.
    When using digital inputs, you need to make sure the external connection are either high or low. It sounds like what you are testing are floating (unconnected) inputs, which is a big no-no (not the testing of, but leaving inputs unconnected). Tie your inputs either high or low and repeat - you will see that they are not affected by your DCD command.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  7. #7
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default pull-ups, pull-ups....

    This could be the trick.

    Let me check over and I'll come back.
    Roger

  8. #8
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default DCD works fine... and faster

    Yes Paul, you're absolutely right.

    The DCD command doesn't affect the input ports. Personally, I would appreciate to see this kind of information in the PBP manual. Maybe it will be there in the next edition?

    As you mentionned, it is not a good idea to measure ports whithout pull-ups or pull-downs; what I did now.

    So, DCD works fine and faster than indexing the ports.

    Thank you very much.
    Roger

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Individual Variable bits
    By tazntex in forum General
    Replies: 4
    Last Post: - 31st January 2008, 18:27
  3. Equating Ports to Data Bits
    By Osiris in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd March 2006, 15:00
  4. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31
  5. pics with 3 hardware PWM ports
    By CBUK in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th August 2004, 00:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts