All Digital


+ Reply to Thread
Results 1 to 40 of 40

Thread: All Digital

  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 21:26. Reason: version update 1.4
    DT

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


    Did you find this post helpful? Yes | No

    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 09: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
    .
    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,185


    Did you find this post helpful? Yes | No

    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


    Did you find this post helpful? Yes | No

    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,619


    Did you find this post helpful? Yes | No

    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


    Did you find this post helpful? Yes | No

    Default

    Nice one Darrel.
    Last edited by mister_e; - 3rd May 2009 at 23: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


    Did you find this post helpful? Yes | No

    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
    3,980


    Did you find this post helpful? Yes | No

    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


    Did you find this post helpful? Yes | No

    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
    3,980


    Did you find this post helpful? Yes | No

    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
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Now what would you DO with all that dirty filthy money?
    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
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Now what would you DO with all that dirty filthy money?
    I would use it to pay the bills,
    so I had nothing else to worry about besides creating the next FREE include file.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    How about a Paypal donation button on your website?
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    From
    http://www.picbasic.co.uk/forum/showthread.php?t=11128

    ALLDIGITAL will need some adjustments for 18F87J50 family and probably some others.

    On this family, ANCON1, ANCON0 are alternate SFR to ADCON0, ADCON1. They share the same address, so you need to set/clear WDTCON.ADSHR to switch between SFRs before writing on... dear Microchip

    http://ww1.microchip.com/downloads/e...Doc/39775b.pdf
    Section 5.3.5.1, pdf page 82, Shared SFRs & WDTCON
    Last edited by mister_e; - 7th May 2009 at 05:46.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    I just knew there would be some Oddball chips somewhere.
    And shared SFR addresses, with the select bit in the Watchdog Timer control, definitely qualifies as Oddball.

    I've updated the program, and replaced the original .zip in post#1.
    http://www.picbasic.co.uk/forum/atta...achmentid=3380

    Thanks mister_e.
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Well... thanks to scalerobotics for having bring that PIC in here

    Definitely, i'll never understand Microchip... that's a real oddball indeed.

    Can't really understand the reason why they used that sharing address method... and with WatchDog register... well... yes and no... but certainely not 100%.

    Question is... do they have an answer for that themself?

    Universal answer??? Because!
    Last edited by mister_e; - 8th May 2009 at 02:59.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Thanks to Tobias, another error has been found, and repaired.
    http://www.picbasic.co.uk/forum/show...3978#post73978

    The file has been updated to version 1.2
    http://www.picbasic.co.uk/forum/atta...achmentid=3380

    I appreciate the efforts of everyone helping to make this the answer to the Analog problem.

    Thank you,
    DT

  18. #18
    Balachandar's Avatar
    Balachandar Guest


    Did you find this post helpful? Yes | No

    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

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


    Did you find this post helpful? Yes | No

    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

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


    Did you find this post helpful? Yes | No

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

  21. #21
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

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

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


    Did you find this post helpful? Yes | No

    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.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    ... Would like to know how to make this modification in DT's ALLDIGITAL.pbp for use as an INCLUDE
    ??????

    It is an Include, and no modifications are required.
    Or maybe there's more to the question.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default ALLDIGITAL.pbp works OK with 18F4550

    Quote Originally Posted by Darrel Taylor View Post
    ??????

    It is an Include, and no modifications are required.
    Or maybe there's more to the question.
    <br>
    Ignore my previous, Darrell. What I was saying is I wanted to modify the code in ALLDIGITAL.pbp so it would work with the 18F4550. I didn't think it was working because I wasn't getting any messages in the Assembly window when I uncommented the DEFINE statement that lists the configs made by ALLDIGITAL.pbp. Turns out I had mispelled DIGITAL in the statement as the reason it wasn't listing the messages. Once I fixed that I discovered that ALLDIGITAL.pbp version 1.3 does already work with the 18F4550. Sorry for the confusion.

  25. #25
    Join Date
    Apr 2011
    Location
    León
    Posts
    5


    Did you find this post helpful? Yes | No

    Question Re: ALLDIGITAL.pbp works OK with 18F4550

    Sorry but how can you do ALL_DIGITAL = TRUE on PicBasic PRO?

    CMCON=7? is it correct?

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


    Did you find this post helpful? Yes | No

    Default Re: ALLDIGITAL.pbp works OK with 18F4550

    Quote Originally Posted by ietcyberwolf View Post
    Sorry but how can you do ALL_DIGITAL = TRUE on PicBasic PRO?

    CMCON=7? is it correct?
    CMCON = 7 is comparators off for many of the pics, not for all, each pic family (read that family members all share a common data sheet) may have very different settings in order to enable digital ports. For you, For Now, go back to the very first post in this thread and get the all digital zip file, unzip it into your pbp directory and include it as Darrel instructed you to do. In his file he has taken the time to read and understand a variety of PIC families and built in enough code to select the appropriate settings. My recommendation to everyone is read those data sheets and struggle with them and ask questions until they begin to make sense. They will begin to make sense. You can find all registers your chip uses in the mpasm suite directory in files with the suffix .inc this chip will be P16F4550.inc . To set ports digital often requires setting several registers like ANSEL, ADCON, CM0CON . . . the data sheet explains what each register does and what each bit controls.
    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
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default Re: ALLDIGITAL.pbp works OK with 18F4550

    Quote Originally Posted by ietcyberwolf View Post
    Sorry but how can you do ALL_DIGITAL = TRUE on PicBasic PRO?

    CMCON=7? is it correct?
    Read carefully POST #1.
    Steve

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

  28. #28
    Join Date
    Jun 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    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

  29. #29
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,960


    Did you find this post helpful? Yes | No

    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.

  30. #30
    Join Date
    Jun 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: All Digital

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

  31. #31
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,960


    Did you find this post helpful? Yes | No

    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 03:10.

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


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    DT

  33. #33
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,960


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    Thanks! Updated to v1.5 from that link you provided.

  34. #34
    Join Date
    Dec 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    Does All Digital work in PBP3? I have installed ALLDIGITAL.pbp in the main directory of PBP3, but Micro Code Studio gives me a warning of unable to open INCLUDE file ALL DIGITAL.pbp. I don't know what I'm doing wrong.
    Thank you.

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


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    Yes, it works with PBP3.

    Post the actual line of code and errors you are receiving.
    Paraphrasing errors doesn't give the information needed to diagnose your problem.
    DT

  36. #36
    Join Date
    Dec 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    This is the code, using PBP3, Micro Code Studio Plus, and a 16F648A PIC selected:

    INCLUDE "ALL DIGITAL.pbp"
    LED var PORTA.0

    mainloop:
    HIGH LED
    PAUSE 500
    LOW LED
    PAUSE 500
    GOTO MAINLOOP
    END

    I get this message at the bottom:

    WARNING: Unable to open INCLUDE file ALL DIGITAL.pbp

    I have been unable to determine the reason I am getting this message.
    Thank you very much for your help.

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


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    Remove the space between ALL and DIGITAL.
    DT

  38. #38
    Join Date
    Dec 2013
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    Thank you so much! This works perfectly. Last week I had tried to run a Timer 1 program on a 16F886 that had been running perfectly on a 16F876A. The program would not run on the 16F886 until I added:

    ANSEL = %00000000
    ANSELH = %00000000
    ADCON0 = %00000000
    ADCON1 = %00000000

    which took me FOREVER to find because I am just starting out learning this. ALLDIGITAL.pbp will save me a lot of time.
    Thank you again for helping.

  39. #39
    Join Date
    Jan 2018
    Location
    Azores Islands
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    As a relative noob, exactly what I was looking for.
    Except...:
    I added it to the folder containing pbpx.exe as instructed but on compile Microcode Studio comes back with:
    WARNING: unable to open INCLUDE file ALLDIGITAL PBP.
    I use PBP3.1

  40. #40
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: All Digital

    You have to include the full path to the file.

    Include "C:\BPP31\...."

    Ioannis

Similar Threads

  1. Replies: 5
    Last Post: - 16th October 2009, 19: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, 23:48
  3. Replies: 4
    Last Post: - 24th January 2007, 23:20
  4. A/D versus Digital I/O
    By dallennn in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th November 2006, 05:31
  5. Digital IC Tester
    By precision in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th September 2006, 04:38

Members who have read this thread : 1

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