I have been working on a new add on board for the Raspberry pi. The ADC Pi is an 8 channel 15 bit analogue to digital converter designed to work with the Raspberry Pi platform. The ADC Pi is based on two Microchip MCP3428 A/D converters each containing 4 analogue inputs with up to 16 bit resolution. The MCP3428 is a delta-sigma A/D converter with low noise differential inputs. We designed the ADC Pi to work as a single ended A/D converter using the internal 2.048V reference voltage with the -V pins tied to ground. A voltage divider on the ADC Pi board brings the input voltage range to a much more useful 0 – 5.06V. In this configuration the sample size is 15 bits for each channel.
The ADC Pi is powered through the host Raspberry Pi using the GPIO port and extended pins on the GPIO connector allow you to stack the ADC Pi along with other expansion boards.
The two MCP3428 A/D converters communicate via i2c to the host Raspberry Pi giving you eight analogue inputs to use.
A logic level converter is included on the ADC Pi board giving you a buffered 5V i2c port making it easy to add other I2C devices which operate at 5 volts without damaging the raspberry pi 3.3 volt i2c port. The i2c buffer uses BSN20 N-channel mosfets with a maximum drain current of 100mA.
http://www.abelectronics.co.uk/products/3/Raspberry-Pi/7/ADC-Pi---Raspberry-Pi-Analogue-to-Digital-converter
ADC Pi 8 channel I2C ADC converter
17 posts
- Posts: 7
- Joined: Sat Jul 14, 2012 8:10 pm
- Location: Swanage, UK
Mine just arrived. They shipped it out the same day I ordered it.
I'll get it hooked up and let you know how it goes.
I'll get it hooked up and let you know how it goes.
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
Wonder what the ENOB is with one, four or 8 i inputs is.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/
- Posts: 1131
- Joined: Sat Jul 14, 2012 6:40 pm
- Location: Reading, UK
I got mine today but have no clue how to use it. I read so much about it but never how to interface with it on a noob level.
- Posts: 2
- Joined: Tue Nov 06, 2012 3:51 am
Did you try the tutorial for how to get it working:
http://elinux.org/RPi_ADC_I2C_Python
My plan is to follow that and hopefully it "just works".
I think I will probably also solder some female headers onto the adc board so I can just "plug" things in and out of it.
Give those steps a try and if it does not work as expected, post back here and you will get help with it.
http://elinux.org/RPi_ADC_I2C_Python
My plan is to follow that and hopefully it "just works".
I think I will probably also solder some female headers onto the adc board so I can just "plug" things in and out of it.
Give those steps a try and if it does not work as expected, post back here and you will get help with it.
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
bgirardot wrote:Did you try the tutorial for how to get it working:
http://elinux.org/RPi_ADC_I2C_Python
My plan is to follow that and hopefully it "just works".
I think I will probably also solder some female headers onto the adc board so I can just "plug" things in and out of it.
Give those steps a try and if it does not work as expected, post back here and you will get help with it.
It absolutely did "just work" when following the tutorial on the wiki for getting it working. Now I just have to use it to do something fun.
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
techpaul wrote:Wonder what the ENOB is with one, four or 8 i inputs is.
If there is a moderately easy way for a newb to find this out using the board, let me know and I'll give it a try.
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
Anyone used this with a GUI? im trying to write a simple python and GTK3+ GUI program to do some basic calculation on the output and print the results to the screen, im very new to all this and have manged to get a basic gui programned in glade which should read from pin 1 and dsiplay it to screen when a button is pressed, however when i press the button i get:
- Code: Select all
File "./adc_demo.py", line 88, in on_sfm_button_clicked
self.rpm = (getadcreading(adc_address1, adc_channel1))
File "./adc_demo.py", line 40, in getadcreading
bus.transaction(i2c.writing_bytes(address, channel))
File "/home/pi/quick2wire-python-api/src/quick2wire/i2c.py", line 72, in transaction
ioctl(self.fd, I2C_RDWR, addressof(ioctl_arg))
IOError: [Errno 25] Inappropriate ioctl for device
- Code: Select all
#!/usr/bin/env python3
# read abelectronics ADC Pi board inputs
# uses quick2wire from http://quick2wire.com/
# github: https://github.com/quick2wire/quick2wire-python-api
# Requries Python 3
# I2C API depends on I2C support in the kernel
#
# This is a slightly modified version of the example code on http://www.abelectronics.co.uk/products/3/Raspberry-Pi/7/ADC-Pi---Raspberry-Pi-Analogue-to-Digital-converter
# See http://elinux.org/RPi_ADC_I2C_Python for full setup instructions
import quick2wire.i2c as i2c
from gi.repository import Gtk
import re
import time
adc_address1 = 0x68
adc_address2 = 0x69
adc_channel1 = 0x98
adc_channel2 = 0xB8
adc_channel3 = 0xD8
adc_channel4 = 0xF8
for line in open('/proc/cpuinfo').readlines():
m = re.match('(.*?)\s*:\s*(.*)', line)
if m:
(name, value) = (m.group(1), m.group(2))
if name == "Revision":
if value [-4:] in ('0002', '0003'):
i2c_bus = 0
else:
i2c_bus = 1
break
with i2c.I2CMaster(i2c_bus) as bus:
def getadcreading(address, channel):
bus.transaction(i2c.writing_bytes(address, channel))
time.sleep(0.05)
h, l, r = bus.transaction(i2c.reading(address,3))[0]
time.sleep(0.05)
h, l, r = bus.transaction(i2c.reading(address,3))[0]
t = (h << 8) | l
v = t * 0.000154
if v < 5.5:
return v
else: # must be a floating input
return 0.00
class Buglump:
def __init__(self):
self.gladefile = "tutorial-4.glade"
self.builder = Gtk.Builder()
self.builder.add_from_file(self.gladefile)
self.builder.connect_signals(self)
self.window = self.builder.get_object("window1")
self.aboutdialog = self.builder.get_object("aboutdialog1")
self.statusbar = self.builder.get_object("statusbar1")
self.window.show()
def on_window1_destroy(self, object, data=None):
print ("quit with cancel")
Gtk.main_quit()
def on_gtk_quit_activate(self, menuitem, data=None):
print ("quit from menu")
Gtk.main_quit()
def on_push_status_activate(self, menuitem, data=None):
print ("updated status bar")
self.message_id = self.statusbar.push(0, "Updated Status Bar")
def on_pop_status_activate(self, menuitem, data=None):
print ("cleared status bar")
self.statusbar.remove_message(0, self.message_id)
def on_gtk_about_activate(self, menuitem, data=None):
print ("help about selected")
self.response = self.aboutdialog.run()
self.aboutdialog.hide()
def on_sfm_button_clicked(self, button, data=None):
self.result1 = self.builder.get_object("result1")
self.rpm = getadcreading(adc_address1, adc_channel1)
print ("calculate rpm clicked")
self.result1.set_text(self.rpm)
if __name__ == "__main__":
main = Buglump()
Gtk.main()
- Posts: 7
- Joined: Sat Aug 11, 2012 8:24 pm
raptorred wrote:Anyone used this with a GUI? im trying to write a simple python and GTK3+ GUI program to do some basic calculation on the output and print the results to the screen, im very new to all this and have manged to get a basic gui programned in glade which should read from pin 1 and dsiplay it to screen when a button is pressed, however when i press the button i get:
Did you run the adc_demo.py script unedited to see if it worked correctly right after installing the required libraries?
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
Yes and it works perfectly
- Posts: 7
- Joined: Sat Aug 11, 2012 8:24 pm
raptorred wrote:Yes and it works perfectly
I am not a python programmer at all, but I can mimic what other people do pretty well. About the only thing I know about python is that white space matters (*grumble*).
In the stock adc demo file, the main part of the program that uses the getadcreading() function seems to be under the the "with" block, meaning at the same indentation level as the getadcreading() definition.
In your code, your class definition is not under that with block and it looks like your indentation spacing is different than the demo file. I would suggest getting the indents uniform (forgive me if this is meaningless in python) and try putting the class definition code at the same indentation level as the definition of getadcreading().
I did that here locally with your code and I get a different error than you do, I got exactly the same error you did until I made the indentations uniform and put your code at the same indent level as the getadcreading() indent level.
However, not having the same tutorial-4.glade file you have I am sure is my problem.
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
ok thanks will try that here is my glade file if its any help:
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAboutDialog" id="aboutdialog1">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<property name="program_name">Pec Flow Bench</property>
<property name="version">0.1</property>
<property name="copyright" translatable="yes">Copyright © PEC Racing</property>
<property name="website">www.pecracing.com</property>
<property name="license" translatable="yes">GNU</property>
<property name="authors">Richard Grace</property>
<child internal-child="vbox">
<object class="GtkBox" id="aboutdialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="aboutdialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="default_width">250</property>
<property name="default_height">100</property>
<signal name="destroy" handler="on_window1_destroy" swapped="no"/>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem1">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem3">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem4">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="gtk_quit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem6">
<property name="label">gtk-cut</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem7">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem8">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem9">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="push_status">
<property name="label" translatable="yes">Push Status</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image1</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_push_status_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="pop_status">
<property name="label" translatable="yes">Pop Status</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image2</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_pop_status_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="gtk_about">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_gtk_about_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">SFM</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Diameter</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">RPM</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="result1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="width_chars">8</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="sfm_button">
<property name="label" translatable="yes">Calc</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_sfm_button_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Enter the SFM (Surface Feet per Minute)
and the cutter diameter.
Press the Calc button to see the
recommended cutter RPM.</property>
<property name="ellipsize">start</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
- Posts: 7
- Joined: Sat Aug 11, 2012 8:24 pm
bgirardot wrote:raptorred wrote:Yes and it works perfectly
I am not a python programmer at all, but I can mimic what other people do pretty well. About the only thing I know about python is that white space matters (*grumble*).
In the stock adc demo file, the main part of the program that uses the getadcreading() function seems to be under the the "with" block, meaning at the same indentation level as the getadcreading() definition.
In your code, your class definition is not under that with block and it looks like your indentation spacing is different than the demo file. I would suggest getting the indents uniform (forgive me if this is meaningless in python) and try putting the class definition code at the same indentation level as the definition of getadcreading().
I did that here locally with your code and I get a different error than you do, I got exactly the same error you did until I made the indentations uniform and put your code at the same indent level as the getadcreading() indent level.
However, not having the same tutorial-4.glade file you have I am sure is my problem.
For what it is worth, I fixed my problem by casting the float value returned from the adc library to a string and now your program works basically fine with the tutorial-4.glade file I have. So I think I can say for sure, it is the indentation of your code that is causing your problem.
You might find you need to change your code around line 89 to read:
- Code: Select all
self.result1.set_text(str(self.rpm))
To display the float value as a string, as your .glade file looks almost the same as mine in that regard.
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
Hi,
Am i save to connect a (+) 11-12 (whats the max?) volt analog input from aa batterys to the analog inputs of the board and the (-) to the gnd of the board? Or do i have to convert it first?
Thnx in advance!
Am i save to connect a (+) 11-12 (whats the max?) volt analog input from aa batterys to the analog inputs of the board and the (-) to the gnd of the board? Or do i have to convert it first?
Thnx in advance!
- Posts: 1
- Joined: Tue Jan 29, 2013 9:07 pm
p4y wrote:Hi,
Am i save to connect a (+) 11-12 (whats the max?) volt analog input from aa batterys to the analog inputs of the board and the (-) to the gnd of the board? Or do i have to convert it first?
Thnx in advance!
The maximum input level is 5V so you would need to use a voltage divider to bring the 11-12 volts down to a maximum of 5 volts before it goes into the ADC input.
- Posts: 7
- Joined: Sat Jul 14, 2012 8:10 pm
- Location: Swanage, UK
p4y wrote:Hi,
Am i save to connect a (+) 11-12 (whats the max?) volt analog input from aa batterys to the analog inputs of the board and the (-) to the gnd of the board? Or do i have to convert it first?
Thnx in advance!
This post has some more information about what size resistor to use for the voltage divider:
viewtopic.php?f=44&t=22330#p211423
- Posts: 517
- Joined: Wed Oct 10, 2012 6:20 am
- Location: Switzerland
I have one of these also, and while it works great the SPI interface seems to be slow (sample rates in the single digits per second). I suspect this is just the nature of the beast but still wonder...?
Cheers,
Wisar
Cheers,
Wisar
- Posts: 56
- Joined: Tue Sep 25, 2012 6:33 am
- Location: Temple near Marlow, England