+ Reply to Thread
Results 1 to 40 of 40

Thread: All Digital

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default All Digital

    ALLDIGITAL.pbp

    If you want to use all the pins on your PIC as general Input/Output, you must first enable the DIGITAL inputs that are multiplexed with the ADC and Comparator pins.

    MICROCHIP in their infinite(simal) wisdom has DISABLED the DIGITAL inputs on Power-Up. Leaving everyone to figure out which of the 10 different ways they need to use to turn them on for the chip they're programming at any given time.
    Sometimes it's ADCON1 and CMCON, other times it's ANSEL and CMCON0, and still others it might take ANSELA ANSELB ANSELC and ANSELD.

    This file is an attempt to rectify that situation.
    I've tested it on all the common chips we use with PBP, and it workes extremely well.
    <hr>

    Simply INCLUDE the file, and all PINs will have any DIGITAL inputs enabled. Whether it's from the A/D converter or the Comparator(s).
    A single line will remove that big thorn from your ...

    Code:
    INCLUDE "ALLDIGITAL.pbp"
    If you are using MPASM for the assembler, add the following line to your program and the registers that need to be set for the CPU you are compiling for will be shown in the "Results" window of MCS.
    Code:
    DEFINE  SHOWDIGITAL 1
    For example, with a 16F877A it would show ...
    Code:
     ... MESSAGE:(ADCON1 = 7)
     ... MESSAGE:(CMCON = 7)
    At that point, you can just add those lines to your program and delete the INCLUDE line.
    If it shows a 0x7F type number, change it to $7F.

    Or for better compatibility, you can leave the INCLUDE in your program, and it will work with whatever chip you are compiling for.

    Here's a simple example for blinking an LED on PORTA.0, without worrying about the analog registers.
    Code:
    INCLUDE "ALLDIGITAL.pbp"
    
    Main:
        TOGGLE PORTA.0
        PAUSE 500
    GOTO Main
    <hr>
    Current Version = 1.4 (7/19/2010)
    Version History:<table border=1 cellspacing=1 cellpadding=3><tr><td>Version</td><td>Reason</td><td align=center>Credit</td></tr><tr><td align=center>1.0</td><td>Initial release</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.1</td><td>Added Shared address SFR support for 18F87J50 family</td><td align=center>mister_e/scalerobotics</td></tr><tr><td align=center>1.2</td><td>Removed MPASM specific opcode (variable), for PM.exe</td><td align=center>Tobias</td></tr><tr><td align=center>1.3</td><td>Added ANSELA,B,D and E for the 16F72x series</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.4</td><td align=center>Added ANSEL0 and ANSEL1 for the 18F4431 series</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.5</td><td align=center>unknown</td><td align=center>This could be you!</td></tr></table>
    The attached .zip has only one file, ALLDIGITAL.pbp extract it to your PBP folder (the one with PBPW.exe).
    <br>
    Attached Files Attached Files
    Last edited by Darrel Taylor; - 20th July 2010 at 20:26. Reason: version update 1.4
    DT

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,819

    Default

    Beau Geste ! Creative people + Frustration = Interesting solution. You keep throwing these out there, my six year old grandson is going to be writing usable code. In fact this might be the one.
    Last edited by Archangel; - 2nd May 2009 at 08:16.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    Tyranny is defined when law enforcement is allowed to make the law.
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,235

    Default

    Helpful indeed.

    May be, with the next version, we can select which CH(s) we want as analog. With some limitations of course.

    @SELECT_CH CH0=1 'Select CH0 as analog.


    Thanks a lot DT.


    _____________________________
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Quote Originally Posted by sayzer View Post
    May be, with the next version, we can select which CH(s) we want as analog.
    But then it wouldn't be ALL DIGITAL.

    That's a little more datasheet searching than I'm up for.
    Would be nice though.
    <br>
    DT

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,541

    Wink

    Hi, Darrel

    Play it Grand size !!! ...

    Why not raise us a full PBP Wizard like some "C" IDEs or the MPLAB VDI are Showing ??? Sure it would bring some $$$++ home ...

    Ah, human lazyness ... how much will it cost us ???

    Regards

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Nice one Darrel.
    Last edited by mister_e; - 3rd May 2009 at 22:07.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Quote Originally Posted by Joe S. View Post
    Creative people + Frustration = Interesting solution.
    Creative people + Frustration<sup>3</sup> = Interesting solution.

    There must be an end to the "I can't blink an LED" threads.

    Code:
    INCLUDE "ALLDIGITAL.pbp"
    
    Main:
        TOGGLE PORTA.0
        PAUSE 500
    GOTO Main
    Ohhhhh, but then there's the CONFIG's.
    Arrrrghhh!

    Thanks Joe!
    And Steve.
    <br>
    DT

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default

    This an all the others (DT-Instant Interrupts, PWM, Bar Graph, etc) exceptional pieces of code, I think should be included in the next PBP release.

    Have you thought of talking to Melabs? It would make their product classes higher.

    Ioannis

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    No way, they can't have them.

    If they just add all my stuff to PBP, it would invalidate the programs I've spent 1000's of hours developing and supporting over the years.
    They'd have everything, and I'd have nothing but a bunch of useless old threads.

    Of course, if there were Large sums of money involved, I might be persuaded.
    <br>
    DT

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Of course, if there were Large sums of money involved, I might be persuaded.
    <br>
    I never meant for free of course! And I am sure all here may be willing to pay a little extra for better product.

    None of the competitive products do not have the Interrupts or Bar Graph quality you did. You gave us a really special present and is really appreciated :-)

    Anyway...

    Ioannis

  11. #11
    Balachandar's Avatar
    Balachandar Guest

    Default All Digital

    Thanks a lot, Darrel.

    This is another great contribution from your side that increases the value of PBP and also reduces the possibility of the code not working as expected.

    Bala

  12. #12
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    While attempting to use my first 16F723, I found that they have ANSELA and ANSELB instead of ANSEL and ANSELH.
    Only the 16F72x series has them.

    ALLDIGITAL.pbp has been updated to version 1.3
    http://www.picbasic.co.uk/forum/atta...achmentid=3380
    See post#1 for instructions and version history.
    DT

  13. #13
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Question Should ALLDIGITAL.PBP work for 18F4550??

    Quote Originally Posted by Darrel Taylor View Post
    .

    ALLDIGITAL.pbp has been updated to version 1.3
    http://www.picbasic.co.uk/forum/atta...achmentid=3380
    See post#1 for instructions and version history.
    Darrell,
    I have been having some problems in my coding of an application for the 18F4550 and suspected I was missing something in setting the ops to pure digital. Attempted to use your ALLDIGITAL.pbp as an INCLUDE and it appeared normal, but at time of compile/assembly I did NOT see any listing in the Assembly window when I decommented the DEFINE statement. That made me wonder if ALLDIGITAL.pbp was even compatible with the 18F4550. Is it, or if not can you advise me how to modify it to include??

  14. #14
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default

    ADCON1 = 15
    Sets all to digital.
    Dave
    Always wear safety glasses while programming.

  15. #15
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Thanks!

    Quote Originally Posted by mackrackit View Post
    ADCON1 = 15
    Sets all to digital.
    Thanks, Dave. Would like to know how to make this modification in DT's ALLDIGITAL.pbp for use as an INCLUDE, but at least your info got me going with using the ADCON1 statement in the code. Appreciate your input.

  16. #16
    Join Date
    Jun 2011
    Posts
    37

    Default Re: All Digital

    David, I just wanted to say "Thanks!"
    This file has fixed a problem that I have been struggling with for 3 days.
    RL

  17. #17
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,254

    Default Re: All Digital

    Quote Originally Posted by RayL113 View Post
    David, I just wanted to say "Thanks!"
    This file has fixed a problem that I have been struggling with for 3 days.
    RL
    You mean Darrel.

  18. #18
    Join Date
    Jun 2011
    Posts
    37

    Default Re: All Digital

    "Darrel, I just wanted to say "Thanks!".
    Sorry for the mistake.
    (Thanks Demon)
    RL

  19. #19
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,254

    Default Re: All Digital

    Darrel,

    1. 18F44K22 - You're missing PortC.

    I displayed on a working program and noticed a difference. This is what I have.

    ANSELA = %00000000 ' Set ports to digital
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000000
    ANSELE = %00000000
    2. I have a suggestion, maybe rename to DT_AllDigital.PBP, that way they all line up together when browsing PBP folder.


    Thanks for awesome utility.

    Robert


    EDIT: Forgot to say I'm still on PBP 2.60c, if it matters.
    Last edited by Demon; - 4th January 2014 at 02:10.

  20. #20
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: All Digital

    DT

Similar Threads

  1. Replies: 5
    Last Post: - 16th October 2009, 18:29
  2. Digital Out on an A/D pin safe ?
    By mr.sneezy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st January 2009, 22:48
  3. Replies: 4
    Last Post: - 24th January 2007, 22:20
  4. A/D versus Digital I/O
    By dallennn in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th November 2006, 04:31
  5. Digital IC Tester
    By precision in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th September 2006, 03:38

Members who have read this thread : 6

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