maurice1
Posts: 37
Joined: Tue Mar 05, 2013 8:55 am
Location: Dublin

3 x MCP3008 Gpiozero RPi3

Mon May 30, 2016 5:13 pm

Hi I have 3 x MCP3008 testing Gpiozero on a RPi3
I have 3 scripts one each to read each MCP3008.

Code: Select all

#!/usr/bin/env python
from gpiozero import MCP3008
import time

while True:
        
		
	V0  = MCP3008(channel=0, select_pin=25)
	V1  = MCP3008(channel=1, select_pin=25)
	V2  = MCP3008(channel=2, select_pin=25)
	V3  = MCP3008(channel=3, select_pin=25)
	V4  = MCP3008(channel=4, select_pin=25)
	V5  = MCP3008(channel=5, select_pin=25)
	V6  = MCP3008(channel=6, select_pin=25)
	V7  = MCP3008(channel=7, select_pin=25)
		
	M0 = int (V0.value * 1000)
	M1 = int (V1.value * 1000 )
	M2 = int (V2.value * 1000 )
	M3 = int (V3.value * 1000 )
	M4 = int (V4.value * 1000 )
	M5 = int (V5.value * 1000 )
	M6 = int (V6.value * 1000 )
	M7 = int (V7.value * 1000 )
	
	time.sleep(1.2)

	print M0," ",M1," ",M2," ",M3," ",M4," ",M5," ",M6," ",M7
The second script is the same except the pin number is 8 and the third script is pin 7.

I then start the scripts in 3 different windows of putty , everything reads fine.

IF I then stop the last script the readings on the first 2 scripts go to 0 as the readings abd keep scrolling..
If I restart the last script the first 2 scripts read their proper readings without touching them.

It nearly seems that the last script takes over the pins and wont let the others keep reading

If I close script 3 and restart script 1 , script 1 & 2 read normally.

Is there a way to force the existing running script to be in charge ?

Incidentally the 3x3008 have been running a year or more using rpi.gpio with no issues

Return to “Interfacing (DSI, CSI, I2C, etc.)”