Hello Mr. Dennis, Seth here. Thank you again. It is nice to have people just away ideas like this one. I know you know more than I do on this subject. I am new to SPI and using in Linux Distros on the BBBW never crossed my path until this task.
... So, I will put in your source and see how it works. Would you like to know the answer or terminal writing, I am sure you already have tested it, when I run the source? Seth On Monday, November 11, 2019 at 9:56:47 AM UTC-6, Dennis Bieber wrote: > > On Mon, 11 Nov 2019 09:32:07 -0500, in > gmane.comp.hardware.beagleboard.user > Dennis Lee Bieber <[email protected] > <javascript:>> > wrote: > > Actually, forget the immediately prior correction for adc-2 > >-=-=-=- adc-2.py > >#!/usr/bin/env python3 > >""" > > adc-2.py ADC example using MCP3008 and Adafruit_Blinka > > and Adafruit_CircuitPython_MCP3xxx libraries > > November 11, 2019 Dennis L Bieber > > > > *** UNTESTED ** > > I do not have access to an MCP3008 ADC chip > > > > *** PREREQUISITES *** > > sudo pip3 install adafruit_blinka (might be adafruit-blinka) > > sudo pip3 install adafruit-circuitpython-mcp3xxx > > > > This code reads all 8 channels of the MCP3008. It may be worth > > checking the data sheet for the chip to determine which state > > draws the least current and using a 10KOhm or higher resister to > > pull-up/pull-down the unused inputs. > >""" > > > >import time > > > >import busio > >import digitalio > >import board > >import adafruit_mcp3xxx.mcp3008 as MCP > >from adafruit_mcp3xxx.analog_in import AnalogIn > > > >#constants from spec sheets > >ADC_REF = 3.3 > >ADC_CHANNELS = 8 > > > >T_DELTA = 5.0 > > > >#create the SPI bus and ChipSelect > >spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) > >cs = digitalio.DigitalInOut(board.DS) > > > >#create ADC instance (note: ref_voltage default is 3.3 if not supplied) > >adc = MCP.MCP3008(spi, cs, ref_voltage = ADC_REF) > > > >#create ADC channel instances -- relies on MCP.P0 = 0, etc. > >channels = [ AnalogIn(adc, chan) for chan in range(ADC_CHANNELS) ] > > > >t0 = t = time.time() > >while True: > > print("\nT: %16.2f" % (time.time() - t0)) > > Replace following... > > > for channel in channels: > > #while a 10-bit ADC chip, the raw counts are scaled to 65472 > > raw, voltage = channels[channel].value, channels[channel].voltage > > print("\tChannel: %2d\tCount: %4d\tVoltage: %6.3f" > > % (channel, raw, voltage)) > > for ch, channel in enumerate(channels): > #while a 10-bit ADC chip, the raw counts are scaled to 65472 > raw, voltage = channel.value, channel.voltage > print("\tChannel: %2d\tCount: %4d\tVoltage: %6.3f" > % (ch, raw, voltage)) > > > t += T_DELTA > > time.sleep(t - time.time()) > >-=-=-=- > -- > Dennis L Bieber > > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/80412ec2-eb28-42ea-9f92-35bf3f3415cc%40googlegroups.com.
