Been there, done that, was quite usefull to make a fast PID line follower with arduino. The prescaler is ok if you set it to about half the value and the big gamechanger is doing the left adjust, so the readout is 8 bits and everything(well, everything except the integral term, which tends to be huge) in the control loop can be processed with bytes(which use only 8 bit-instructions)! I wish this would have been posted a month or 6 ago!
I just watched this again and took some notes. This is a great video, Pete. I think I'm going to try to do something similar with a wheatstone instead of a pot. Keep the vids coming. Maybe make a companion vid to to DAC next?
Thought it was funny to correct an already correct value to a wrong value but we get you. No biggie. Thanks for the good content and please keep it up. I know a lot of the ins and outs of ADCs but still nice to go back once in a while.
If the resolution is 10 bits, you are correct dividing the reference voltage by 1023. The extra number that completes the set of 1024 numbers from it is the 0 value.
1023 is the largest number a 10 bit binary can hold, but Zero is also a value. So it's a total of 1024 possibilities, so he should divide by 1024 just as he did.
Also, AVR pro-tip: if you need to capture an accurate waveform, DO NOT trigger the ADC in software! Loops can take varying amounts of time to execute and your sample rate is unpredictable. I believe you can trigger the ADC off a timer. Use that instead!
Dividing by 1024 is correct. 0-1023 in a micro controller is 1024 steps of resolution. dividing 3.3/5v by 1023 does not give you 1024 steps of resolution. It would give you 1023.
Yes, it should be 1023. Plug some numbers into the formulas and try it yourself. If Vin = Vref, then the ADC register should be at its max value, which is 1023. Off by bites again!
I'm getting tired of this.. Bro you need to go back to school! This is simple math.. Let us do a example: (5000mV - 0.000mV)/(1023 - 0) =~4.888mV/step .. The uC goes between 0 and 1023.. Now take 1024*4.888=5004.89mV and 1023*4.888=5000mV! You don't ever get 1024, why divide by it..??
I love the "Behind the Arduino" take on this. Love to see more of those kind of subjects. Thanx.
Thank you. This old man now understands!
Been there, done that, was quite usefull to make a fast PID line follower with arduino. The prescaler is ok if you set it to about half the value and the big gamechanger is doing the left adjust, so the readout is 8 bits and everything(well, everything except the integral term, which tends to be huge) in the control loop can be processed with bytes(which use only 8 bit-instructions)! I wish this would have been posted a month or 6 ago!
I just watched this again and took some notes. This is a great video, Pete. I think I'm going to try to do something similar with a wheatstone instead of a pot. Keep the vids coming. Maybe make a companion vid to to DAC next?
Great explanation of the ADC. Was always a mystery until today.
Explanation starts at 5m37s
I'm off to find the rest of Pete's videos!
Thought it was funny to correct an already correct value to a wrong value but we get you. No biggie. Thanks for the good content and please keep it up. I know a lot of the ins and outs of ADCs but still nice to go back once in a while.
If the resolution is 10 bits, you are correct dividing the reference voltage by 1023. The extra number that completes the set of 1024 numbers from it is the 0 value.
1023 is the largest number a 10 bit binary can hold, but Zero is also a value. So it's a total of 1024 possibilities, so he should divide by 1024 just as he did.
Also, AVR pro-tip: if you need to capture an accurate waveform, DO NOT trigger the ADC in software! Loops can take varying amounts of time to execute and your sample rate is unpredictable. I believe you can trigger the ADC off a timer. Use that instead!
Dividing by 1024 is correct. 0-1023 in a micro controller is 1024 steps of resolution. dividing 3.3/5v by 1023 does not give you 1024 steps of resolution. It would give you 1023.
so we cannot convert a an analog signal which is greater than Vref. what if I have to convert a signal greater than the reference voltage. pls help
Yes, it should be 1023. Plug some numbers into the formulas and try it yourself. If Vin = Vref, then the ADC register should be at its max value, which is 1023. Off by bites again!
I also think you have to divide by 1023.
1023 divisions separate 1024 values.
But you can't divide by 0!!! :)
NOOOOOOOO......1023 is correct.. change it back!!!!
are you joking?
I'm getting tired of this.. Bro you need to go back to school! This is simple math.. Let us do a example: (5000mV - 0.000mV)/(1023 - 0) =~4.888mV/step .. The uC goes between 0 and 1023.. Now take 1024*4.888=5004.89mV and 1023*4.888=5000mV! You don't ever get 1024, why divide by it..??