Thank you! What is really good for a non-nativespeaker, you speak relatively slowly and clearly. Once again thanks. Regards
@antalz2 жыл бұрын
Thanks mate, good to also hear appreciation for a bit slower pace. It feels sometimes like you should talk as fast as possible on KZfaq.
@braantechv35662 жыл бұрын
hello, good video, it helps me too much, so i have a question, for the analogic signal, are you using the voltaje of the raspberry or your potenciometer were conected to a external sourse? i hope you understand, i dont spak english
@antalz2 жыл бұрын
Hi, apologies for the long wait. The potentiometer was connected to the Pi. It's possible to connect to an external source, but the ground of that source must be connected to the MCP3208, or the ground of the Pi and that source must be connected.
@jorgefigueroa35363 жыл бұрын
Thanks a lot Antalz for this video, really helped me to understand how to use this analog input "converters", saw lot of videos and couldt catch it great and simple like yours :) Have one small and think simple question, if i want to read/use more analog input channels from the chip, should i recall the ReadChannel3208 function on another loop or sentence ? Lets say, i have value = ReadChannel3208(4) to read a potentiometer like your example video, and i declare a variable like humValue= ReadChannel3208(3) to read a humidity voltage sensor on analog pin 3 of chip? thanks in advance sir. Regards.
@antalz3 жыл бұрын
Yeah that's exactly how you'd do it, you need to call ReadChannel3208() for each measurement you want to make. Good luck!
@yali123 Жыл бұрын
Thank you for a great video! One comment, the pins you mention are really PI GPIO, which are different than the actual 40 pin Header pin numbering. Question: I have the 3208 with 5v from the PI and 2 capacitors 100nf and 220nf. My reading fluctuating from 3147-3156, i.e. 3.812v-3.823v. I have a new cheap voltmeter showing constant 3.824v. This is about 11mv difference. The accuracy of the A2d with 5v reference, is supposed to be ~1mv (5/4096). It seemed your readings were much more stable, within a couple of digits. I also tried adding 100uF electrolytic cap on Vcc and Vin, didn't make a difference. Do you have any idea why this large fluctuation? (trying to test the voltmeter accuracy:))
@antalz Жыл бұрын
I'm honestly not sure what could be causing the fluctuations. It could be the use of long wires or somewhat dodgy connections. The readings might also be more stable if you use higher resistances, so the current that's running is lower. For good readings a stable power supply is also important. As for your multimeter, I think that won't work. You're assuming a 5V reference, but I suspect you don't actually know what the real voltage on the Pi's 5V rail is. You need a reliable multimeter to establish that after all. It will have quite some deviation to begin with, many power supplies for Pis actually supply 5.1V or 5.25V to compensate for wire losses for example. If the actual reference is higher than the assumed 5V, then the real voltages shown by a multimeter will also be higher than what the chip/code say. Finally keep in mind the MCP3208 is not an accurate chip per se. Yes it has 4096 counts of resolution, but a few counts worth of noise is normal. Besides that is also has a few counts worth of offset error and gain error. I don't know the details of that entirely, I never tried squeezing this level of accuracy from an MCP chip. I usually just need tenths of volts at most. If your cheap multimeter is a modern chinese one, then it should be accurate. EEVBLog reviewed/tested many of them against callibrated standards, they were always very accurate.
@chrismoore438 ай бұрын
I would like to take all the analog outputs for my boat and make a digital dashboard. My question is my fuel sending unit is sending between 240-33 ohms. Would I be able to read this with a Raspberry PI? I know I will need an Analog To Digital Converter probably 8ch.
@antalz7 ай бұрын
To read resistances you essentially need to create a resistor divider. In this way you can convert an ohm value to a voltage, which can then be read with an ADC. Finding the math for voltage dividers online should be quite simple.
@123123mike7 ай бұрын
When I enter an integer between 0-7 for 'channel' it gives an error of invalid syntax. When I substitute 'CH4' for 'channel' it seems to move past it but not getting any voltage readings, just 0.00's. Also, if I'm using mcp3008 should this line in the while loop "value = ReadChannel3208(4)" refer to 3208 or 3308. Something's not working. thanks
@123123mike7 ай бұрын
Got it! Been a few years forgot how functions worked, passing parameters to a defined function when calling the function, etc. pretty cool. Great video
@paulwg3163 жыл бұрын
Thanks for your sharing. Would you tell me How to record the Digital Caliper reading into my Raspberry Pi ?
@antalz3 жыл бұрын
I'm afraid I can't, that's not something I've tried to do. I can find some videos about doing that with Arduino, but I don't know how easily those translate to Raspberry Pi
@MauricioHernandez-de8is3 жыл бұрын
Very useful!
@antalz3 жыл бұрын
Good to hear, thanks for watching
@dalesmith86668 ай бұрын
You need to incorporate a low pass filter...etc...Noise will also find it way into he ADC.
@antalz7 ай бұрын
That's a good idea, but there's also a compromise there. A low-pass filter also reduces the response time of the system.
@Alkatross21 күн бұрын
Isn't a capacitor to ground a low pass filter? Still pretty noisey... @@antalz
@djtyros2 жыл бұрын
What 2 capacitors should I use> it sounds like you say, 100 "nano" farads ? is that right, not "micro"? Also, what voltage, thanks. ps. why ceramic capacitors? is there a difference in normal ones. thanks
@antalz2 жыл бұрын
Yeah they're 100 nanofarads. That's a somewhat high value for ceramics. Voltage limit has to be higher than the voltage that you're trying to filter, I believe I used 30V or 50V capacitors. Too high voltage limit doesn't matter. You use ceramics because they have a good high-frequency response, they're small, they're cheap, and they do the job. Electrolytics for example have much higher capacity generally, but are also bulkier, more expensive, and sensitive to polarity. You should really have a set of ceramic capacitors on hand, you can get 1000 for under 20 bucks. They're like resistors in that sense, just have them on hand because they're so often used and so cheap.
@djtyros2 жыл бұрын
@@antalz Thank you so much for a detailed response!! Subbed
@djtyros2 жыл бұрын
@@antalz I've just bought one of those capacitor kits from Amazon, and it has x40 100mF capacitors. I wanted to ask, under what circumstances would you use a lower mF capacitor? I understand getting one with a voltage rating that is higher than needed, but I wondered if there are times when a specific uF/mF capacitor is required. Thank you again for your detailed replies!
@antalz2 жыл бұрын
@@djtyros Did you get an electrolytic set or a ceramic set? A 100 milli-Farad is huge, a 100 micro-Farad is quite normal for an electrolytic but huge for a ceramic, I believe. The markings on ceramic capacitors should tell you their capacity in picofarads.
@antalz2 жыл бұрын
@@djtyros Broadly speaking, if you want to make a voltage stable then you use relatively large values, which you sometimes see in typical L7805 circuits. Usually something like a 100uf electrolytic with a 100nf ceramic. The exact values don't matter so much, you just want the big capacitor for the bigger spikes, and the ceramic for small high-frequency stuff. If you use a 220nf or a 46nf capacitor instead that's usually totally fine. In other cases like filters and integrators and whatnot the exact value of a capacitor can matter a lot, and those cases are unfortunately outside my expertise.
@Snoweuph3 жыл бұрын
my MOSI, MISO and SCK are already occupied by the screen that I use for my PI, is there an alternative that I can use? I have a Pi 4b. I would like to connect two joysticks to the pi which each have two potentiometers and turn them into a gamepad with a few buttons using software. thx
@antalz3 жыл бұрын
That depends on how occupied they are. MOSI/MISO/SCK can be connected to a range of different devices, and then each device needs its own chip select wire connected. Then you can speak to any device by setting its chip select high. If the screen physically blocks you from connecting MOSI/MISO/SCK, or if the screen requires all the bandwidth, then my advice would be to get an Arduino, and connect it to the Pi via USB. Then on the Arduino put a simple sketch that reads its analog inputs, and send that data over to the Pi via the USB serial. You'll need to decide what format to use so send/receive the data, and a small bit of code on both devices to make it happen.
@Snoweuph3 жыл бұрын
@@antalz thx for the response
@Snoweuph3 жыл бұрын
@@antalz I have put all together, but i get this error: spi.open(0,0) IOError: Errno 2 No such file or directory I have spi enabled like you did in your video
@Snoweuph3 жыл бұрын
I also changed the code in AnalogInput-RPi-GPIO.py to use the 3008 (swaped the funktions). I dont know much about python and linux and all what i found online did not helped (sry for my english)
@antalz3 жыл бұрын
@@Snoweuph Did you enable SPI in the raspberry pi config? I'm not sure I covered it in the video, but that is required and that's what usually leads to that error.
@DockterWho2 жыл бұрын
What is the lowest voltage that can me read with this chip and raspberry pi?
@antalz2 жыл бұрын
Hard to say. I don't know what the lowest reference voltage is these will accept, and even then there will be some read noise. I would say the lowest is about 10 counts, so 10*reference voltage / 2^bits
@rayyanislam32792 жыл бұрын
So you can use 2 MCP3008 devices on 1 pi (so 16 channels?)?
@antalz2 жыл бұрын
Yes! You wire each MCP3008 to MISO, MOSI and CLK, and then you must give each MCP3008 its own chip select pin. You can then control which MCP3008 you want to talk to by which pin you pull low before starting the read. That's pi.write(CS_ADC, False). It might actually make more sense to put that line into the read function itself. You can also control any other kind of SPI device alongside the MCP3008. The only trouble is you often need to look into the datasheets and mess with bitwise logic, unless a standard library is already available to use.
@swarnanjalibagchi16662 жыл бұрын
(adc[1]&15)
@antalz2 жыл бұрын
It's pretty complicated. You take the second byte of the adc array (the first byte is adc[0]), you do a logic-and with 15, which is 00001111, and the result you bitshift 8 steps to the right. The reason for bitshifting 8 to the right is because right after that you add the bits that are on the third byte, the + adc[2] statement. The whole bitshifting stuff isn't too complicated, but it takes a while to wrap your head around. Unless you're specifically interested in writing your own SPI code to interface with other SPI devices, I would ignore this part. If you do want to interface with other devices it will take you a while to wrap your head around, and you need to study their datasheets carefully. You will also need an oscilloscope or logic analyzer to have any real hope of making it work.
@antalz2 жыл бұрын
For reading all the channels, just call ReadChannel3208(0), followed by ReadChannel3208(1), then 2,3,4 etc. Using a for loop or a list comprehension is probably a good idea.
@user-gh2mo2yn9i7 ай бұрын
An easier way to add up to 128 Analog ports to a single Pi is
@rushikantpawar84953 жыл бұрын
Can I get circuit digram for this?
@antalz3 жыл бұрын
I think the link in the description to raspberrypi-spy.co.uk has what you need.
@shuchismitabagchi8012 жыл бұрын
How can we store this output data in the sd card of rpi
@antalz2 жыл бұрын
You can write to a file like any other Python variable, there are dozens of tutorials on how to write to files.
@shuchismitabagchi8012 жыл бұрын
@@antalz will it be stored in the sd card? Because I have send those data to a mobile via bluetooth ....I mean is real time data transmission possible With that?
@antalz2 жыл бұрын
@@shuchismitabagchi801 Yes it will if you select a file location on the SD card. I don't know how you can transmit over Bluetooth I'm afraid. You can use sockets to send over WiFi too, but you'll need to learn about serialising data and sockets for that to work.
@shuchismitabagchi8012 жыл бұрын
@@antalz okk ,Thanks a lot
@creativearts4917 Жыл бұрын
How to use it with pico?
@antalz Жыл бұрын
Unfortunately I'm not familiar with Picos
@creativearts4917 Жыл бұрын
@@antalz any reference?
@antalz Жыл бұрын
@@creativearts4917 It appears the Pi Pico has SPI, so maybe you can use the existing libraries in python? Or are you using C? Whatever the case you will need to use the right pinout: datasheets.raspberrypi.com/pico/Pico-R3-A4-Pinout.pdf This might be helpful: www.digikey.be/en/maker/projects/raspberry-pi-pico-rp2040-spi-example-with-micropython-and-cc/9706ea0cf3784ee98e35ff49188ee045 If need be you can adapt the code from this video. Essentially you need to send 3 bytes to tell the chip you want data, and what channel you want it from, and then you listen to and decode the response. How to do that is in the code, but it involved bit-level stuff which is used very rarely, so it's quite a poorly covered subject.
@more2much6963 жыл бұрын
Resolution of inputs
@antalz3 жыл бұрын
10 bits for the MCP3008, and 12 bits for the MCP3208. Resolution is 3.3V/1024 or 3.3V/4096, respectively.