Hello Again,
I am receiving now, what I think are voltage levels, some levels from some
simple math added to the source.
Seth
P.S. Here:
voltage: 0.0032258064516129032
16
voltage: 0.0032258064516129032
16
voltage: 0.0032258064516129032
0
voltage: 0.0032258064516129032
24
voltage: 0.0032258064516129032
10
voltage: 0.0032258064516129032
1
voltage: 0.0032258064516129032
24
The line below voltage is the original numerical value w/ what I think is
the a voltage to the right of voltage. Here is the updated source to the
library:
from LDRII import MCP3008
import time
adc = MCP3008()
while True:
Vref = 3.3
Voltage = (Vref / 1023)
print("voltage: \t", Voltage)
print(adc.read(channel = 0))
time.sleep(4)
On Saturday, November 9, 2019 at 11:19:35 PM UTC-6, Mala Dies wrote:
>
> Hello,
>
> I am running a python3 program that has to do w/ SPI on the BBBW and the
> Adafruit_BBIO library. I set up my pins, set up the source, and ran the
> code.
>
> ...
>
> I got back some odd numbers that mean nothing. I was following some ideas
> from Rpi stuff and transferring data to the BBBW via the Adafruit_BBIO
> library to make things work.
>
> So...
>
> from LDRII import MCP3008 #I found this source online and I cannot figure
> out what site I found it at currently. Anyway...if this is your source, say
> so! I will give you credit.
>
> adc = MCP3008()
>
> print(adc.read(channel = 0))
>
> is the source I run from this library...
>
> from Adafruit_BBIO.SPI import SPI
>
> SPI0_CS0 = "P9_17"
> SPI0_D0 = "P9_21"
> SPI0_D1 = "P9_18"
> SPI0_SCLK = "P9_22"
>
> spi = SPI(1, 0)
>
> class MCP3008:
> def __init__(self, bus = 0, device = 0):
> self.bus, self.device = bus, device
> self.spi = SPI()
> self.open()
>
> def open(self):
> self.spi.open(self.bus, self.device)
>
> def read(self, channel = 0):
> adc = self.spi.xfer2([1, (8 + channel) << 4, 0])
> data = ((adc[1] & 3) << 8) + adc[2]
> return data
>
> def close(self):
> self.spi.close()
>
> Now, what I figured would happen, happened and I cannot explain it (yet).
>
> Do you see my error in computation here?
>
> Seth
>
> P.S. I have to use config-pin to set up the pins for use but I receive
> variable numerical values every time I run the source from above. Please
> send some advice if you have time.
>
--
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/d994b90d-0c05-4421-9674-cf5db4ddfba7%40googlegroups.com.