tag:blogger.com,1999:blog-6238454757421809452.post5259573286927526340..comments2024-01-29T06:22:58.174-05:00Comments on The Raspberry Pi <br>Hobbyist: Analog InterfaceTed B Halehttp://www.blogger.com/profile/16887056993667506084noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-6238454757421809452.post-41111417935766156452016-03-10T21:38:31.072-05:002016-03-10T21:38:31.072-05:00hi , I can not get it working for the 3208 ... wou...hi , I can not get it working for the 3208 ... would you please list the entire readadc(adcnum) routine ? thanks !!! from argentina.<br />Anonymoushttps://www.blogger.com/profile/12835475106144378552noreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-87420519252324139592014-11-30T22:32:20.356-05:002014-11-30T22:32:20.356-05:00buff[1] overflows if adcnum>3. The hi order bi...buff[1] overflows if adcnum>3. The hi order bit needs to be in buff[0]. Use this:<br /><br />buff[0] = 0x06 | ((adcnum & 0x07) >> 7);<br /><br />I also ran in to this once I tried reading the higher adc channels but forgot to update the blog. Thanks for the reminder.<br />Ted B Halehttps://www.blogger.com/profile/16887056993667506084noreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-72104067421546528532014-11-30T08:22:21.734-05:002014-11-30T08:22:21.734-05:00Hi there,
long time ago Pat asked a question on in...Hi there,<br />long time ago Pat asked a question on integrating the mcp3208. Now i have the same problem. I have modified the code but i can only read 4 input ports, after readind port 0 to 3 the values are repeating. idea?<br />buff[0] = 6;<br /> buff[1] = (8+adcnum)<<6;<br /> buff[2] = 0;<br /> buff[3] = 0;<br /> wiringPiSPIDataRW(0, buff, 3); <br /> adc = 0;<br /> adc = ((buff[1]& 0x0F) << 8) | buff[2];<br /> <br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-42287058554653177092014-01-02T10:53:00.927-05:002014-01-02T10:53:00.927-05:00Good point. I used WiringPi as my interface, so I...Good point. I used WiringPi as my interface, so I had to use the designated SPI pins. Letting Gordon do all the hard work really does simplify these projects.<br /><br />http://wiringpi.com/Ted B Halehttps://www.blogger.com/profile/16887056993667506084noreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-386178729919163672013-12-27T16:53:55.381-05:002013-12-27T16:53:55.381-05:00It looks like the Adafruit tutorial is using bit b...It looks like the Adafruit tutorial is using bit banging, rather than true SPI. Therefore, the wiring does not match your wiring for SPI based readout.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-68696237524044569492013-07-17T16:38:51.616-04:002013-07-17T16:38:51.616-04:00Hi Ted,
I'm trying to read from a MCP3208 the ...Hi Ted,<br />I'm trying to read from a MCP3208 the 12 bit version of the ic you used above.<br />I modified your line;<br />adc = ((buff[1]&3) << 8) + buff[2]; to read <br />adc = ((buff[1]&15) << 8) + buff[2]; so that I capture the 4 lower bits; bit 11, bit 10, bit9 and bit 8 and not only just bit9 and bit8 as your programme did. For some reason bit 10 and 11 never change from zero. If I do a printf on buff[1] immediately after the line; wiringPiSPIDataRW(0, buff, 3); while the analog in signal=vref I only get 3 instead of 15. For some reason I get returned a 10bit instead of a 12 bit result. Any ideas???<br /><br />Pat.<br /> <br /><br />int readadc(adcnum) <br />{<br /> uint8_t buff[3]; <br />int adc; <br />if ((adcnum > 7) || (adcnum < 0)) return -1; buff[0] = 1; <br />buff[1] = (8+adcnum)<<4; <br />buff[2] = 0; <br />wiringPiSPIDataRW(0, buff, 3); <br />adc = ((buff[1]&3) << 8) + buff[2]; <br />return adc; <br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-19251224927453632242013-06-03T10:30:12.308-04:002013-06-03T10:30:12.308-04:00Adafruit has a good write up on the MCP3008
Look h...Adafruit has a good write up on the MCP3008<br />Look here:<br />http://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi<br /><br /><br />Ted B Halehttps://www.blogger.com/profile/16887056993667506084noreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-39601130772173224182013-05-27T01:43:31.594-04:002013-05-27T01:43:31.594-04:00Hi Ted! Found it very useful for me!! I have the s...Hi Ted! Found it very useful for me!! I have the same MCP3008 but I always receive 1023 as result...I think I'm doing something wrong in the cabling...have you got some schematics?<br /><br />Thank youAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-68757778131256147602013-05-04T15:28:20.990-04:002013-05-04T15:28:20.990-04:00I am really glad to find your blog! :)I had exactl...I am really glad to find your blog! :)I had exactly the same problem than "Anonymous" above ;). Since I am really a newbie in manipulating bits, your code really helped me and made me understanding things! Cool! thanks! :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-43341693216993681192013-03-04T10:44:39.059-05:002013-03-04T10:44:39.059-05:00Hey, Thanks so much for this code. There are many ...Hey, Thanks so much for this code. There are many phyton-adc-RPI-tutorials but i was searching for it in C. I would have adapt it myself but im very glas i found your code :)<br /><br />There is one question left:<br />How to convert the other 7 analoug channels? (how to reads them into the RPI)<br />Do I only have to change<br />x1 = readadc(chan);<br />the chan-parameter?<br /><br />Thanks :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-16333192787869561882013-03-02T01:19:19.701-05:002013-03-02T01:19:19.701-05:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/09249591690038219231noreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-68645363231486462212013-01-03T08:51:46.659-05:002013-01-03T08:51:46.659-05:00Glad that you found it helpful. That's the re...Glad that you found it helpful. That's the reason I do this blog.<br />I will have my code on github eventually, I just have to catch up on a backlog of other stuff. I am working on another project that is hosted on google code (using a git interface) but it's not RasPi related.Ted B Halehttps://www.blogger.com/profile/16887056993667506084noreply@blogger.comtag:blogger.com,1999:blog-6238454757421809452.post-16658848727118922872013-01-02T08:55:55.958-05:002013-01-02T08:55:55.958-05:00Love your code
Made SPI all the more easier for me...Love your code<br />Made SPI all the more easier for me to understand :D<br />Why don't you host your code on GitHub ?Anonymousnoreply@blogger.com