User avatar
TonyD
Posts: 447
Joined: Thu Sep 08, 2011 10:58 am
Location: Newcastle, UK
Contact: Website

Re: Multiple SPI

Thu Mar 24, 2016 2:01 pm

well done. Looking forward to seeing your solution
Tony

ats1080
Posts: 44
Joined: Thu Sep 27, 2012 2:10 pm

Re: Multiple SPI

Fri Mar 25, 2016 1:10 pm

So the issue in schematic that was posted is that it doesn't include the ground and 3.3v connections. I was thinking the ground and 3.3v connections he had were all that was needed, but you have to hook up exactly has he has it (pin numbers not physical layout) and attach another 3.3 and ground the the correct pins as well. I wanted to draw up a pic but just haven't had the motivation to do it.

So I got everything working at room temperature. Temps were constantly reading within 1 degree of each other and not fluctuating by more than a degree. Now that the thermocouples are actually in the smoker it is reading some very odd temps. Does anyone have any ideas what might be wrong?

Code: Select all

Probe 0: Temperature : 209.75℉
Probe 1: Temperature : 44.15℉
Probe 0: Temperature : 163.40℉
Probe 1: Temperature : 93.65℉
Probe 0: Temperature : 175.10℉
Probe 1: Temperature : 82.85℉
Probe 0: Temperature : 222.80℉
Probe 1: Temperature : 35.15℉
Probe 0: Temperature : 214.70℉
Probe 1: Temperature : 44.15℉
Probe 0: Temperature : 189.50℉
Probe 1: Temperature : 73.40℉
Probe 0: Temperature : 207.50℉
Probe 1: Temperature : 45.50℉
Probe 0: Temperature : 238.55℉
Probe 1: Temperature : 32.00℉
Probe 0: Temperature : 225.50℉
Probe 1: Temperature : 40.10℉
Probe 0: Temperature : 152.15℉
Probe 1: Temperature : 115.25℉
Probe 0: Temperature : 147.65℉
Probe 1: Temperature : 83.75℉
Probe 0: Temperature : 195.35℉
Probe 1: Temperature : 71.15℉
Probe 0: Temperature : 101.75℉
Probe 1: Temperature : 172.40℉
Probe 0: Temperature : 101.75℉
Probe 1: Temperature : 171.95℉
Probe 0: Temperature : 245.75℉
Probe 1: Temperature : 32.00℉
Probe 0: Temperature : 228.65℉
Probe 1: Temperature : 46.85℉
Probe 0: Temperature : 184.10℉
Probe 1: Temperature : 93.65℉
Probe 0: Temperature : 198.05℉
Probe 1: Temperature : 79.25℉
Probe 0: Temperature : 189.50℉
Probe 1: Temperature : 89.60℉
Probe 0: Temperature : 221.00℉
Probe 1: Temperature : 67.10℉
Probe 0: Temperature : 163.40℉
Probe 1: Temperature : 120.65℉
Probe 0: Temperature : 215.60℉
Probe 1: Temperature : 63.95℉
Probe 0: Temperature : 243.95℉
Probe 1: Temperature : 36.05℉
Probe 0: Temperature : 259.25℉
Probe 1: Temperature : 32.00℉
Probe 0: Temperature : 262.40℉
Probe 1: Temperature : 32.00℉
Probe 0: Temperature : 238.10℉
Probe 1: Temperature : 52.25℉
Probe 0: Temperature : 252.05℉
Probe 1: Temperature : 35.60℉
Probe 0: Temperature : 229.10℉
Probe 1: Temperature : 59.45℉
Probe 0: Temperature : 235.40℉
Probe 1: Temperature : 56.30℉
Probe 0: Temperature : 211.55℉
Probe 1: Temperature : 81.05℉
Probe 0: Temperature : 197.15℉
Probe 1: Temperature : 96.80℉
Edit:
I think this was due to wiring. I put some electrical tape around the door so the grounds don't touch and loosened the door a bit. Seems to be Ok now

Sky1994
Posts: 5
Joined: Wed Feb 22, 2017 5:32 am

Re: Multiple SPI

Wed Feb 22, 2017 4:28 pm

