Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MCP3304, 13-bit 8-channel ADC #1

Merged
merged 2 commits into from
Jan 5, 2017

Conversation

rxseger
Copy link
Contributor

@rxseger rxseger commented Oct 6, 2016

Adds support for the MCP3304 chip, datasheet here: http://www.microchip.com/wwwproducts/en/MCP3304

This is a 8-channel ADC, similar to MCP3208 and MCP3304, but 13-bit instead of 10- or 12-bit. It also optionally supports differential inputs (using the 4 channel pairs) but this PR only adds 8-channel single-sided input support. Tested on a Raspberry Pi 3.

@fivdi
Copy link
Owner

fivdi commented Oct 10, 2016

Thanks for the pull request.

@fivdi
Copy link
Owner

fivdi commented Oct 10, 2016

According to the datasheet (http://ww1.microchip.com/downloads/en/DeviceDoc/21697F.pdf) the MCP3304 operates at 4.5V to 5.5V. This means running out of spec on machines like the Raspberry Pi or level converters + special power supply. How are you operating the MCP3304?

@rxseger
Copy link
Contributor Author

rxseger commented Oct 13, 2016

You caught me :) Technically I am running the MCP3304 out of spec, powering it at 3.3V from the Raspberry Pi (I have purchased some level shifters, but haven't got around to trying them out yet), ideally could power with 5V and convert to 3.3V, nonetheless it does seem to be working well for my purposes on 3.3V (using for homebridge-lightsensor-analog, only 1 channel, low sampling rate, maybe why I haven't noticed any problems).

@fivdi
Copy link
Owner

fivdi commented Oct 15, 2016

I'll order an MCP3404 and test. If all is OK the PR will be merged.

@rxseger
Copy link
Contributor Author

rxseger commented Oct 17, 2016

Sounds good. As another data point I've finally tested the MCP3304 with the level shifters (5V on HV, 3.3V on LV) on the SPI bus (CE0, MOSI, MISO, SCLK) and powering with 5V:

screen shot 2016-10-17 at 1 33 33 am

seems to be working well (channel 0 tied to unfiltered ~5.0V, 1 to ground, 7 to a photodiode, others floating):

4.97 0.00 0.38 0.39 0.38 0.38 0.42 1.18 
4.99 0.00 0.40 0.41 0.40 0.40 0.43 1.17 
4.97 0.00 0.41 0.41 0.41 0.41 0.44 1.18 
4.97 0.00 0.41 0.42 0.41 0.41 0.44 1.17 
4.98 0.00 0.42 0.42 0.42 0.42 0.45 1.18 

@fivdi
Copy link
Owner

fivdi commented Dec 28, 2016

@rxseger Sorry about the delay here. I have a few MCP3304s now and hope to test this PR soon.

@fivdi fivdi merged commit 52a08a0 into fivdi:master Jan 5, 2017
@fivdi
Copy link
Owner

fivdi commented Jan 5, 2017

@rxseger Thank you for this pull request. It has been merged and is now available with mcp-spi-adc v0.4.0 on npm. I made a few small tweaks before publishing, I hope you don't mind.

One thing of note that was modified is the default clock frequency for the MCP3304. There are two datasheets for the MCP3304 at Microchip. This one from 2008 and this one from 2011. The timing specifications on page 4 of the 2008 datasheet state that the maximum clock frequency at VDD = 2.7V is 1.05MHz. The 2011 datasheet no longer specifies a clock frequency for VDD = 2.7V. For all other supported chips the default clock frequency is the clock frequency at VDD = 2.7V so the same was done for the MCP3304.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants