DAC conversion

Let's have a look at going with a cheap microprocessor to do all the work and see what we come up with. I can source an Arduino for $4 and it should be more than capable of processing sound and controlling a motor and controlling IR diodes. This will be a companion project to televisior #2

Moderators: Andrew Davie, Steve Anderson, Dave Moll

Re: DAC conversion

Postby Klaas Robers » Tue Mar 21, 2017 2:24 am

First about the "kink" in the centre. That is because you haven't taken into account the internal resistance of the output ports of the Arduino. They are rather low, but not zero, so you should have taken all resistors a little bit lower.

But you see that only in the center you see an irregularity. This is because all the current of the bits 0...5 have to be supplied only by the current of bit 6 when you go from 011 1111 to 100 0000. There the influence of the internal resistance is largest. That is the reason.

You can quite simply correct this by placing a high ohmic resistor in parallel to the 1k. I should start with 220k, and look if the correction is large enough. If it is too large, take a higher value, e.g. 330k, if it is not large enough, take a lower value, e.g 100k. The precision of this correction resistor is not at all important, as long as the real 1k is stable.

On the other hand, it is not too bad, as the curve is still always rising. It is worse if there is a fall back in the centre. I am sure that you will NOT see any effect from this DAC as is.
User avatar
Klaas Robers
Frankenstein was my uncle.
 
Posts: 1244
Joined: Wed Jan 24, 2007 8:42 pm
Location: Valkenswaard, the Netherlands

Re: DAC conversion

Postby Klaas Robers » Tue Mar 21, 2017 2:30 am

Then about the 5 volt when you output 111 1111. The result is that there are 7 resistors going from the output point to a voltage of 5 volt. So you measure a voltage of 5 volt. Simple eh?

When you output 111 1110 then only the highest resistor is connected to 0 volt, so the voltage drops a little bit. You have formed a voltage divider.

To do all the 128 calculations to the voltage divider is quite a job, but the resistors do it in real time for you, so don't bother. It works.
User avatar
Klaas Robers
Frankenstein was my uncle.
 
Posts: 1244
Joined: Wed Jan 24, 2007 8:42 pm
Location: Valkenswaard, the Netherlands

Re: DAC conversion

Postby Klaas Robers » Tue Mar 21, 2017 3:03 am

Now the voltage to current conversion for the LED array.

Connect the output point to the base of a transistor, e.g. TIP22 (?). The collector is connected to the bottom of your new 125 mA LED cluster. Connect the emittor not directly to ground, but via a resistor. This resistor reduces the amplification factor of the transistor, and that is what you need.

Roughly spoken:
- the base voltage goes from 0 to 5 volt.
- the emitter voltage goes also from 0 to 5 volt
- for 5 volt at the emitter you want to have 125 mA collector current,
- that is also 125 mA emitter current,
- so the resistor has to be 5 / 0.125 = 40 ohm (39 0hm).

This will work. Don't bother about the base current yet. It is low.

First refinement:
- you will see that the first steps, 000 0000 to about 000 1111, give no light at all.
- that is because the base voltage has to be 0.6 volt higher than the emitter voltage,
- for any collector current.
- So place a resistor from the base to +5 volt.
- This will lift the base voltage for 000 0000 most,
- for all other numbers too, but less.
- Everything here is a linear system,
- so the DAC will go now from 0.6 volt to 5 volt,
- with all equal steps.
- It is even a good idea to use for this resistor a variable resistor (potentiometer) of say 10k.
- This is going to be your black level setting.

Black level setting:
- Output 000 0000,
- adjust the black level setting for just starting light from your LED cluster.

Now you have a working LED driver, although with no gamma correction. See that you have this working first !

You will notice the lack of gamma correction because all pictures look "bleached out". That is only dark areas are well visible, everything that is brighter than dark grey (in the original) looks like white. You can see this as an effect of our eyes. We have to compensate for this. This compensation is called Gamma correction.
User avatar
Klaas Robers
Frankenstein was my uncle.
 
Posts: 1244
Joined: Wed Jan 24, 2007 8:42 pm
Location: Valkenswaard, the Netherlands

Re: DAC conversion

Postby Andrew Davie » Tue Mar 21, 2017 11:56 am

Aside from the 12V input to the LED array and consequent modification of the resistor at the emitter, I think this is what I'm supposed to do...?

driverx1.jpg
driverx1.jpg (170.87 KiB) Viewed 244 times


Edit: OK, where it says 125mA 12V at the base of the LED matrix, that's wrong. The voltage there needs to take account of the drop across the LEDs (3), so it would be about 2V per LED for the RED LEDs I am using at the moment. So the voltage at that point would now be 6V (3 LEDs in series) - and the resistor at the emitter would now be 47 ohms, or thereabouts.

See update below for correct diagram.
User avatar
Andrew Davie
I think I've had a cranial implosion.
 
Posts: 1032
Joined: Wed Jan 24, 2007 4:42 pm
Location: Hobart, Tasmania, Australia

Re: DAC conversion

Postby Andrew Davie » Tue Mar 21, 2017 1:17 pm

Updated.
Update 2: Modified the balancing resistors to 240 ohms. They are calculated on the voltage NOT used by the LEDs to restrict the current. So, R = (InputV - (#LEDs * 2V) ) / maxCurrent.

driver2.jpg
driver2.jpg (155.57 KiB) Viewed 245 times
User avatar
Andrew Davie
I think I've had a cranial implosion.
 
Posts: 1032
Joined: Wed Jan 24, 2007 4:42 pm
Location: Hobart, Tasmania, Australia

Re: DAC conversion

Postby Andrew Davie » Tue Mar 21, 2017 4:02 pm

Klaas Robers wrote:First about the "kink" in the centre. That is because you haven't taken into account the internal resistance of the output ports of the Arduino. They are rather low, but not zero, so you should have taken all resistors a little bit lower.

But you see that only in the center you see an irregularity. This is because all the current of the bits 0...5 have to be supplied only by the current of bit 6 when you go from 011 1111 to 100 0000. There the influence of the internal resistance is largest. That is the reason.

You can quite simply correct this by placing a high ohmic resistor in parallel to the 1k. I should start with 220k, and look if the correction is large enough. If it is too large, take a higher value, e.g. 330k, if it is not large enough, take a lower value, e.g 100k. The precision of this correction resistor is not at all important, as long as the real 1k is stable.

On the other hand, it is not too bad, as the curve is still always rising. It is worse if there is a fall back in the centre. I am sure that you will NOT see any effect from this DAC as is.



I actually understand this! By placing a high-ohm resistor in parallel with the 1K, I slightly reduce the resistance. For example, a 220k will bring the resistance down from 1K to 995 ohms. That in turn slightly increases the voltage only from the bit 5 (not bit 6!) pin (connected to the 1K resistor). It's the "32" value where the resistance is a bit high - that's on pin 5 (counting from 0). All values above 32 will have this reduced resistance contribution from pin 5 and thus slightly higher voltage output. I can easily test this just by redoing the test with a resistor temporarily clipped to the 1K. I also understand it would be quite unlikely to ever notice the difference if I left it as-is.

Thanks for the explanation!
User avatar
Andrew Davie
I think I've had a cranial implosion.
 
Posts: 1032
Joined: Wed Jan 24, 2007 4:42 pm
Location: Hobart, Tasmania, Australia

Re: DAC conversion

Postby Steve Anderson » Tue Mar 21, 2017 9:53 pm

Another way of doing a resistor-based D-A is the R2R 'ladder". This requires only two values of resistance but one must be double the other. In this case I used 3k6 & 1k8 but others might be suitable too, 11k & 22k. It can be extended 'downwards' in theory as far as you wish...

Note that the bottom resistor, R14 is double the value of the other 'vertical' resistors, R9 to R13.

Steve A.
Attachments
Mini-NBTG 2-Model.gif
Mini-NBTG 2-Model.gif (17.46 KiB) Viewed 239 times
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 3425
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand.

Re: DAC conversion

Postby Andrew Davie » Tue Mar 21, 2017 11:59 pm

I built a test matrix (5x3) using some spare LEDs I had hanging around. Kind of a dry run for the LEDs I have on order...

Yellow ones
White ones

They should be here in a few days. So my "dry run" array only lit up 3 of the 5 strips (of 3 LEDs). A bit disappointing as I was trying to be careful but as always little errors seem to magnify and eventually everything I do looks like a hack job. Particularly with my 1920s soldering iron. Seems like it, anyway. So I thought "3 out of 5 ain't bad" and decided to use that as a test array rather than trying to fix it. Anyway, first I wanted to see how those glass beads fared in diffusing the light. Well you know I had them yesterday but couldn't for the life of me find them today. I looked every possible location - pocket of my jeans in the wash, every drawer in the room, every container of electronics. Not to be found - very disappointing. So, I kind of gave up on those - figured I'd thrown them out when I did a desk clean-up last night, and wouldn't you know it, this morning was rubbish day so I couldn't go through the bin to check. Bummer.

So I decided to see if the original LED matrix I blew up the other day had any salvageable parts. And just as I was reaching for that - well, there were the glass beads, sitting in plain sight right on the desk I was using. I mean right smack bang THERE in the middle of the desk. Unmissable. Only I spent an hour looking for them; that's a bit of a worry. So I popped them in the light box I printed today, and they actually do a pretty fantastic job of diffusing the light, but they have an uneven kind of "sparkly" texture so there are minor bright dots here and there. I put some grease paper in front, and it was close to perfect. So I'll give them a go when I build another light box..

Back to the blown up one - well I thought I'd just drive it direct from (say) 20V to see what I could see - and it was working nearly perfectly. One of the 8 strings was non-functional, but the other 7 blinding. So.. well, WTF... why is it not functioning in the televisor but working stand-alone? And I traced the wires and lo and behold the wires in the connector were reversed. Now that's bizarre because I have absolutely no memory of swapping them around - and I can't think of ANY reason I would have done that. The only thing that comes to mind is that the wires to the motor ARE the wrong way around (I have black as "positive" and red as "ground" - but of course they're arbitrary). But to spin the motor the correct direction I have to wire them in "backwards" like that; when I did the motor I took a 50/50 punt on getting it right. I lost. So I can only imagine I must have started to fix the motor wiring, got distracted, and actually changed the LED wiring. Only I have NO memory of that.

As I said the other day - was having a very vague day due to medication and lots of sparks ensued. I guess I did more damage than I thought. Bit of a worry, really, that I buggered up so much.

On the bright side, new drugs, so let's see how these work for me. And my super-bright matrix mostly works. I can use that for my tests.
User avatar
Andrew Davie
I think I've had a cranial implosion.
 
Posts: 1032
Joined: Wed Jan 24, 2007 4:42 pm
Location: Hobart, Tasmania, Australia

Re: DAC conversion

Postby gary » Wed Mar 22, 2017 12:28 pm

Sounds like a typical day to me, things DO tend to hide in plain sight. My "favourite" is when the thing you are looking for "just happens" to be covered up by something with a completely different size and shape but in such away to make the item almost invisible.

Well that's great that you didn't blow up the LED matrix.

BTW, after you did(n't do) that I went back to look what series resistor value you used for the LEDs and how you calculated them but I couldn't find that anywhere - I am probably overlooking it, but in addition to that, Klaas mentions that you had the LEDs in series, whereas all your diagrams show them in parallel (you may have changed the diagram), so I am a little confused.

Just for interests sake what IS the resistor value?

I have (or rather had) my own problems with bench clutter and particularly not being able to find beads as this video shows :oops:


youtu.be/53huVx7yrYI
Perfecting an NBTV system is like trying to slam a revolving door...
User avatar
gary
"Fester! Don't do that to 'Thing'"
 
Posts: 2234
Joined: Sat Jan 27, 2007 11:29 am
Location: Bundanoon, Australia

Re: DAC conversion

Postby Andrew Davie » Thu Mar 23, 2017 1:49 am

gary wrote:BTW, after you did(n't do) that I went back to look what series resistor value you used for the LEDs and how you calculated them but I couldn't find that anywhere - I am probably overlooking it, but in addition to that, Klaas mentions that you had the LEDs in series, whereas all your diagrams show them in parallel (you may have changed the diagram), so I am a little confused.

Just for interests sake what IS the resistor value?


I don't think they're all in parallel...? I draw with many missing, but it's supposed to be 8 strings of LEDs, each string in parallel with the others. Each string consists of 5 LEDs wired in series. The LEDs consume about 2.2V. I just measured the resistors - they are measuring 46.7 but of course that's in-circuit. The colour code is hard to see but looks yellow, brown, black, red which would make them 41 ohms. I have no idea how I got those values now.

If we have (say) 22V input, and 5 LED in series, then I *think* the resistors were just (and only) balancing resistors, and there must have been a current limiting resistor elsewhere...? Trying to remember how to calculate it, but 5x2.2V = 11V drop across the LEDs, leaving 11V and we want 25mA (although I recall allowing 35mA) current maximum, so R = 11/0.025 = 440 ohms. So yeah, that 47 (roughly) resistor on each string of 5 must be a balancing one only...?

I haven't powered it directly off 22V - I go through my LED board, which has a 16 ohm resistor across the emitter. I calculated that value here (the diagram shows 18 ohms, I used a 16). I also assumed a 26V supply, when I'm currently using 22V. So, 200mA with 22V that would make R = -- well I assume it doesn't matter what the input voltage is, because it's the voltage across the transistor that determines R which determines current at the LED matrix, right? I could have any input voltage, provided I still have 3.5V between the base and emitter of the TIP122 transistor then that's what I use to calculate the resistor. Kind of feel like closing my eyes, cringing, and waiting to be corrected here.

So in summary - looks like about 47 ohm resistors "balancing" the 8 strings. Supposedly. External 16 ohm resistor controls the emitter-side current and limits to 3.5/0.016 = 218mA at the LED array. Divide by 8 for the number of strings, that's 27.25mA per string. Input voltage is unimportant, provided there's enough to cover the voltage drop across the strings. Its should, therefore, work at roughly 15V or so.

I suspect that I went "OK, 5 LEDs per string at 2.2V each. That's 11V. At 25mA maximum, the resistor for a string should be 11/0.25 = 44 (and chose 47) and was of course an order of magnitude out because 25mA is actually 0.025 not 0.25. That's my guess. It's moot anyway, if the emitter resistor is limiting the current.

I'm tired, and weary of fighting this thing.
User avatar
Andrew Davie
I think I've had a cranial implosion.
 
Posts: 1032
Joined: Wed Jan 24, 2007 4:42 pm
Location: Hobart, Tasmania, Australia

Re: DAC conversion

Postby gary » Thu Mar 23, 2017 9:18 am

Aaaah all is clear now, sorry to put you through all that, but it's good to be clear in case I, or someone else tells you something based on a wrong assumption.

Klaas was obviously cognisant of all that, but I must have missed it somehow.

That is one heck of a LED matrix Andrew, I had been noticing some flashes coming from the deep south and had thought it was distant lightning...
Perfecting an NBTV system is like trying to slam a revolving door...
User avatar
gary
"Fester! Don't do that to 'Thing'"
 
Posts: 2234
Joined: Sat Jan 27, 2007 11:29 am
Location: Bundanoon, Australia

Re: DAC conversion

Postby Andrew Davie » Fri Mar 24, 2017 1:41 am

gary wrote:That is one heck of a LED matrix Andrew, I had been noticing some flashes coming from the deep south and had thought it was distant lightning...


It's awesome. I had a lot of fun packing 40 LEDs onto a breadboard with optimal efficiency, too. Very tightly packed; alternate LEDs are rotated 45 degrees pinwise so that I could get it all to fit. And yes, you have to be very careful not to look at it, even a sideways glance leaves "sunspots".
User avatar
Andrew Davie
I think I've had a cranial implosion.
 
Posts: 1032
Joined: Wed Jan 24, 2007 4:42 pm
Location: Hobart, Tasmania, Australia

Re: DAC conversion

Postby Klaas Robers » Sun Mar 26, 2017 5:00 am

Andrew, the 47 ohm resistors (Yellow Violet Black) are indeed balancing resistors. If you circuit strings of LEDs in parallel it is unsure that all strings draw an equal current. Therefore you circuit a resistor in series with each serie, a resistor that takes an extra voltage of 1 ... 2 volt at the maximum current of the string,

So for 25 mA for peak white the resistor should be 1 (volt) / 0.025 (ampère) = 40 ohm, or slightly more. 47 ohm is perfect.

This is NOT a current limitting resistor! The total current is limited by the transistor and the resistor from emitter to ground. As the output ports of the Arduino get never higher than 5 volt, the current cannot be larger, unless you make a short circuit by placing a screwdriver in the working circuit. This never happened to me.
User avatar
Klaas Robers
Frankenstein was my uncle.
 
Posts: 1244
Joined: Wed Jan 24, 2007 8:42 pm
Location: Valkenswaard, the Netherlands

Previous

Return to Andrew Davie's Arduino Televisor

Who is online

Users browsing this forum: No registered users and 1 guest