Hi, there I have the problem connect between decoder with RFID rc522 on Rpi. It is the problem that it just appears only Probe 7 and it can not read information.

Code: Select all

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import spidev
import time
import RPi.GPIO as GPIO
import MFRC522

class RFID:

	VALID_DATA   = 0 
	ERROR_CHANNEL = 1
	ERROR_PROBE   = 2
	ERROR_DATA    = 3

	errorString  = [ 'Uid is Valid' , 'Multiplex channel 74HC138/139 error' ,
                        'Probe is not connected' , 'RFID returned bad data']

	def __init__(self,spiPort=0, spiDevice=0,HC138A = None , HC138B = None, HC138C = None):

		self.spi = spidev.SpiDev()
		self.spi.open(spiPort,spiDevice)
		self.HC138A = HC138A
		self.HC138B = HC138B
		self.HC138C = HC138C
		self.HC138Valid = False
    
		if (self.HC138A != None) or (self.HC138B != None) or (self.HC138C != None):
			self.HC138Valid = True
			GPIO.setwarnings(False)
			GPIO.setmode(GPIO.BOARD)
         
		if self.HC138A != None:
			GPIO.setup(self.HC138A,GPIO.OUT)

		if self.HC138A != None:
			GPIO.setup(self.HC138B,GPIO.OUT)

		if self.HC138A != None:
			GPIO.setup(self.HC138C,GPIO.OUT)

	def get(self,Channel=None):
    # Deal with 74HC138/139 Multiplexer if we have one
		if ((Channel == None) and  (self.HC138Valid)) or ((Channel != None) and (not self.HC138Valid)):
			return [None , self.ERROR_CHANNEL]

		if Channel != None:
			if Channel > 7 :
				return [None , self.ERROR_CHANNEL]
			if self.HC138A!=None:
				GPIO.output(self.HC138A, Channel & 1)
			if self.HC138B!=None:
				GPIO.output(self.HC138B, Channel & 2)
			if self.HC138C!=None:
				GPIO.output(self.HC138C, Channel & 4)

    #Now let's read the sensor
		Reader = MFRC522.MFRC522()
		(status,TagType) = Reader.MFRC522_Request(Reader.PICC_REQIDL)
		(status,uid) = Reader.MFRC522_Anticoll()
		uid= [0,0]
		uid = self.spi.xfer2(uid)
    
    #Is the sensor data Valid
		if (uid[1] & 2) == 2:
			return [ None , self.ERROR_DATA ]

    #Is the Probe connected
		if (uid[1] & 4) == 4:
			return [ None , self.ERROR_PROBE ]    
            
		wdata = uid[0] << 8 | uid[1]
		return [(wdata>>3)/4.0  , self.VALID_DATA]

if __name__ == "__main__":
	while True:
		
		rfid = RFID(0,0,11,13,15)
		
		for Probe in range(8):
			probeOK=False
			
			Num_id =0
			_get = RFID.get
			uid = _get(rfid,Probe)

		 #let's check if the data is Valid
		if uid[1] != RFID.VALID_DATA:
			print('Probe {}: {}'.format(Probe,RFID.errorString[uid[1]]))
		else:
			print("Probe {}: Num_id : {}".format(Probe,str(uid[0])))
This is compiled file https://www.img.in.th/image/CUEa?

I hope so you will advise to me this issue. Thanks for your input and help

bongeauts
Posts: 1
Joined: Fri Mar 10, 2017 5:56 pm

Re: Multiple SPI

Fri Mar 10, 2017 6:06 pm

danjperron wrote:Use a 74hc138 and 3 GPIO.

The chip select from the RPi will be one of the E line and use each Y to the corresponding max 6675 chip select.

When you want to read a specific sensor just set the GPio to select the correct sensor.

Strange thing, I just received my max6675 yesterday but it will be set to an arduino using nRF24L01 and then the data will be transfer to the Pi. This one will be attached to me pellet stove.

Daniel
Hi, for instance, if I want to use with this configuration 6 devices (MAX6675), how should I do? How can I wire them to 74hc138 and to RPi?

Luca

Return to “Automation, sensing and robotics”