Shop OBEX P1 Docs P2 Docs Learn Events
new MCP3XXX ADC driver — Parallax Forums

new MCP3XXX ADC driver

Bobb FwedBobb Fwed Posts: 1,119
edited 2009-09-01 21:01 in Propeller 1
I'm just looking for some people who would test my new ADC object. It is a [noparse][[/noparse]robust] driver for the MCP3208 (12-bit) and MCP3008 (10-bit).
It can do the obvious (get current values of channels) but also can be customized as a Schmitt input, max/min values over time, value averaging, and input frequency are all available.

I am hoping some people can download it here: obex.parallax.com/objects/488/
Let me know if everything works as expected, what features should be added.
Any suggestions on how to make the coding faster is always helpful.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!

Post Edited (Bobb Fwed) : 7/24/2009 6:35:54 PM GMT

Comments

  • parts-man73parts-man73 Posts: 830
    edited 2009-07-23 00:37
    Bobb,

    This is great, I have a SpinStudio module based on the MCP3208, I'm currently writing the documentation for now. The upcoming IODreamKit also has a MCP3208 onboard. I was pointing to Chip Gracey's object in the OBEX for customers to use as an example, mind if I point to your object from the documentation as well?

    ADC was one area of my product offerings that was lacking. The MCP3208 module and IODreamKit should fill that hole.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio - the modular Development system for the Propeller

    PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!

    SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-23 00:53
    Ya, no problem. Its all legally freeware now :-P. I would like to get more testing and some of those additional features added. And some optimization would be nice...but it will probably always be a work in progress.
    So, link to it, it still does more than the other and in the future it will be more complete...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • TrapperBobTrapperBob Posts: 142
    edited 2009-07-23 11:36
    Hi Brian,

    When do you expect to start selling the MCP3208 module and the IODreamKit?

    TrapperBob
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-23 21:59
    A new version has been posted to the Obex obex.parallax.com/objects/488/

    Added the ability to limit the number of channels scanned. Make make the driver compatible with 1, 2, 4, and 8 channel ADCs.
    Added method to get an average of a channel over a specified amount of time. This is in addition to the method that allows for an average over a specified number of samples.
    Max/min values are now stored for active channels while in a single-channel-exclusive actions (waits/freq/average). But they are not stored to cog memory until the following time the channel is active (up to 4800 cycles later).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • parts-man73parts-man73 Posts: 830
    edited 2009-07-23 22:45
    TrapperBob said...
    When do you expect to start selling the MCP3208 module and the IODreamKit?

    I hope to have the MCP3208 module ready by this weekend, I have the kits all made up and ready to ship, it's just a matter of documenting the kit.

    The IODreamKit will be another month or 2. The design needs some minor tweaking and I need to work on methods of producing them en masse. The prototypes took about 45 minutes to an hour each to assemble. Since the IODreamKit is mostly SMT parts, I will assemble and test each one before shipping. Coming up with a suitable assembly process to get these reliably assembled, while keeping the cost for the product reasonable is a challenge. I hope to make some real progress over the next month.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio - the modular Development system for the Propeller

    PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!

    SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
  • HannoHanno Posts: 1,130
    edited 2009-07-23 23:04
    Thanks Bobb for this great object- keep up the good work!

    Brian sent me one of the first IODreamkits and it's an absolute beauty! Brian has a gift for making pcb's look and work great.
    Hanno

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Download a free trial of ViewPort- the premier visual debugger for the Propeller
    Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-24 21:59
    Version 1.0 is now available on the Obex: obex.parallax.com/objects/488/

    Changes:
    Some optimization: Replaced the MUX shift out with a CTR NCO shift out. Rearranged end of loop code to evenly space WRLONGs. This increased the sample frequency from 119ksps to 127ksps.
    Fixed a problem introduced in v0.7 with the minimum value output.
    Reduced the number of instructions executed during resetmax and resetmin.
    Differential and single-ended mode can be enabled during start up with mode setting. Both the mode and active channels values are part of the start method parameters.
    The ADC and it's driver cog can be put into standby mode to save power. All values are ignored in this mode. Standby exiting check time is a customizable value.

    this will be my last update on the forum for this object (unless continued interest is shown)
    I am still hoping for some feedback on functionality of the driver...I hope some people are using it, and no news is good news.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-07-24 23:00
    Bobb Fwed,

    Man, I wish I knew that you were working on code for the MCP3202,04, and 08. We could have collaborated our efforts! - Good Job!


    I like your idea on setting the behavior of the input threshold and making it act like a programmable I/O.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-24 23:09
    Beau Schwabe (Parallax) said...
    Bobb Fwed,

    Man, I wish I knew that you were working on code for the MCP3202,04, and 08. We could have collaborated our efforts! - Good Job!


    I like your idea on setting the behavior of the input threshold and making it act like a programmable I/O.
    Well, it is always a work in progress. I'd love to contribute/receive contributions. Right now I am looking at ways to make it faster, and I still have a short list of features (in the documentation) I intend to add over time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-25 00:05
    I just got some help to bump the sample rate up from 127ksps to 144ksps. That's faster than the MCP3008 spec at 5V...but it is working great for me at 3.3V. But I am right at the limit. I had one more thing to speed it up, and then it started to give back bunk information. But maybe the two different speeds can be used for users with the ADC at 5V or if you are running slower than 80MHz.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • TreeLabTreeLab Posts: 138
    edited 2009-07-25 01:29
    Bobb: Can you estimate how many stable bits of resolution you have at these high sample frequencies?
    Cheers!
    Paul Rowntree
  • mynet43mynet43 Posts: 644
    edited 2009-07-25 01:34
    Hi Bobb,

    I also wrote a driver for the MCP3208. I had it running much faster than the spec, so I talked to the manufacturer. They said it can vary some from chip-to-chip or batch-to-batch. So I ended up slowing it down to match the spec, just to be sure other people wouldn't have problems.

    Keep at it, looking good!

    Jim
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-25 01:57
    TreeLab said...
    Bobb: Can you estimate how many stable bits of resolution you have at these high sample frequencies?
    Cheers!
    Paul Rowntree
    It seems the values are very consistent. The higher the sample rate, the lower the return value, but it appears very predictable. As long as you are using the same method to read the values each time it is fairly stable.
    The big difference comes when you switch between normal operational values and a single-channel command (like average or frequency) but the difference (in testing) is less than 1%.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • Jim FouchJim Fouch Posts: 395
    edited 2009-07-25 02:45
    One of the things I found lacking in the MCP320x driver was the ability to have the readings used by more than one parent object. I rewrote an area of the stock driver a few years ago to allow one instance of the driver to feed a common area of memory with all channels being read. This allowed different cogs to share the various channels.

    I can post some of that code if others think it would be useful.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jim Fouch

    FOUCH SOFTWARE
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-25 02:59
    I was already thinking about that. I would have the controlling program feed the object the address of 8 longs...
    Then the PASM would populate it. I think it would be a sub version of the program because it would be more difficult to integrate the object, but more flexible.
    It would also make the channel values accessible with less cycles. It would also make it look more like the standard IN[noparse]/noparse

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-07-28 19:05
    Jim Fouch said...
    One of the things I found lacking in the MCP320x driver was the ability to have the readings used by more than one parent object. I rewrote an area of the stock driver a few years ago to allow one instance of the driver to feed a common area of memory with all channels being read. This allowed different cogs to share the various channels.

    I can post some of that code if others think it would be useful.
    Try version 1.1 (obex.parallax.com/objects/488/). Let me know if that does what you want it to.


    Additions in 1.1:
    Added alternate start method: start_pointed. This allows for multiple objects to access current channel value, state, and max/min. The parent object supplies 4 8-long blocks which are used instead of the object's blocks.
    Shifting in and out has been sped up. While fewer instructions are used per bit, it creates a problem. This object should be run at operating clock frequencies of less than 80MHz. At 80MHz, the driver runs at almost 50% faster than the MCP3XXX ADCs are designed to operate. This could produce invalid, or unexpected outputs. 64MHz or less is recommended (though still 25% over spec). At 40MHz, all MCP3XXX ADC should operate fine.


    In the future I will add a subversion into the object. When the operating clock frequency is detected to be above 64MHz, it will launch a slower version of the driver (customizably slow though). In all other cases, it will run the [noparse][[/noparse]current] fast version to get as many samples as possible at the slower clock speeds.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-08-29 18:31
    @Bobb Fwed

    Excelling job on the driver. I like the way you comment the code.


    Re:but also can be customized as a Schmitt input,

    Do you have a reference to this in the driver. I read through most everything (at least twice) and the Microchip Spec PDF but somehow I missed it. Maybe I just need glasses lol.gif
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-08-29 21:00
    Well I think I mentioned it in the documentation at the top of the driver. But you won't find it in the datasheet. It is purely a product of the driver.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-08-29 21:52
    @ Bobb Fwed : Thanks!! for the feedback and all the work you've done on the drivers and examples. They are really great objects. yeah.gif

    What I did wrong:

    I think I figured it out. I only seen a reference to the Schmitt trigger in your post and not in the driver object. The driver version I have printed is 1.1.

    Solution:

    I just downloaded a new version of the driver and it's now up to 1.31 jumpin.gif I see that it has lots of additional info.

    Also, there is a Schmitt trigger reference is in another object" ADC Frequency Reader v1.1 " (first time I saw this object)

    "****************************************
    ''* ADC Frequency Reader v1.1 *
    ''* Author: Brandon Nimon *
    ''* Created: 6 July, 2009 *
    ''* Copyright (c) 2009 Parallax, Inc. *
    ''* See end of file for terms of use. *
    ''***********************************************************************************
    ''* This PASM-driven object reads the values off of an MCP3008/3208 analog-to- *
    ''* digital converter (ADC). It can mimic a Schmitt trigger, only clocking cycles *
    ''* after the channel's value has gone from a low threshold to a high threshold. *
    ''* Jitter can be easily reduced by requiring the "high" input to last for a *
    ''* certain number of ADC read cycles ("samples"). The "high" value can also be *
    ''* easily changed to fit the needs of the input and to widen the "Schmitt gap".


    Ok great. I may not need glasses after all. turn.gif I'll just print a fresh copy of everything and start from the beginning.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-09-01 21:01
    Bob Lawrence (VE1RLL) said...
    Also, there is a Schmitt trigger reference is in another object "ADC Frequency Reader v1.1".
    Ah, right. I will add some info on the Schmitt trigger in the next release of the ADC Driver.

    Any requests as to additions in the next version?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
Sign In or Register to comment.