element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • 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 Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products and Partners
    Products and Partners
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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
  • Settings
Community Hub
Community Hub
Member's Forum Help, Pi2 and MCP3008
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Community Hub to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 14 replies
  • Answers 2 answers
  • Subscribers 631 subscribers
  • Views 1879 views
  • Users 0 members are here
  • mcp3008
  • spi
  • analog
  • pi2
Related

Help, Pi2 and MCP3008

e14 Contributor
e14 Contributor over 10 years ago

My analog board and Pi2 are inside a well ventilated metal enclosure. The MCP3008 is not getting warm to the touch. There is a fan pushing air though the enclosure.

 

All signals look clean on the scope.

 

Vcc, and Vref are 3.3v.  All samples are within 0-3.3v.

 

I have tried all different SPI clocks form 500Khz to 3Mhz.

 

An identical board sitting on my desk has been working fine for 45 min.  Three different PI and MCP3008 inside the metal enclosure will work for about 5 min after a power cycle then the readings go nuts, before all eight channels revert to zero.

 

I will leave the working board running all night.  The AC cuts off here at about now.  So the temp in this office will go up over night to about 30c (Singapore) so I guess I will know if the temperature affects it.

 

Here is my "transfer" code:

 

//==================================================================

//Private main read/write

//==================================================================

int CMCP3008::spiWriteRead( unsigned char *data, int length)

{

  struct spi_ioc_transfer spi[length];

  int i = 0;

  int result=-1;

 

    //One spi transfer for each byte

    for(i=0;i<length;i++)

    {

      memset(&spi[i],0,sizeof(spi[i]));              //Flush

      spi[i].tx_buf        = (unsigned long)(data+i); //Transmit from "data"

      spi[i].rx_buf        = (unsigned long)(data+i); //Receive into "data"

      spi[i].len           = sizeof(*(data+i));

      spi[i].delay_usecs   = 0;

      spi[i].speed_hz      = this->speed;

      spi[i].bits_per_word = this->bitsPerWord;

      spi[i].cs_change = 0;

    }

 

    result=ioctl (this->spifd,SPI_IOC_MESSAGE(length),&spi) ;

    if(result<0) {  printf("spiWR==[%i]\n",result); return -1; }

 

  return 0; //Success

}

 

Please help

  • Sign in to reply
  • Cancel
Parents
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    What SPI mode are you using, is it the correct one ?

     

    See here for more info

    http://www.ti.com/lit/ug/slau411d/slau411d.pdf

    and

    https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

     

    The MCP3008 can use mode 0 or 1 and depending on what your clock is doing, it could be getting confused but this is only showing when the MCP3008 gets warm, Try setting to the other mode and see if it helps, your code does not show the mode your using.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    What SPI mode are you using, is it the correct one ?

     

    See here for more info

    http://www.ti.com/lit/ug/slau411d/slau411d.pdf

    and

    https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

     

    The MCP3008 can use mode 0 or 1 and depending on what your clock is doing, it could be getting confused but this is only showing when the MCP3008 gets warm, Try setting to the other mode and see if it helps, your code does not show the mode your using.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube