Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Very Innacurate MCP 3008 Readings

Sat Oct 19, 2019 9:49 pm

I just assembled a pcb with an MCP3008 chip connected to 4 thermistor voltage divider circuits on pins 0-3. When I run a simple python script to get the adc values on each pin however, they are wildly inaccurate and often 0. I am using an AMS1117 with 10uf caps on either side to drop a seperate 5v supply down to a steady 3.3v (Not the Raspberry Pi 5v out because it was giving me issues, I think I was drawing too much current). There is a 0.05 second sleep in between readings, so I am not sampling at an extremely fast rate either. Any ideas for what could cause this issue? Here is my latest readings.

Code: Select all

-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 1984.000000 on pin 7
-----------------------------------
Read: 16320.000000 on pin 0
Read 1984.000000 on pin 1
Read 4032.000000 on pin 2
Read 1984.000000 on pin 3
Read 8128.000000 on pin 4
Read 1984.000000 on pin 5
Read 4032.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 4032.000000 on pin 2
Read 1984.000000 on pin 3
Read 8128.000000 on pin 4
Read 1984.000000 on pin 5
Read 4032.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 4032.000000 on pin 2
Read 1984.000000 on pin 3
Read 8128.000000 on pin 4
Read 1984.000000 on pin 5
Read 4032.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 4032.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 16320.000000 on pin 0
Read 1984.000000 on pin 1
Read 4032.000000 on pin 2
Read 1984.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 4032.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 1984.000000 on pin 5
Read 4032.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 4032.000000 on pin 2
Read 1984.000000 on pin 3
Read 0.000000 on pin 4
Read 1984.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 1984.000000 on pin 1
Read 4032.000000 on pin 2
Read 1984.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 16320.000000 on pin 0
Read 1984.000000 on pin 1
Read 4032.000000 on pin 2
Read 1984.000000 on pin 3
Read 8128.000000 on pin 4
Read 0.000000 on pin 5
Read 4032.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 1984.000000 on pin 3
Read 8128.000000 on pin 4
Read 1984.000000 on pin 5
Read 4032.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 1984.000000 on pin 5
Read 4032.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 1984.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 4032.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 16320.000000 on pin 0
Read 1984.000000 on pin 1
Read 4032.000000 on pin 2
Read 0.000000 on pin 3
Read 8128.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 1984.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 1984.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 4032.000000 on pin 6
Read 1984.000000 on pin 7

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Very Innacurate MCP 3008 Readings

Sat Oct 19, 2019 10:01 pm

Any ideas for what could cause this issue?
Unlikely.

You have omitted, among other things -

The model of RPi board
The OS it is running
The code giving these results
Any wiring details




