element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs even Faster A to D  :)
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: YT2095
  • Date Created: 29 Feb 2012 11:55 AM Date Created
  • Views 381 views
  • Likes 1 like
  • Comments 4 comments
Related
Recommended

even Faster A to D  :)

YT2095
YT2095
29 Feb 2012

Having spent most of the evening and a very restless night  thinking about how to optimise my A to D speed on the UNO32 board, beyond the standard 1MHz sample rate, I`v finally come up A solution.

in addition to yesterdays Blog using TRISE and PORTE to address the I/O directly, you can also use LATE instead of PORTE, and that`s also perfectly acceptable in the IDE.

I`m not sure if it makes it any faster or not, but it Does work.

 

anyway, to get real Speed from the boards A to D convertor you need to go into the Core code, my pathway is like this:

Desktop\UNO32\hardware\pic32\cores\pic32   then look for a file called: wiring_analog.C

make a Backup copy of this file and hide it somewhere, then Open the original file into Notepad.

scroll about half way down until you see a line that says:

//Delay for a bit

delayMicroseconds(2);

 

the put a `//` in front of the delay to comment it out, and put this line under it instead: asm("nop\n nop\n nop\n nop\n nop\n");

this way you`re using NOPs instead of a 2uS delay, the lowest Delay is 1uS (1MHz), but using NOP`s you actually knock out single clock cycles, and at 80MHz each NOP is worth 12nS delay (Much smaller!).

I`m using 5 of them, so that should be 60nS delay, this is the Smallest (shortest) delay you can possibly use and still have your A to D work, I added them one by one until it fired up, 5 seemed to be the magic number image

 

now Just above that original Delay line, look where it says: AD1CON3    =    0x0002;    //Tad = internal 6 Tpb

this sets the prescaller for the conversion,set  0x0002 to 0x0001 instead.

this divides the clock by 2 instead of 4.

 

save the edited Notepad file, and then upload this massive chunk of code to your UNO32:

 

void setup (void) {

TRISE =B00000000;

}

void loop() {

  LATE = (analogRead(0)>>1);

}

 

If you have a D to A built as shown a few Blogs ago, with a little audio amp, and long-wire antenna (capacitor coupled), yo might be able to pick up radio stations! I can get BBC Radio4 (198KHz) very well and can understand it word for word!

it`s not Hi-Fi quality at all, but perefctly readable, and there`s nothing really Radio-ish involved, it`s a purely Digital "radio".

I have no idea what the sample rate is at now by doing the above, but I would Guess it`s at least 4x faster, I cannot confirm this though as i`m totally out of desk space to get my Scope and Sig-gen out to try it at the moment.

I`m sure it can be optimised some more, perhaps by disabling the multiplexer for the analog pins and reading just one, using System variables like: ADC1BUF0 into LATE instead of using analogRead(0) which would probably need a lookup table, and by parsing the High and Low order data directly in the wiring library rather than using >>1; in the program.

 

I don`t know what I`m going to Do with it exactly yet, but it`s been loads of Fun exploring the code and getting down and dirty with some Metal image

if anyone Can replicate this and confirm what the Actual A to D speed is afterwards, that would be really cool! and if it doesn`t work 1`st time add another NOP to the chain, boards and conditions may differ slighly.

also, if you Break it, use your back-up again... you Did make a the back-up didn`t you?

 

have Fun!

  • Sign in to reply

Top Comments

  • YT2095
    YT2095 over 11 years ago in reply to fustini +1
    It reminds me of grabbing a screwdriver and taking the back off things to see how they work inside, similar feelings, only it`s with S/ware instead. I`m still very much a beginner with C, C++ language…
  • YT2095
    YT2095 over 11 years ago in reply to fustini

    I hope so image

    it`s still a huge learning curve, as I`m mostly Z80 based in MC, but some of it`s transportable, also I realised this morning rather naughty of me, that this project is UNO32 based, and maybe not too many people have these boards (but they should image ), so I`v done the same for the Arduino as well now, more people have these, and I know you do, so this project should be quite approachable for almost anyone that can solder and has some pocket change (or a reasonably stocked junk bin).

     

    you can Scour the internet, and get little bits and pieces of ideas, but never all in one place, and no one tells you Exactly HOW to do this, what is in effect a very simple thing.

    I find it annoying, so i`m hoping that putting simple step-by-step instructions together here, someone will benefit and save themselves a lot of frustration and leg-work, and get on with doing something creative.

    to basicly present the sort of material that I would have liked to have come across but never did, having said that of course, John Boxall (I think he`s also a member here) has some great tutorials also, and some of his work has helped me in the past when I was starting out.

     

    so yeah, check out my todays blog, and DO let me know if it needs expanding on or more detail.

     

    All the best!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 11 years ago in reply to YT2095

    I think you'll benefit from your solid understanding of the registier and assembly.  The higher level libraries are a great help but every now and then there will be a leaky abstraction which requires pouring through the data sheets and handling registers yourself.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • YT2095
    YT2095 over 11 years ago in reply to fustini

    It reminds me of grabbing a screwdriver and taking the back off things to see how they work inside, similar feelings, only it`s with S/ware instead.

    I`m still very much a beginner with C, C++ language, but the hardware registers and ASM / machine code is where I`m most comfortable, so much of my stuff is a Hybrid at the moment, but I`ll get there eventually.

    I have to, this is the current state of electronics nowadays, and I feel I need to know both rather than just how to handle a soldering iron image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 11 years ago

    Looks like you are having fun diving through the Arduino layer of abstraction image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube