Digital to Analogue and Analogue to Digital Conversion - IO from Scratch - Part 3

  Переглядів 7,644

James Sharman

James Sharman

День тому

In this video we build a Digital to analogue converter using an R2R ladder and then use as part of a more advanced Analogue to digital circuit. At the end I do try the converters out on some sound with some mediocre results, It’s not my plan to add wave based sound support to my build as anything other than this quick experiment. The sampling here is at just over 6khz which fills memory very quickly.
0:00 Introduction
0:42 Digital to analogue
4:42 Using the External Trigger
5:33 Analogue to Digital
6:27 LM393 Voltage Comparator
9:58 Binary Search
13:38 Test
14:55 Lets Try Sound
17:17 Outro

КОМЕНТАРІ: 159
@weirdboyjim
@weirdboyjim 11 місяців тому
Join us on Discord: discord.gg/jmf6M3z7XS Follow me on Twitter: twitter.com/WeirdBoyJim Support the channel on Patreon: www.patreon.com/JamesSharman After uploading I always do a final watch though to make sure everything is ok, on this instance I spotted an obvious (in hindsight) code optimization I could have made at roughly 12 minutes in. See if you can spot it!
@PsychogenicTechnologies
@PsychogenicTechnologies 11 місяців тому
I knew the successive approx algorithm but I think this is the first time I actually see it stepstepstep to the answer in real life. Watching the yellow trace converge was really cool--thanks!
@weirdboyjim
@weirdboyjim 11 місяців тому
Glad you liked it. Seeing it on the scope screen reacting to a changing input was really cool despite it being exactly what I expected to see!
@wallyhall
@wallyhall 11 місяців тому
@James - I hope you appreciate the joy you bring to a lot of folk who follow this channel. Look after yourself, we enjoy this series because you’re clearly enjoying making it. If your joy in it ever falters, don’t burn yourself out trying to force it 🙂
@weirdboyjim
@weirdboyjim 11 місяців тому
Those are very kind words! Thanks!
@rauljvila
@rauljvila 10 місяців тому
This reinforces the feeling that this is not a toy, but a fully functional computer. Really impressive! And that visualisation of the binary search on the oscilloscope is VERY satisfying :D. Thanks for the great videos.
@weirdboyjim
@weirdboyjim 8 місяців тому
Thanks! Glad you are watching!
@LaserFur
@LaserFur 11 місяців тому
back when I was in school I made a staged SAR ADC. It used pairs of op amps and a Sample and hold for each bit. The first op amp was the comparitor and the second op amp would amplify the signal by 2 and then offset it by the bit. Then the Sample and hold would stage the signal. The result was slow op amps being able to do audio. The output bits also had to be shifted and delayed so that the results lined up.
@weirdboyjim
@weirdboyjim 11 місяців тому
Nice work! Must have taken up a fair bit of breadboard?
@m1geo
@m1geo 11 місяців тому
Watching the SAR ADC work is bloody awesome! I knew how it worked, I could have written the code, or designed you Verilog to do it. I could have explained it on a whiteboard... ... But playing with it on a scope, that's excellent! I want one! 🙂
@weirdboyjim
@weirdboyjim 11 місяців тому
I know right? I really liked seeing it like that!
@SpinStar1956
@SpinStar1956 11 місяців тому
I come from the old school. One day, I got ahold of a bad A2D module (might have been Burr-Brown or Philbrick?) that failed due to some mistake by one of the engineers. It was very expensive and so I decided to goof with it. Anyway, I started to disassemble it. At first it looked totally potted but I soon found it was just the outer perimeter. When I got it apart, I was stunned to find that it was nothing more than a 555 with precision metal-film resistors and ultra stable capacitors with attendant transistors and diodes. After that I got another idea and constructed a 0-10,000-count counter and a precision integrator along with a precision comparator that would start/stop the counter. I was able to get incredible accuracy and with the only downside being it was single-slope. Fun days for a young buck just starting out! Excellent video, channel and subscribers; good stuff! 73...
@weirdboyjim
@weirdboyjim 11 місяців тому
Interesting! Was your accuracy limited by the counter frequency or noise on the other components? Glad to hear you found it interesting!
@m1geo
@m1geo 11 місяців тому
Yay! Another part in the installation! Something to watch while in the workshop this evening!
@weirdboyjim
@weirdboyjim 11 місяців тому
Hope it doesn't disappoint!
@m1geo
@m1geo 11 місяців тому
​@@weirdboyjim never a disappointment, James! Just what I need after designing modern computer systems all day. 😂
@TonyBrooks1979
@TonyBrooks1979 11 місяців тому
Hunni,, wake up!!, james has put another video up
@weirdboyjim
@weirdboyjim 11 місяців тому
I hope "Hunni" was't too upset with you 😅
@TroySchrapel
@TroySchrapel 11 місяців тому
Love the binary search. Very cool.
@weirdboyjim
@weirdboyjim 11 місяців тому
Thanks Troy! Binary search / Successive approximation techniques should be in everyone mental toolkit!
@ecosta
@ecosta 8 місяців тому
The record at around 17:00 sounds like the kind of recorder we see in some toys. I can't recall which, but it was so nostalgic! I loved it!
@weirdboyjim
@weirdboyjim 8 місяців тому
Glad you liked! I really need to get a decent audio out, that speaker seemed like a great idea at the time as I can put it on camera but the audio quality is terrible.
@KaseKnife95
@KaseKnife95 7 місяців тому
Having now watched all the videos working on this computer its super satisfying watching everything go from a breadboard to being on PCBs, i love the look of the PCBs
@weirdboyjim
@weirdboyjim 6 місяців тому
Thanks! I'm glad you have enjoyed it.
@KaseKnife95
@KaseKnife95 6 місяців тому
cant wait for more videos! @@weirdboyjim
@connorwood95
@connorwood95 11 місяців тому
I wonder how possible it would be to implement the binary search using hardware, and free up the CPU to do other things. This is impressive, as a software engineer turned hobbyist electronics, I'm loving this series and learning a hell of a lot!
@maeanderdev
@maeanderdev 11 місяців тому
SAR ADCs are commonly available. Many simply have an input to start a conversion and approximate synchronous to an spi interface
@NessaNekochan
@NessaNekochan 11 місяців тому
I wouldn't bother too much doing a binary search in hardware. Just using an 8-bit counter as the input to the R2R ladder and latching its value on the transition of the comparator will give you a steady sample rate and your CPU only has to read the latched value and is not busy otherwise.
@weirdboyjim
@weirdboyjim 11 місяців тому
You could definitely do it, I planned a circuit out to do it a while back. Basically a set of latches, a counter and a 3:8 line decoder implementing this algorithm. Would have a taken multiple bread boards though. If you don't need the speed a counter based approach would be a simpler circuit.
@blacklion79
@blacklion79 11 місяців тому
Great work! You need to add a reconstruction filter for DAC, which will be LPF tuned to your «sampling rate», and an antialias filter for ADC :-)
@weirdboyjim
@weirdboyjim 11 місяців тому
Sounds right, but I was trying to keep to the basics here.
@patrickelliott2169
@patrickelliott2169 11 місяців тому
Also.. the minimum usable bit... depth... for digital, even way back when they first used a DAC to convert it to a video pattern, because in the early 70s they had no other useful way to store it, was 14bit. They later improved that to 16bit, and even the eventual CD standard was this same 16bit, 44.1kb/s. You are using a) an 8bit chip, at b)probably nothing close to the needed sample rate. Having seen someone do this with an old Apple II, I would be hugely surprised if it sounded better, regardless of the speaker, or the mic.
@microcolonel
@microcolonel 10 місяців тому
​@@patrickelliott2169with dither you can trade these off alright. With enough sampling frequency, dither will give you any dynamic range you want. Even at the extreme of 1-bit precision, it takes just 2^n samples for n bits of dynamic range.
@ArneChristianRosenfeldt
@ArneChristianRosenfeldt 7 місяців тому
@@microcolonelDelta Sigma and PWM come to mind. With 25 MHz as seen on some of his circuits.
@ArneChristianRosenfeldt
@ArneChristianRosenfeldt 7 місяців тому
@@patrickelliott2169Amiga had 8bit and pcEngine had 5. Also I think there is a video about polyphony in this playlist. 8 bit add is single cycle. So you can mix a lot of square waves with different volumes and still only need a resistor network, but no OpAmp ( other than to terminate the resistor network with a fixed impedance.
@AjinkyaMahajan
@AjinkyaMahajan 11 місяців тому
Impressive James!!! I am fascinated by the Successive Approximation Register ADC demonstration. Cheers!!
@weirdboyjim
@weirdboyjim 11 місяців тому
Glad you liked it! You could easily add a second channel just by using the other comparitor.
@cskilbeck
@cskilbeck 11 місяців тому
Brilliant - the successive approximation code was neat as a button!
@weirdboyjim
@weirdboyjim 11 місяців тому
Thanks Charlie! not sure if I should revisit it in an extras video, I can see several easy improvements now.
@m1geo
@m1geo 11 місяців тому
@@weirdboyjim Yes, please please do! 😁
@alexloktionoff6833
@alexloktionoff6833 11 місяців тому
Most modern AD are Sigma-Delta based, high frequency but one bit /*almost*/ is more precise and efficient nowdays. R-2R is retro :)
@weirdboyjim
@weirdboyjim 11 місяців тому
Eventually I want to explore a range of techniques, 1-bit would need more circuitry, wouldn't like to drive that manually on a home made 8-bit.
@absalomdraconis
@absalomdraconis 10 місяців тому
​@@weirdboyjim : You'd probably want to use an eprom, with either a clock-controlled adder chip for the address bits (sorta slow, checks every combination), or with extra data bits to indicate the next higher/lower address to check (lets you check bits individually, but more complex).
@ArneChristianRosenfeldt
@ArneChristianRosenfeldt 7 місяців тому
I’d like to see a circuit using discrete capacitors. A big one to hold and a small one to add or subtract a quantum. I don’t like OpAmps. I would like to float an amplifier on the capacitor. Isolation transformer running at 48 kHz or floating elco supply power. Sending a charge package using MOSFETs. So actually two storage capacitors. One to each rail. Zener diode to measure the package on the float.
@EdwinSteiner
@EdwinSteiner 11 місяців тому
Besides the cool ADC functionality, this also nicely demonstrates what a powerful and flexible tool even such a basic CPU is.
@weirdboyjim
@weirdboyjim 11 місяців тому
Absolutely! One of the points of this sub series is to show how much can be achieved with some very simple io lines and a bit of software.
@Spongman
@Spongman 11 місяців тому
very cool. i have fond memories of an 8-bit successive-approximation ADC I built from discrete logic on breadboard for my AS-level project many moons ago...
@weirdboyjim
@weirdboyjim 11 місяців тому
Nice! I've planned out a circuit to do that but it didn't feel right to build it in this video.
@BillySugger1965
@BillySugger1965 11 місяців тому
Excellent! It even says “one, two, _free”_ so we know it’s you 😂
@weirdboyjim
@weirdboyjim 11 місяців тому
Thanks for making me even more self conscious!
@BillySugger1965
@BillySugger1965 10 місяців тому
@@weirdboyjim Oh James I’m so sorry, I really didn’t mean it critically. It was supposed to be a friendly leg pull. I can’t pronounce my Rs properly and that’s a speech impediment I’m self conscious about. It never occurred to me that your pronunciation might be a bug rather than a feature. I _assumed_ that it was one of these speech patterns we fall into with our friends as kids, and continue through choice, not something that was a problem for you. That assumption made an ass of me, not you. I honestly meant no offence and sincerely apologise for any hurt or embarrassment I inadvertently caused you.
@trevorhaddox6884
@trevorhaddox6884 8 місяців тому
"Greetings Professor Falken." Or better yet..."So this one time mate I had an 8-bit nugget..."
@weirdboyjim
@weirdboyjim 7 місяців тому
Would you like to play a game? 😜
@itsJden_
@itsJden_ 8 місяців тому
Hello there Sir Thank you soo MUCH for MAKING THESE videos.... Honestly as an embedded systems beginner your videos are helping me a ton and again... I really do appreciate your work and please I hope you will continue makin videos
@weirdboyjim
@weirdboyjim 8 місяців тому
You are most welcome. I have plenty more videos in me!
@AJMansfield1
@AJMansfield1 11 місяців тому
One potential approach to the voltage offset issue, would be to use a separate analog power domain where one can just redefine the high and low voltage references to suit the input (e.g. low = -2.5V, high = 2.5V), and buffer the GPIO outputs to those levels with push-pull optocouplers (e.g. TLP2270, or HCPL-2232 if you don't want to use an adapter board). One would also get complete electrical isolation with that approach, rejecting all of the digital-domain noise by default. And one could even generate those high/low references _from the same reference as the sensor_ (mic phantom power, potentiometer divider voltages, etc.), so any induced ripple on the sensor voltage caused by the supply would be cancelled out. I'd expect it would be possible to get a noise figure better than 16 bits even on a breadboard, this way.
@AJMansfield1
@AJMansfield1 11 місяців тому
This "cancel out induced ripple" is the reason that microcontrollers with ADCs always expose an "analog reference voltage" pin, btw. All ADCs just read in a value as a fraction of the reference voltage, `y = Vin / Vref`. And funny enough, there's a huge range of sensors that basically output a fraction of their input voltage that corresponds to the measured quantity, `Vsensor = Vsupply * x`. So, if if you can directly tie `Vref = Vsupply`, then when you connect the sensor voltage `Vin = Vsensor`, it all cancels out: `y = Vsensor / Vref = Vsupply * x / Vsupply = x`. And it still cancels out, even if `Vsupply` is some wildly unstable voltage with unfiltered switching noise and microphonic capacitors and a temperature coefficient that would make a thermistor blush.
@maeanderdev
@maeanderdev 11 місяців тому
@@AJMansfield1 ripple is canceled only when the measured quantity is truly a fraction of the ADC's reference voltage. When the reference voltage changes the voltage steps between the quantized ADC codes change as well. Whenever the reference voltage is reduced, the microphone sensitivity reduces and vive versa. Due to capacitances even a voltage divider output voltage will lag behind the reference voltage and thus cancellation is practically not perfect. @James Sharman could however simply connect his R2R network to the supply over a small resistor like 10 - 100 Ohms together with a capacitor in parallel to the R2R. That way a low pass network is formed and supply ripple gets reduced. Due to the parallel resistance to the capacitor the common RC cutoff frequency formula does not apply, but it gets close when the series resistor is much much smaller than the parallel resistor (R2R network in this case)
@AJMansfield1
@AJMansfield1 11 місяців тому
@@maeanderdev True, definitely an aspect to consider. But also, the capacitance on the input line acts essentially opposite to any capacitance present on the reference line, so if you're careful about circuit topology you really can get away with a lot. (And by "careful", I mean a full paranoia three-way differential pair between the analog signal, analog reference, and analog ground, all three routed all the way out to the sensor and only connected in with the supply voltage via the other traces that connect to the sensor's pads.)
@weirdboyjim
@weirdboyjim 11 місяців тому
If everything was totally isolated from one another I could have just used the center of the voltage divider for the common audio input. Unfortunately isolating everything is pretty tough.
@Otakutaru
@Otakutaru 11 місяців тому
I've been expecting you for a while now
@weirdboyjim
@weirdboyjim 11 місяців тому
Hope it didn't disappoint!
@Otakutaru
@Otakutaru 11 місяців тому
@@weirdboyjim Of course it didn't. I'm glad you used the binary approximation approach, it's such a great mix of theory concepts and visual proof. Also as you said, it's widely used in ADCs integrated in micros
@TheGunnarRoxen
@TheGunnarRoxen 11 місяців тому
"it proves I shouldn't be an audio engineer." 😂 Nonetheless, that was fun!
@weirdboyjim
@weirdboyjim 11 місяців тому
I've did some experiments after of connecting sound up directly to/from my pc which work a bit better.
@ffsireallydontcare
@ffsireallydontcare 11 місяців тому
I never knew this was the method used by most ADCs given the inherant distortion caused by the temporal delay in the search process, interesting. It would be fascinating to hear a comparision between this ADC and one that uses 8 comparitors, using the resistor ladder to create the fixed comparision levels for each bit's comparitor. You'd achieve a time coherent sample point and a higher sampling frequency, but of course your amplitude resolution will drop from 8 bits to 3.
@maeanderdev
@maeanderdev 11 місяців тому
An ADC with 8 levels only achieves 3 bits of resolution! It takes 2^nBits comparators for that technique. The biggest that I have seen was an old harris semiconductor chip with 6 bit resolution using 64 comparators
@ffsireallydontcare
@ffsireallydontcare 11 місяців тому
@@maeanderdev You did read that I said that the amplitude resolution will be 3 bits?
@maeanderdev
@maeanderdev 11 місяців тому
@@ffsireallydontcare obviously not. I've got no idea how I missed that
@weirdboyjim
@weirdboyjim 11 місяців тому
Yeah, I've seen that technique used. I could see a hybrid approach gathering a few bits each loop of successive approximation being very flexible.
@ffsireallydontcare
@ffsireallydontcare 11 місяців тому
@@maeanderdev No worries! ;-)
@RealEngineer
@RealEngineer 11 місяців тому
Loved the video as usual!🎉
@weirdboyjim
@weirdboyjim 11 місяців тому
Thanks! Glad you are still enjoying this stuff!
@rinner2801
@rinner2801 11 місяців тому
Great explanation as usual, thanks!
@weirdboyjim
@weirdboyjim 11 місяців тому
Glad you liked it!
@FrankGevaerts
@FrankGevaerts 11 місяців тому
This was very interesting! I never really thought about how ADC is done, it all makes sense in hindsignt but I'm not sure I had expected this sort of mechanism beforehand :)
@weirdboyjim
@weirdboyjim 11 місяців тому
Glad you found it interesting. Even just in the comments here you can get an idea that there is a wide variety of techniques to do this!
@dav1dbone
@dav1dbone 11 місяців тому
I remember audio sampling on the Ensoniq Mirage, working with MASOS, reading the phonebook sized manual, interesting to learn that it is not just as simple as A/D, storing the value, playing this back into the D/A and expecting it to be a sound representing the original, there's filtering and also antialiasing. Quite tedious constantly pushing buttons and reading the 2 digit lcd, still, some really nice sounds could be created.
@weirdboyjim
@weirdboyjim 11 місяців тому
Indeed. This was just a basic demonstration of the tools. To really dig into sound reproduction you would need to start discussing Nyquist-Shannon as well as analogue circuit tricks that I'd rather stay clear of.
@andrewwatts1997
@andrewwatts1997 11 місяців тому
That is wonderfull. So little extra hardware but a huge impact ! Talking about the memmory part at the end. Would it be possible to impliment some kind of compression/decompression algorithm? Something like, Record the amount of identical bytes and where they where, store the one byte and some locations to be used at decompression. Can't wait for the next vid !
@weirdboyjim
@weirdboyjim 11 місяців тому
Thanks Andrew. Obviously there are lots of good ways to do audio compression but it really needs to be more complex than that. You'll find identical samples to be rare, most techniques involve transforming into the frequency domain.
@MarkOfBitcoin
@MarkOfBitcoin 11 місяців тому
Brilliant!
@weirdboyjim
@weirdboyjim 11 місяців тому
Thanks! Glad you are enjoying it!
@khatharrmalkavian3306
@khatharrmalkavian3306 9 місяців тому
Hope you're doing well, brother.
@weirdboyjim
@weirdboyjim 8 місяців тому
I'm good thanks. I know it's been a gap between videos but there have been things going on beind the scenes. Should build up a bit more pace over the next few months. They keen to get the more system finished by the end of the year.
@KerboOnYT
@KerboOnYT 4 місяці тому
Wow, thats really cool
@weirdboyjim
@weirdboyjim 4 місяці тому
Glad you found it interesting!
@RooMan93
@RooMan93 11 місяців тому
heck yeah, here we go boys
@weirdboyjim
@weirdboyjim 11 місяців тому
Hope it didn't disappoint!
@jaguarsrevenge
@jaguarsrevenge 11 місяців тому
So cool!
@weirdboyjim
@weirdboyjim 11 місяців тому
Glad you think so!
@jaguarsrevenge
@jaguarsrevenge 11 місяців тому
Thanks!
@weirdboyjim
@weirdboyjim 11 місяців тому
Very generous thanks, glad you enjoyed it!
@andymouse
@andymouse 11 місяців тому
Awesome !....cheers RIP Calculon
@weirdboyjim
@weirdboyjim 11 місяців тому
Thanks Andymouse!
@graealex
@graealex 11 місяців тому
Moving AC to DC is perfectly fine with an OP amp, but it's also possible with a capacitor and a voltage divider. Although that also forms an RC filter network, basically a high-pass. Which isn't going to be a problem for low-quality audio purposes. In the same manner, you can transform a DC signal into AC without having to provide negative voltages to an OP amp. Just put a capacitor between the DC and AC side, typically 100uF electrolytic for audio at line level and high-impedance sinks.
@maeanderdev
@maeanderdev 11 місяців тому
high pass networks were also fine for high quality audio purposes. As long as the cutoff frequency is somewhat far away from the audio frequency range, like much below 20 Hertz, the entire audio frequency range will be practically unaffected
@graealex
@graealex 11 місяців тому
@@maeanderdev Well, the problem starts when the sink impedance is variable. Often seen with (cheaper) sound cards, as the filter characteristic will change depending on which head phones you connect. Also, just RC is a first order filter, so it will have a very flat curve, meaning it's unlikely to not affect low frequencies unless you use unreasonably large Cs. Anyway, for this demonstration, it would have been more than fine. It might even have better high-frequency response than a cheap OP amp, although again not really relevant for audio and a simple voltage follower, where even a cheapo LM358 with 0.7 MHz GBW would be fine. But let's say you wanted to offset a 10 MHz AC signal, using a rather good OP amp with 10 MHz GBW is barely going to make it without reducing the signal amplitude.
@maeanderdev
@maeanderdev 11 місяців тому
@@graealex Opamp gain actually is tremendously important for audio. Distortion induces small errors. Correcting them through the feedback loop needs a lot of gain to achieve really low distortion. High performance opamps often have 50+ MHz of GBP for that reason
@maeanderdev
@maeanderdev 11 місяців тому
@@graealex first order indeed becomes impractical when a small resistor needs to be chosen in favour of a reduced impedance dependence. I had only ever done that with large resistors and insignificant impedance variability. In my case first order was fine. Some modern DACs like the pcm5102 simply include a charge pump and allow filterless operation. Not sure whether filterless is also viable with audio ADCs, since any offset in a recording will introduce a pop sound at playback, which would require a digital filter
@weirdboyjim
@weirdboyjim 11 місяців тому
Using the op amp in the way I did produced a different offset from different audio sources. I attributed this to different output impedance, at a guess I would need to buffer the signal though another op-amp first but I'd need a split rail to do that.
@Schwuuuuup
@Schwuuuuup 11 місяців тому
Absolut amazing as always. But even after watching the addendum I did not get how it was timed in the first place. I guess playback is faster, so the delay loop slows it down, but recoding is done as fast as possible?
@weirdboyjim
@weirdboyjim 11 місяців тому
Oh no, both record and playback are slowed down. I worked out I can get the sample rate (which is much slower than playback) up towards 50khz but that would obviously fill memory far too quickly. The reason for the variability of timing is simply that AD requires the 8 step loop and the DA is a single cycle out instruction. I could have cycle counted the AD loop but I just guessed numbers a couple of times until it sounded right. The loops were about 6khz, looking back I could have got a bit higher.
@m1geo
@m1geo 11 місяців тому
At 18:21 I was fully expecting to hear Rick Astley! 😁
@weirdboyjim
@weirdboyjim 11 місяців тому
I actually recorded a rickroll but you I dare not!
@m1geo
@m1geo 11 місяців тому
@@weirdboyjim I was sooo ready for it! 😂 And then... It wasn't! 😁
@damouze
@damouze 11 місяців тому
Another amazing video. I am afraid I am having a bit of difficulty keeping up. The fault is entirely mine though. My attention has a way of wandering about. In addition to my dayjob, I have been working on a little project of my own, that's keeping me busy as well. But keep it up. The A/D and D/A circuitry intrigues me. Do you need that offset for the output stage as well, and if so, how did you achieve it?
@cj09beira
@cj09beira 11 місяців тому
In this case he shouldn't need it because he is just outputing exactly what he read, but in case you want to add/ remove a offset to a audio signal, its usually done with a capacitor in series with the output which will only let the AC through, then if you need to add an offset to it simply connect a voltage divider to the capacitor output pin.
@damouze
@damouze 11 місяців тому
@@cj09beira Ok. Would you need it if you want to output a line out signal?
@weirdboyjim
@weirdboyjim 11 місяців тому
I'm outputting 0v-5v which works for that speaker. A simple DC blocking cap would make that +-2.5v to be line out compatible but it wasn't necessary for what I was doing here.
@Scrogan
@Scrogan 11 місяців тому
Really cool stuff. Still missing the anti-aliasing and anti-imaging filters. Make sure you stock up on RRIO op-amps and comparators for this kind of digital stuff. Next time make your own delta-sigma modulator!
@weirdboyjim
@weirdboyjim 11 місяців тому
Whoa there! Just trying to skip though a few concepts lightly. Glad you like what I've done though.
@JenslilCorner
@JenslilCorner 9 місяців тому
very cool you could do a circuit that takes an 8 bit value and does DPCM 8:1 compression and less CPU intensive an 8 bit shift register and a simple up down counter is all thats needed.
@weirdboyjim
@weirdboyjim 8 місяців тому
Yes, always possible to simplify with a few additional parts. I've done plenty of that in other side projects but here I wanted to go very simple.
@JenslilCorner
@JenslilCorner 8 місяців тому
Totally understand that@@weirdboyjim
@antadefector
@antadefector 11 місяців тому
Respected, i'm not an expert but, I think LM393 (and op amp cousin LM358) can go from negative (or zero) rail, but not up to positive rail. You would need somewhat bigger supply voltage to a comparator to be able to hugh the 5V input You are feeding in. This can be avoided by one more MSB bit in D/A section set to zero so the output does not go over 2.5V. In retrospect, some op amp buffering, and surely some sample and hold circuitry would increase the quality so much. Sorry for my bad English, Best Regards
@weirdboyjim
@weirdboyjim 11 місяців тому
We could restrict the ranges just by adding voltage dividers to both the inputs. Understand I was trying to get the basic principle across, keeping the circuit as simple as possible is far more interesting to me as first demonstration of the principle.
@antadefector
@antadefector 10 місяців тому
@@weirdboyjim Of course, thats why we watch your videos with full heart. Thank You and Best Regards
@-lolus-
@-lolus- 11 місяців тому
i was almoast hoping to get rick rolled at the end
@weirdboyjim
@weirdboyjim 11 місяців тому
Lol! I actually recorded one but copyright being what it is I dare not include it.
@brettb.345
@brettb.345 11 місяців тому
Pretty cool. Could you tell me the part number for the resistor ladder array you’re using? I’m tired of building them from individual resistors. Thanks.
@weirdboyjim
@weirdboyjim 11 місяців тому
The exact part I'm using here is "4310R-R2R-103LF" but they come with different values and configurations.
@brettb.345
@brettb.345 11 місяців тому
Thanks! I just need a starting point, because there were way too many options.
@tiemenfiat1321
@tiemenfiat1321 11 місяців тому
In an optimized loop, what would be the sample rate in 8-bit resolution on your machine?
@weirdboyjim
@weirdboyjim 11 місяців тому
I think I can tune the sample down to maybe ~60 cycles which would make it capable of 66khz
@LeeSmith-cf1vo
@LeeSmith-cf1vo 11 місяців тому
So the samples are 8 bit mono, right? Do you have an idea of what the approximate samplerate is?
@weirdboyjim
@weirdboyjim 11 місяців тому
That's right, the sample rate was about 6 khz
@TheTkiller9999
@TheTkiller9999 11 місяців тому
@James, I have not tried this, but can you 1. split the d/a to several d/a's with a bias voltage... and that way the d/a counts can run at the same time and then add the outputs with the bias voltage and out put that.
@weirdboyjim
@weirdboyjim 11 місяців тому
It's difficult to parallelism like that since each bit needs the higher bits to be correct for the comparitor to work. There are techniques that can do multiple bits at once though.
@akkudakkupl
@akkudakkupl 11 місяців тому
The whole ADC state machine could be done in hardware to offload CPU to do it's own stuff. I did hope you would use the SAR method and you did :-) I do hope that one day this CPU will get interrupts to be able to do concurrent tasks ;-)
@weirdboyjim
@weirdboyjim 11 місяців тому
Of course, but building the ultra simple circuit like this was deliberate. Once you have build a cpu you can make a choice about these things, building the circuit to do handle it all would involve spending much more time on the kind of stuff I've already done and very little time on the AD/DA bit.
@richardkelsch3640
@richardkelsch3640 11 місяців тому
Put a 0.01 microfarad cap on the output (signal to ground) to smooth out the jagged edges on the output. I highly suggest also using a latch on the output to prevent the gaps between samples.
@weirdboyjim
@weirdboyjim 11 місяців тому
Probably need to buffer the output through an op-amp as well but understand I was trying to demonstrate the basic principles in as simple a way as possible. The digital outputs are already latched before the ladder, or are you talking about an analogue latch?
@richardkelsch3640
@richardkelsch3640 11 місяців тому
@@weirdboyjim I must have missed the latch. Looking at the scope output you had, it didn't look latched, but like I said, I may have missed something. That would be my fault. Back to D/A converters. Nearly all have some sort of smoothing on the output via a low pass filter. Just keeping the curve above the desired high frequency output threshold is the trick. Yes, an op-amp would help with the strength of the signal. If you are using it to actually amplify and not just buffer, then you can use a capacitor in its negative feedback to give it a low pass response. The capacitor or low pass filter acts as an analog anti-aliasing of the output signal, turning the stair stepped output from the ladder to a nice smooth curve.
@hola3535
@hola3535 8 місяців тому
Waiting news.
@weirdboyjim
@weirdboyjim 8 місяців тому
Soon, I've just finished a video but have many more with partial progress on, should be able to get back to regular (ish) publishing.
@hola3535
@hola3535 8 місяців тому
@@weirdboyjim thanks for the answer and by the way, how dificult will be to implement resolution 720x480 AND apart from this, will be posible to make it compatible and executable with the NES socket.
@garthberry
@garthberry 11 місяців тому
The 2² tier seems to be missing from Patreon, making up the difference here!
@weirdboyjim
@weirdboyjim 11 місяців тому
Very generous Garth! I appreciate it! I set those tiers up very arbitrarily, wouldn't take look at add one if there was call for it.
@maesse
@maesse 8 місяців тому
New video soon? :)
@weirdboyjim
@weirdboyjim 8 місяців тому
Soon.
@MobiusHorizons
@MobiusHorizons 11 місяців тому
What sample rate did you achieve?
@weirdboyjim
@weirdboyjim 11 місяців тому
I was recording at 6khz but that was with a big delay loop. I can go much faster but that just fills memory even quicker.
@MobiusHorizons
@MobiusHorizons 11 місяців тому
@@weirdboyjim Very cool! I should have probably asked what the time taken for a single sample was, since it totally makes sense you would delay the sample rate keep memory usage reasonable. I was curious how expensive making a measurement would be especially with increased resolution (10-12bit seems achievable and useful)
@RooMan93
@RooMan93 11 місяців тому
the best way to test how it sounds is say "Double Dribble"
@weirdboyjim
@weirdboyjim 11 місяців тому
Say that too many times and it might become a description of whats the speaker is doing!
@jamesrivettcarnac
@jamesrivettcarnac 3 місяці тому
That audio say the end was poor gold
@weirdboyjim
@weirdboyjim 3 місяці тому
I'm going to assume you didn't mean "poor" and say thank you.
@DAVIDGREGORYKERR
@DAVIDGREGORYKERR 10 місяців тому
What about a Philips Bitstream DAC.
@weirdboyjim
@weirdboyjim 10 місяців тому
Exploring the basics here David.
@naikrovek
@naikrovek 11 місяців тому
If I didn't have ADHD I'd be doing this same stuff. fascinating.
@weirdboyjim
@weirdboyjim 11 місяців тому
Glad you are enjoying!
@DAVIDGREGORYKERR
@DAVIDGREGORYKERR 10 місяців тому
Can we not do... fldt x fcos fstpt y fldt x fsin fstpt y
@weirdboyjim
@weirdboyjim 10 місяців тому
This comment feels entirely unrelated to the video?
@DAVIDGREGORYKERR
@DAVIDGREGORYKERR 10 місяців тому
@@weirdboyjim using fcos and fsin for real time cosign and sine wave generation int __main(int argc,char argv[],char envir[]) int __ITER,__TWO=2,__TEN=10000,__DIVSOR=44150; long double __THETA,__COS,__SIN; __asm__ __volatile__( "fldpi \t" "fimull %0 \t" "fimull %1 \t" "fidivl %2 \t" "fstpt %3 \t" :"=m"(__TWO),"=m"(__TEN),"=m"(__DIVSOR),"=m"(__THETA) : "m"(__TWO), "m"(__TEN), "m"(__DIVSOR), "m"(__THETA) :"st","st(1)" ); for(__ITER=0;__ITER
@gawkersdeathrattle1759
@gawkersdeathrattle1759 11 місяців тому
7 minutes in, looks like you're gearing up to do a 1 bit ADC...
@weirdboyjim
@weirdboyjim 11 місяців тому
I could have done! You really want a faster loop to get good results out of 1 bit though.
SPI (Bit Banging)- IO from Scratch - Part 4
30:04
James Sharman
Переглядів 9 тис.
Deep Ocean Transport from seaQuest DSV
1:13:22
sprueVerse
Переглядів 113
Машины в 2018 и в 2024
00:15
Gazan
Переглядів 2 млн
Designing a simple analog kick drum from scratch
39:11
Moritz Klein
Переглядів 582 тис.
Hardware SPI - IO from Scratch - Part 6
26:14
James Sharman
Переглядів 6 тис.
Introduction to CPU Pipelining
10:29
Merlin Wellington
Переглядів 32 тис.
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Переглядів 188 тис.
GPIO over SPI over GPIO - IO from Scratch - Part 5
25:48
James Sharman
Переглядів 6 тис.
Tile Data - VGA from Scratch - Part 13
1:00:34
James Sharman
Переглядів 15 тис.
8-Bit Adder built from 152 Transistors
12:25
Hyperspace Pirate
Переглядів 579 тис.
#1201 LM311 Crystal Oscillator
12:28
IMSAI Guy
Переглядів 10 тис.
Apple Event - May 7
38:22
Apple
Переглядів 6 млн
Vortex Cannon vs Drone
20:44
Mark Rober
Переглядів 13 млн
Creepy Samsung Alarm cannot be turned off 😱🤣 #shorts
0:14
Adani Family
Переглядів 1 млн
Broken Flex Repair #technology #mobilerepair
0:50
ideal institute aligarh
Переглядів 1,5 млн