(Seems to be a continuation of https://www.raspberrypi.org/forums/view ... 2#p1543288 ?)

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sat Oct 19, 2019 10:26 pm

B.Goode wrote:
Sat Oct 19, 2019 10:01 pm
Any ideas for what could cause this issue?
Unlikely.

You have omitted, among other things -

The model of RPi board
The OS it is running
The code giving these results
Any wiring details
It is a continuation of the same project, yes, but I thought it was better etiquette to start a new thread rather than revive one that was several weeks old.

It is a RasPi B3+ running Raspbian OS and you're right...the schematic would probably be helpful.
schematic.PNG
schematic.PNG (36.23 KiB) Viewed 1619 times

Code: Select all

import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
import time
import math
import RPi.GPIO as GPIO

spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
cs = digitalio.DigitalInOut(board.D8)
mcp = MCP.MCP3008(spi, cs)

client = InfluxDBClient(host='localhost', port=8086)
client.create_database('temperatures')
client.switch_database('temperatures')

Ro = 100000
To = 25.0
beta = 4103.69
def temp_get():
    tempf0 = 0
    tempf1 = 0
    tempf2 = 0
    tempf3 = 0
    tempf4 = 0
    tempf5 = 0
    tempf6 = 0
    tempf7 = 0
    #print ("-----------------------------------")
    #Probe 0
    value0 = AnalogIn(mcp, MCP.P0).value #read the adc
    print ("Read: %f on pin 0" % value0)
    if value0 != 0 and value0 != 65535:
        ohms = 9880  / (65535/value0 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf0 = tempc*(9/5) +32

    #Probe 1
    value1 = AnalogIn(mcp, MCP.P1).value #read the adc
    print ("Read %f on pin 1" % value1)
    if value1 != 0 and value1 != 65535:
        ohms = 9880 / (65535/value1 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf1 = tempc*(9/5) +32


    #Probe 2
    value2 = AnalogIn(mcp, MCP.P2).value #read the adc
    print ("Read %f on pin 2" % value2)
    if value2 != 0 and value2 != 65535:
        ohms = 9880 / (65535/value2 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf2 = tempc*(9/5) +32

    #Probe 3
    value3 = AnalogIn(mcp, MCP.P3).value #read the adc
    print ("Read %f on pin 3" % value3)
    if value3 != 0 and value3 != 65535:
        ohms = 9880 / (65535/value3 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf3 = tempc*(9/5) +32

    #Probe 4
    value4 = AnalogIn(mcp, MCP.P4).value #read the adc
    print ("Read %f on pin 4" % value4)
    if value4 != 0 and value4 != 65535:
        ohms = 9880 / (65535/value4 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf4 = tempc*(9/5) +32

    #Probe 5
    value5 = AnalogIn(mcp, MCP.P5).value #read the adc
    print ("Read %f on pin 5" % value5)
    if value5 != 0 and value5 != 65535:
        ohms = 9880 / (65535/value5 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf5 = tempc*(9/5) +32

    #Probe 6
    value6 = AnalogIn(mcp, MCP.P6).value #read the adc
    print ("Read %f on pin 6" % value6)
    if value6 != 0 and value6 != 65535:
        ohms = 9880 / (65535/value6 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf6 = tempc*(9/5) +32

    #Probe 7
    value7 = AnalogIn(mcp, MCP.P7).value #read the adc
    print ("Read %f on pin 7" % value7)
    if value7 != 0 and value7 != 65535:
        ohms = 9880 / (65535/value7 -1) #calculate the ohms of the thermistor
        steinhart = math.log(ohms / Ro) / beta
        steinhart += 1.0 / (To + 273.15)
        tempc = (1.0 / steinhart) - 273.15
        tempf7 = tempc*(9/5) +32
        
    while True:
        temp_get()
        sleep(0.05)
        

trejan
Posts: 902
Joined: Tue Jul 02, 2019 2:28 pm

Re: Very Innacurate MCP 3008 Readings

Sat Oct 19, 2019 10:45 pm

Have you measured the voltages? 5V input? 3.3V output?

This circuit shouldn't draw enough current from the Pi to cause problems. I would suspect a wiring issue or short somewhere. What is the value of R1/6/7/8? If they're very low then you'll probably cause the thermistors to heat up which will affect your readings.

As mentioned above, it shouldn't be necessary to have a separate PSU but are you sure you've got the micro USB connector wired up properly? Pin 1 is VBUS but you've got it as ground?

Are all the grounds connected together? If not then this won't work.

Your schematic shows the ground pin of the 3.3V regulator not connected to anything?

Is the 3.3V on MCP3008 VREF from the Pi or your 3.3V regulator? It should be connected to the output of your 3.3V regulator.

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sat Oct 19, 2019 10:54 pm

trejan wrote:
Sat Oct 19, 2019 10:45 pm
Have you measured the voltages? 5V input? 3.3V output?

This circuit shouldn't draw enough current from the Pi to cause problems. I would suspect a wiring issue or short somewhere. What is the value of R1/6/7/8? If they're very low then you'll probably cause the thermistors to heat up which will affect your readings.

As mentioned above, it shouldn't be necessary to have a separate PSU but are you sure you've got the micro USB connector wired up properly? Pin 1 is VBUS but you've got it as ground?

Are all the grounds connected together? If not then this won't work.

Your schematic shows the ground pin of the 3.3V regulator not connected to anything?

Is the 3.3V on MCP3008 VREF from the Pi or your 3.3V regulator? It should be connected to the output of your 3.3V regulator.
I drew that schematic up quite hastily because the actual one is on my other computer. Here is a more accurate version. The grounds are all connected via a plane on the PCB and the 3.3 was a label for the regulator output not the RPi's on-board. When testing this, for some reason when using the 3.3 from the raspberry pi, the voltage across all the thermistors changes simultaneously as if they were in series not parallel. I checked my wiring multiple times and as soon as I switched from the 3.3 out on the Pi to a dedicated voltage supply, it started working as expected, no other changes to the wiring on my breadboard.

I took readings with an oscilloscope and the 1117 is outputting a steady 3.3v, and the voltage across the thermistors is a steady voltage around 3V as well. They are rated for 100k ohm at 25C, so 3V makes sense for room temperature. I am using 10k ohm resistors for voltage division because these thermistors will mainly measure much higher temps where their resistance will drop to around 5-15k ohms.
Attachments
schematic.PNG
schematic.PNG (41.77 KiB) Viewed 1606 times

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12412
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 12:14 am

Because it against forum rules to start two threads about the same topic, I have decided to delete your older thread.

never start a new thread when an older one about the same subject exists, repeat offenders receive a (short) ban

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 12:17 am

Here is a picture of the oscilloscope reading across a thermistor for anyone interested. There is about 5 milivolts of noise, I might have to up the 10uF cap to 22uF, but that little noise shouldn't cause such a massive variance should it? Also doesn't explain the 0's.
Attachments
Voltage Test.PNG
Voltage Test.PNG (63.39 KiB) Viewed 1581 times

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 12:19 am

mahjongg wrote:
Sun Oct 20, 2019 12:14 am
Because it against forum rules to start two threads about the same topic, I have decided to delete your older thread.

never start a new thread when an older one about the same subject exists, repeat offenders receive a (short) ban
My mistake, is there a link to the rules somewhere? I didn't see any in the FAQ's or stickied on the thread...

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 2:32 am

So turns out there was a short on my pcb. Should have checked the traces before soldering. Working "correctly" now. Still curious about the forum rules though.

My voltage is still stable on the oscilloscope, but my readings are kind of sporadic and the 0's are still present.

Code: Select all

-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 60160.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 0.000000 on pin 7
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 60224.000000 on pin 2
Read 0.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55616.000000 on pin 0
Read 60096.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 65472.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 0.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 0.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 56384.000000 on pin 0
Read 60096.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 57088.000000 on pin 0
Read 60096.000000 on pin 1
Read 58560.000000 on pin 2
Read 0.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 0.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 0.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55680.000000 on pin 0
Read 640.000000 on pin 1
Read 1216.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 57792.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 57792.000000 on pin 0
Read 60096.000000 on pin 1
Read 58432.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55872.000000 on pin 0
Read 60096.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 60288.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 0.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 0.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 57792.000000 on pin 0
Read 60096.000000 on pin 1
Read 57856.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 0.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55808.000000 on pin 0
Read 60096.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 0.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 56832.000000 on pin 0
Read 0.000000 on pin 1
Read 58816.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 0.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55552.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 0.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 65408.000000 on pin 7
New Temps
-----------------------------------
Read: 55616.000000 on pin 0
Read 0.000000 on pin 1
Read 0.000000 on pin 2
Read 0.000000 on pin 3
Read 0.000000 on pin 4
Read 65472.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 0.000000 on pin 0
Read 0.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 65472.000000 on pin 5
Read 65472.000000 on pin 6
Read 0.000000 on pin 7
New Temps
-----------------------------------
Read: 55808.000000 on pin 0
Read 60096.000000 on pin 1
Read 60288.000000 on pin 2
Read 65472.000000 on pin 3
Read 65472.000000 on pin 4
Read 0.000000 on pin 5
Read 0.000000 on pin 6
Read 0.000000 on pin 7

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 3:55 am

I just tried testing it one more time. Now all my voltages are the same, even though the thermistors are in parallel. I hooked up the probe to the first thermistor and put the fourth one over a flame, and the voltage across the first one started dropping. Each line should have it's own independent 3.3V that doesn't vary based on the others if they are connected in parallel. It wasn't doing this before, It just started doing it between when I last tested it and now, with no changes to the board. Is this a sign of a faulty mcp3008?

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 7:36 am

No. It's likely a sign of faulty wiring.

Schematics are pretty and can be useful but are not a substitute for clear photos which show the actual wiring.

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 2:40 pm

joan wrote:
Sun Oct 20, 2019 7:36 am
No. It's likely a sign of faulty wiring.

Schematics are pretty and can be useful but are not a substitute for clear photos which show the actual wiring.
So I came back to it today, and before checking the replies on this, I realized multiple pins on the mcp3008 were shorted together that weren't previously and had no reason to be. I replaced the chip (Learning the importance of why you should use sockets and not directly solder chips as I initially did). And now it is working correctly.

I am attaching my PCB anyway though because it is my first "complicated" PCB design (a.k.a more than 7 components) and I would love any constructive criticism on the layout. There is a fan controller circuit on the same board, which is what the components in the top right are for. I also had to wire the SMD components backward for toner transfer, because I also needed to mirror the design for the IC. There doesn't seem to be a way to mirror a component in eagle without switching it to another board layer, unfortunately. At least as far as I know. I also tacked down the board before reading this, so I can't get a picture of the underside without ripping it back up...probably should have just gone to the store and bought screws...sorry.
Attachments
No Ratsnest.PNG
No Ratsnest.PNG (62.33 KiB) Viewed 1463 times
PCB.PNG
PCB.PNG (116.98 KiB) Viewed 1465 times

trejan
Posts: 902
Joined: Tue Jul 02, 2019 2:28 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 3:01 pm

You can power this board from the Pi now you've found the shorts. Add two extra pins to the header in the bottom right for 3.3V and ground to the Pi. The USB connection isn't necessary any more and you can skip all those components in the top left + the central ground pin.

The mounting hole arrangement is odd and moving them to the corners would make it easier to mount this board.

If you want to keep the USB connection as a backup then move it down so you can put the mounting hole in the corner.

If you are going to socket the chip then use turned pin sockets. They're more expensive than the cheap leaf sockets but give you a more reliable connection.

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 3:14 pm

trejan wrote:
Sun Oct 20, 2019 3:01 pm
You can power this board from the Pi now you've found the shorts. Add two extra pins to the header in the bottom right for 3.3V and ground to the Pi. The USB connection isn't necessary any more and you can skip all those components in the top left + the central ground pin.

The mounting hole arrangement is odd and moving them to the corners would make it easier to mount this board.

If you want to keep the USB connection as a backup then move it down so you can put the mounting hole in the corner.

If you are going to socket the chip then use turned pin sockets. They're more expensive than the cheap leaf sockets but give you a more reliable connection.
That sounds brilliant! The mounting holes on the left side were supposed to be lined up with each other, but I misplaced them and deleting mounting holes in Eagle is unnecessarily complicated compared to a component. I still am not sure how to do it. But for sure will be making these changes!

trejan
Posts: 902
Joined: Tue Jul 02, 2019 2:28 pm

Re: Very Innacurate MCP 3008 Readings

Sun Oct 20, 2019 3:34 pm

You can buy throughhole micro USB sockets that are power only e.g. https://www.aliexpress.com/item/33042205393.html It isn't needed for this project but might be handy for you in the future.

The throughhole connector will be much stronger than a surface mount version.

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Nov 10, 2019 10:49 pm

I thought the issue was fixed but it is not. My readings are "more accurate" but I am still getting frequent spikes and zeros. I don't know how to debug at this point, the oscilloscope isn't showing any spikes or drops on my voltage supply. Any ideas on what could fix this?

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Mon Nov 11, 2019 8:39 pm

Is it possible to change the SPI frequency with circuitpython library? Thinking of experimenting with that.

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sat Nov 16, 2019 4:36 pm

Bump?

User avatar
scruss
Posts: 2630
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Very Innacurate MCP 3008 Readings

Sat Nov 16, 2019 5:49 pm

Newguys wrote:
Sat Oct 19, 2019 9:49 pm
…There is a 0.05 second sleep in between readings, so I am not sampling at an extremely fast rate either.
The MCP3008 should be up for that, but your thermistor probably isn't. What's the response time or thermal time constant (τ) for your thermistor? Thermistors typically take several seconds to respond. Not that that's the source of the noise, but it's somewhat futile reading a sensor tens of times a second when it's going to take a couple of seconds to get to the appropriate resistance.

If you need really rapid response, thermistors aren't great. Faster sensors like thermocouples or Pt100 sensors have really annoying interfacing needs. Pt100s also tend to be expensive.

For noisy sensors, using the MCP3008 in differential mode might help get a clear signal. Yes, I know it would need you to redesign your board, but the chip can be reconfigured to read 4 differential channels, one for each of your thermistors. A rolling average of results is also another way of getting cleaner output.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sat Nov 16, 2019 6:00 pm

scruss wrote:
Sat Nov 16, 2019 5:49 pm
Newguys wrote:
Sat Oct 19, 2019 9:49 pm
…There is a 0.05 second sleep in between readings, so I am not sampling at an extremely fast rate either.
The MCP3008 should be up for that, but your thermistor probably isn't. What's the response time or thermal time constant (τ) for your thermistor? Thermistors typically take several seconds to respond. Not that that's the source of the noise, but it's somewhat futile reading a sensor tens of times a second when it's going to take a couple of seconds to get to the appropriate resistance.

If you need really rapid response, thermistors aren't great. Faster sensors like thermocouples or Pt100 sensors have really annoying interfacing needs. Pt100s also tend to be expensive.

For noisy sensors, using the MCP3008 in differential mode might help get a clear signal. Yes, I know it would need you to redesign your board, but the chip can be reconfigured to read 4 differential channels, one for each of your thermistors. A rolling average of results is also another way of getting cleaner output.
I thought thermistors were supposed to be more accurate with the analog resistance, but less durable, that's why I made the choice. Unfortunately, I can't get any data on them because the manufacturer ignored my support requests for data sheets. I tried changing the readings to one time per second, but I still get 0's and spikes, even though on the oscilloscope graph there is no such change in voltage across the probe.

User avatar
scruss
Posts: 2630
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Very Innacurate MCP 3008 Readings

Sat Nov 16, 2019 9:17 pm

There's a good chance that it's a Vishay NTCLE100E3: https://www.vishay.com/docs/29049/ntcle100.pdf
… or behaves very like one.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Newguys
Posts: 48
Joined: Sun Sep 22, 2019 3:02 pm

Re: Very Innacurate MCP 3008 Readings

Sun Nov 17, 2019 3:10 am

scruss wrote:
Sat Nov 16, 2019 9:17 pm
There's a good chance that it's a Vishay NTCLE100E3: https://www.vishay.com/docs/29049/ntcle100.pdf
… or behaves very like one.
Will take a look, thank you!

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