Це відео не доступне.
Перепрошуємо.
Why are my ADC readings messed up? (Arduino example)
Вставка
- Опубліковано 16 сер 2024
- Patreon ➤ / jacobsorber
Courses ➤ jacobsorber.th...
Website ➤ www.jacobsorbe...
---
***
Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
More about me and what I do:
www.jacobsorbe...
people.cs.clem...
persist.cs.clem...
To Support the Channel:
+ like, subscribe, spread the word
+ contribute via Patreon --- [ / jacobsorber ]
Source code is also available to Patreon supporters. --- [jsorber-youtub...]
Put a cap parallel to the divide output and add an emitter follower or an op amp follower. You get very low impedance output and you can sample it very fast.
Hi Jacob, would appreciate if you could add more content of embedded systems coding, best practices and tops and tricks I am self taught and always scanning for learning and improving my skills.
Thank you for the great channel I appreciate your time,
J
AFAIK, ATMega has a separate pin for ADC reference voltage. Why not to use it, maybe, with a resistor and zener/LED?
Right. There is also an internal band-gap reference that should be quite immune to power-supply fluctuations. Its is somewhat low voltage though (1.35 V IIRC).
@@edgarbonet1 that is still full of white noise both from power supply and wires. the most clean output of uno adc in my experiments is just to feed the supply voltage to external reference pin.
in this case as mentioned, the surge current of motor upon action and sampling rate of adc causes the problem.
Doesn't the arduino have an internal voltage reference that you can use? Most microcontrollers I've used have that. Googled it and it seems it does have an internal 1.1V reference, that you can use, of course you'd also change the resistor divider to bring the signal to that level. Wouldn't that be a better quick fix that the battery?
simple way, use an precision reference voltage for the ADC
LM4040 or similar
I think in this case its the sample and hold circuit of the adc. Since the aref of the Uno is on the 5v supply rail. So it should be proportional to the voltage drop.
I try to put all inductive loads on their own power supply. I use input from a 12v or 9v wall cube. Then split that between two inexpensive buck converters that drop the voltage. One buck converter powers all the inductive loads (motor/solenoid/relay/servo) The second buck converter powers only the microcontroller. The MCU then has it's own power supply with nothing to cause surges. The 12v Vin can usually easily handle varying loads from either buck converter.
This is usually what I do too! It has worked pretty well so far!
Cardboard and tape craft science is what I do best ;)
Ugh i remember when we learned about this in school. There is a whole field about providing clean power to all components (with lowpass filtering, shielding, dividing power correctly,...) there are all sorts of things you can do with hardware to prevent these things. When we measured with our µControler and had (more or less) the same problem to solve only we HAD to use the power provided via the controller (part of the exercise).
Could adding a capacitor to the power supply fix the issue?
more on resistor dividers
There's another common issue I've dealt with in the past which is charge couples input voltage sharing between channels. Especially with high impedence inputs and rapid channel switching (which I used to have back in the old days using assembler. If you're running python it's kind of slow so might not be an issue but otherwise you might need to do some dummy reads or extend your input sample time depending on your hardware and how much into the nuts and bolts you're having to dive to extract the readings. i.e. for Arduino, it's already hiding most of the work of doing an analogue reading behind the calls you make.
Good one.
Can you pls do a video on resistor dividers
very useful thank you
You are measuring an independent absolute voltage source with an A/D. Your input is not ratiometric with the Vref.
To measure absolute A/D voltages, you need to also feed in a stepped down Vref and a precision voltage reference into 2 other A/Ds. Then you can derive what the voltage of Vref is.
A/Ds read a count value relative a full count value representing Vref. It is wrong to assume your A/Ds read absolute voltages.
You need a discussion on ratiometric A/D configurations and one on what’s needed to read absolute voltages on A/Ds.
The easy way out of this problem is to use a weight and pendelum or connect the arduino to a clean power separate from the motor power. Vref ~= 5V and be fairly stable.
Please make a video on the Adafruit TinyUSB library and its implementations in CDC and HID (both host and device) modes. It would be better if you can use something which incorporates an RP2040 controller. Raspberry Pi Pico is cheaper. The codes should perform simple tasks without making things difficult to understand.
Hobbyist-grade sensor often either biased or a bit noisy, need to be calibrated and filtered in Arduino program. This is why industry-grade sensor like Siemens and Omron are bloody expensive because calibration is hard to do and they did the job very well
Great knowledge👌🏽!
I thought you will talk about digital filters instead of caps and beads
Thank you - I realised similar issues some time ago, and since then, all my MCU based sensors have: LDO and bunch of capacitors, to make sure the Vin is as stable as possible. Vref in MCU crap ;-) (because it is probably not referenced to the Vin but Vref, however if Vin is unstable then Vref as well)
EDIT: btw, this issue you are showing is typical: "LAB only problem" because in the real life application you were describing there was... no motor, right? ;)
Why not an stm32 example but thanks
tnx. great.
thanks a lot, it was certainly interesting. 👍 but if had to do it in a more precise and reliable way I wouldn't use an Uno! Instead I'd go for a military/aerospace/life support ADC chip and a bridge to my pc with proper filtering and shielding. 😁
more more embedded
How about using galvanic isolation, though? (instead of using multiple power rails)
I cringe when I hear people are reading voltage levels when using their A/Ds. They need to get out of this fantasy land in assuming Vref = 5V. Ratiometric configurations address much of this. Just think of A/Ds as being a count value relative to Vref and not an absolute voltage reading.
you are my father
No code at all video.
yes it's great
@@vectoralphaSec not my point.