Shop OBEX P1 Docs P2 Docs Learn Events
A/D with TLC2543 still buggy... - Page 2 — Parallax Forums

A/D with TLC2543 still buggy...

2

Comments

  • NewzedNewzed Posts: 2,503
    edited 2006-08-24 11:37
    Kirk, I do not understand why the output of your TLC2543 is so erratic.· I have been using this chip for a long time and·I get·rock steady output values that may vary by one or two digits.· Have you looked at the input to ADC with a scope to see what is there?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-24 17:00
    Kirk, I don't have a specific suggestion for the potentiometer, especially since it needs to have 360 degrees of travel. The Beckman Industrial pots you have should work. I think you said you get steady readings from them on a voltmeter, so it should also be possible to get steady readings with a Stamp system. I was just concerned about the shielding around the potentiometer itself, but somehow I think that is not the issue here. The first thing to do is to get it rock steady on the protoboard. I agree with Sid, it should be possible to get it down to +/- one bit of bobble.

    It is common practice to use a median or mode filter as the first stage in a smoothing procedure. That is like your suggestion number 1 of looking at three readings and throwing out the extreme. That is effective against "pop" noise, where there is occasionally an outlier, like your sequence 2052 1796 2054. The "pop" has to be shorter than the time length of the window, of course. A filter with a window of 5 milliseconds will zap a 1 millisecond outlier, but it will not be effective against long fluctuations. The output of a median or mode filter can then feed into a moving average like Bruce suggested, and/or an exponential lowpass filter. I think I have an example of a median filter on my web site. They are kind of slow to implement on a Stamp, because of the memory access and comparison required, espcially when you go to much more than three samples.

    So the sequence 2052 1796 2054 was after averaging 8 points? It really is important to figure out where that fluctuation is coming from electrically,and also check to be sure there is nothing buggy in the pbasic. The averaging and math are secondary.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • T ChapT Chap Posts: 4,223
    edited 2006-08-24 18:11
    Kirk I was wondering if you were able to put Vdd into the A/D input and get a solid number. If so, what about a resistor divider to check it at around 2.5 volts, thus determining how much your pot is really contributting to the problem.
  • NewzedNewzed Posts: 2,503
    edited 2006-08-24 18:19
    Kirk, I would really like to know what the scoped input to the ADC looks like.· Since you have tried about everything, try putting a 10uf electrolytic in parallel with your .1uf.· As Tracy pointed out, all the math formulae and averging really shouldn't be necessary.· I have never had to use anything other than a "calibration" formula whenever I use LM34s.

    Sid
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-24 19:02
    Bruce,

    Correct me if I'm wrong but to my understanding a moving average is a simple average over moving data -- take the next N points then divide by N. That's what I've been doing but thanks for the tip.

    Sid,

    It's good to hear somebody is getting rock solid results! So it is possible, somehow. Unfortunately my scope is one of the modern cheap digital Tek scopes which has one nice feature "autoset" which samples the signal and gives an initial display to tweak but it doesn't tweak quite as much or have as clean a display as a real CRT based scope. I see some intermittent noise from my 5V supply, a PhoenixContact brand which I expected would be fairly clean as it was industrial sourced instead of hobbiest. I checked another 6V supply from Radio Shack and it has a similarly dirty waveform although the intermittent noise is different. So it is entirely probable based on your clean results that my problem is in my power supply. I do have a better one to try which takes some setting up as it only accepts 220VAC input. I could also try batteries, the most likely to not have noise. Any suggestion for a "good" power supply? Thank you.

    Tracy,

    It's good to read confirmation that the chip can work to +/- LSB. Here's the code that passed through the fluctuation:

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' {$PORT COM1}
    'Test A/D Inputs

    ' A/D pins
    ADclk PIN 11
    ADdati PIN 10
    ADdato PIN 9
    ADcs PIN 8

    'VARIABLES
    a VAR Nib
    ADch VAR Nib
    ADout VAR Word
    avg VAR Word

    DO
    GOSUB Read_Inputs
    PAUSE 1
    LOOP

    Read_Inputs:
    avg = 0
    FOR a = 1 TO 8
    FOR ADch = 9 TO 9
    LOW ADcs ' select chip
    SHIFTOUT ADdati,ADclk,MSBFIRST,[noparse][[/noparse]ADch<<8\12] ' output AD channel #
    SHIFTIN ADdato,ADclk,MSBPRE,[noparse][[/noparse]ADout\12] ' input pot value
    HIGH ADcs ' deselect chip
    NEXT
    avg = avg + ADout
    NEXT
    avg = (avg ** 57630) / 8
    DEBUG "Avg ", DEC avg, CR ' minimal error out
    RETURN

    This code I think is not the problem based on your and Sid's statements that rock solid results are expected. I got the power supply culprit idea after reading both of your posts. I'm a little worried after getting it to work in prototype how it will work in a real world setup, possibly with a battery and alternator. What power supply do you use? I'll hook up batteries and report results. Thanks.

    Kirk
  • NewzedNewzed Posts: 2,503
    edited 2006-08-24 19:12
    Kirk, by all means, try a battery!!
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-24 19:26
    Agreed--try a battery and a 5 volt regulator.

    On the TLC2543, you can interrogate channel ADch=11, and that connects inside the TLC2543 to a voltage at 1/2 the reference, so you should see a count of 2048 or very close to it. If not, there is an extreme level of noise on the power supply & reference.

    Your averaging algorithm looks fine. Instead of
    avg = (avg ** 57630) / 8
    you can simplfy it to
    avg = avg ** 7200

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-25 05:38
    Everybody,

    Voltage is critical.· When the C·batteries were new earlier today I was getting over 6v and channel 11 was rock steady but after I went to buy a 5v regulator and a 10uF electolytic the voltage from the batteries was close to 5v and the regulator output as well as the Stamp 5v output was less than 5v causing problems for the TLC 2543 eventually slowing output and allowing the big bug in the more significant digits back in when it looked gone·earlier.·

    So as I have a hookup to enable connecting an extension cord to my car battery I'll hook it up to the regulator and try to get the voltages right to all points before reevaluating the results.

    Kirk
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-25 08:51
    Ok, before blowing out my 5v regulator on my 12.6v car battery run in by extension cord, the best I got was about 4.6v. Thus I ask again for recommended power supplies. You guys who get rock solid results from the A/D chip, what power supplies do you use to get there, please?

    I need all three -- the Stamp power supply you use, the A/D chip power supply you use, and the chip reference power supply. Otherwise I need a means of turning a Radio Shack 5v regulator into a 5v regulator from a 4.xv regulator. Thank you.

    Kirk
  • NewzedNewzed Posts: 2,503
    edited 2006-08-25 12:09
    Kirk, I use a 9V or 12V wall transformer, which ever happens to be handy.· It goes through a 7805 or LM340 regulator aloing with filtering.· Stamp Vdd, TLC2543 Vdd and Vref+ all to to the same voltage terminal.· Stamp Vss, TLC Vss and Vref- all go to the same ground.· That's all there is to it.

    Sid
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-25 16:07
    Sid,

    Ok, thanks. I burned out my 7805 but I'll go buy another. What kind of filtering do you use? Do you actually get 5v out of your 7805 or is it 4.x? I may have a likely wall transformer or will check out another 12v supply that still works. It's nice to have solid information on what works instead of going only by hope and running into a lot of walls.

    I expect the filtering you use is important as the Radio Shack 6v wall transformer I have shows some far from flat signals on my scope. Fortunately not the ghost transients that would show up on my industrial 5v supply output though.

    Kirk
  • NewzedNewzed Posts: 2,503
    edited 2006-08-25 16:34
    Kirk, I use a .1uf on the input to the VR and a 100uf and a .1uf on the output.· I've never had a problem with that.

    Sid
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-25 16:54
    Kirk, it puzzles me why you were getting 4.6 volts out of a 5 volt regulator with 12 volts input. That indicates either that there was excessive load from the Stamp and surrounding circuit, or that a filter capacitor was missing on the regulator. The BS2px is the most power hungry of all the Stamps, but it is not _that_ power hungry. Is there other equipment running off the 5 volts or possibly a partial short circuit somewhere? Or possibly a weak connection (i.e. resistive) to the voltage regulator? Is it still hooked up directly to those LEDs without current limiting resistors? Why would the circuit drain a set of new C cells (~8 amp hours) in the time it took you to go to the store and back? Is the circuit really drawing >1 amp?!

    Can you look at the power supply output on your 'scope? You indicated in one comment that your 'scope came up with an automatic setting and would not let you adjust that. You also said I think that it was a Tektronix 'scope, and even in the low end 'scopes, Tektronix does not scimp. The controls are probably there on the buttons or menus.

    I use a variety of voltage regulators, but I'm partial to Linear Tech parts, the LT1129, LT1121 and LT1521. For a reference I usually use an LT1790-4.096, which gives a convenient scaling of 1 millivolt per bit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 8/25/2006 6:20:54 PM GMT
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-25 18:06
    Sid,

    Ok, thanks! Sounds simple.

    Tracy,

    I honestly don't know what's wrong as far as load but I misread the diagram or maybe it was misprinted on the back of the Shack bubble pack for the 7805. I assumed the diagram was a top view but based on the output it seemed reversed. Of course some of the advertized features like "internal thermal overload protection" and "internal short-circuit current limit" didn't work very well.

    The battery drain wasn't complete, just down from 6.x to 5v. The LED's have been removed except one from the A/D chip to show data is moving and it is barely lit so it can't be a full load. The only differences now from the previous picture is my plastic pot and fewer LED's.

    My comment on the scope wasn't clear I guess. There is a display of the power supply waveform but it isn't as fully manipulable as I've experienced on a high-end Tek scope (which costs a year's wages from a good job). The one I have was around $1K. I'll post what I have after I get Sid's power circuit re-bought & built to regulate my car battery or a wall transformer. I can also post the old power supply scope shot and I'll try to catch that transient.

    Limited experience with Linear has me leaning in their direction too. I ordered samples of one of their 12 bit A/D's but they haven't arrived yet and only have two channels. When we were working on the D/A I liked Linear's built in ref.

    Kirk
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-25 18:34
    I have a portable digital tekscope ths720 and also an old analog tek7602. They are different beasts, but for most work I prefer the analog 'scope. Like you say, it is easier to manipulate the waveform to find the sweet spot. The analog 'scope can fool you too with spurious results, if the triggering is not set up right, but the digital 'scope adds another layer of confounding and it is slow to work through the menus. The THS720 'scope is unparalleled though for the battery power and complete isolation of the channels, and the digital capture of transients.

    I've seen rat shack packaging with incorrect pinouts, too. If the voltage regulator was reversed, that would explain a lot! There is nothing wrong with the 7805. When you have sufficient voltage and current available at the input, it should work admirably. The more modern chips we have suggested are low dropout parts that work on lower input voltages and are easier on batteries and have better overload protection. One reason I like Linear Tech regulators is that their protection circuits are exceptionally good. That is why the LT1121 that Parallax uses on the BASIC Stamp IC can have Vdd come in from an outside source without current flowing backwards into the regulator.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-26 06:43
    Tracy & Sid,

    Seems like I'm making every error possible. Ok, please tell me what I should expect from a 5v regulator given 12.6v input. Is it 5v? Or, is it anything else? This time my regulator didn't literally smoke but it didn't produce 5v, either way of hookup.

    If I should be seeing 5v, then I obviously need to try one of Tracy's suggested Linear products because the regulators available at RShack aren't working for me. If I should be seeing a little less than the input voltage then the regulator is working.

    I'm bypassing the scope of the industrial power supply until tomorrow.

    Kirk
  • NewzedNewzed Posts: 2,503
    edited 2006-08-26 11:40
    Kirk, I get about 4.96 volts out according to my voltmeter.· Just to make sure, the positive input from your wall transformer goes to the left hand pin, the center pin goes to ground, and the right hand pin is the VR output.· The negative lead of your wall transformer also goes to ground.· If you are not getting about 5VDC out of the regulator, you are doing something wrong.· Don't blame the regulator.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-26 17:12
    Sid,

    Thanks. I assume that means facing up or front where the numbers are printed instead of reverse where the heat sink tab is the most prominent.

    On blame -- the fact the last one literally smoked and my current one didn't with the same voltages means the last one was at fault. That's why even big companies test components before accepting shipments of them. On my current regulator I agree with you and Tracy that my lack of knowledge contributed to user error.

    Kirk
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-26 21:02
    Sid,

    Ok, I tested my latest RShack 7805 using a transformer 12.02v input and the output per your wiring instructions is 8.65v. Just to be certian, wiring it backwards produced 11.38v. Wiring it forward again produced 8.65v again, proving it's not burned out.

    From that I conclude Tracy's Linear suggestions are the way to go. While waiting I could try the RShack LM317T which is supposed to be adjustable but being RShack, who knows if it can produce 5v. Anyway I guess this discussion will be on hold until I get a decent regulator.

    Kirk
  • NewzedNewzed Posts: 2,503
    edited 2006-08-26 21:07
    Kirk, if you will give me your address I will send you an LM340, which is what I use.· My e-mail is Newzed@aol.com

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-27 05:43
    Tracy & Sid,

    Here's·a scope shot of two power supplies.· Channel 1 on top is a Radio Shack 6vdc 1amp wall transformer.· Channel 2 at bottom is·a Phoenix Contact·industrial 5vdc 3amp rack mount power supply.· To make comparison easy, you'll note they are both sampled at the same ratings listed at the bottom of the photo.

    The rack unit looked real smooth in comparison when first hooked up but after I went away and came back it had expanded in the Y dimension as you see.· The scope is a Tek TDS 220.·

    Kirk
    2080 x 1544 - 1M
  • T ChapT Chap Posts: 4,223
    edited 2006-08-27 18:05
    Kirk That looks more like a scope without a ground connected on the leads.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-27 19:00
    Originator99,

    What ground do you mean? All I did was hook the power supply negatives to the scope probe ground 'gator clips and the power supply positives to the probe centers. Should I have a wire going to the telephone company's house ground? Or the PUD house ground?

    Thanks,
    Kirk
  • T ChapT Chap Posts: 4,223
    edited 2006-08-27 19:14
    What I mean is that if I remove the GND clip from the test probes, the result is an image that looks like what you have just shown, and the result would fluctuate as you described. With all the various supplies you have tried and still have fluctuating noise, it may be worth while to investigate your test leads and scope settings, as there is no way that all those supplies are really that bad. Can you test with the scope connected directly to a battery with no load? Do you any other leads to try? Can you test to see if there is a difference between having the test leads GND connected and disconnected? Normally, you'd see a difference in noise levels. If you don't detect a difference that could indicate a GND problem in the test.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-28 04:23
    Originator99,

    You helped me stumble on somthing. I hooked up both sets of batteries, 4 C cells and my car battery giving 6v and 12v. They had an equally awful looking set of waveforms. I tried reversing the channels and that seemed to change things a little. So I changed the menu items from AC Coupling to DC Coupling and it produced virtually straight waveforms at the correct voltage level. So I tried that on one of the wall transformers and it produced equivalent results. Truthfully I don't know what AC Coupling does but there is a big difference.

    Anyway the main problem still appears to be my RShack 5v regulator(s) which I must disrecommend to everybody. I've ordered 2 samples of the first of Linear's regulators in Tracy's list, which ought to arrive next week. But maybe not -- I'll review the industrial power supply again with DC Coupling and maybe I can use it without any external regulator. Nope, I remember even if the 'scope results are better, that power supply added more serious noise to the most significant bits of the A/D in the Stamp debugger. I'll check the waveform but it can't improve the debugger result. So my hopes are that the Linear chip(s) will work better.

    I received 2 Linear 2 channel A/D chips and I'll try them out to see if they will naturally perform better than the TI chip with my available power supplies.

    Kirk
  • T ChapT Chap Posts: 4,223
    edited 2006-08-28 05:48
    Kirk Glad you have gotten over one hurdle.

    There should not be an isue with the RS 7805's. I'd recheck your connections, or test new ones as you may have damaged what you have. A/C coupling is for audio use or other various uses as well where you want to decouple the input via a cap. A/C coupling usually means there is a capacitor in series with the probe, thereby not passing DC. Caps don't pass DC, maybe there are some exceptions I don't know about.

    One thing I can add that may help you: retrace all your steps at a very fundamental level. Without sounding critical by any means, I think you have overlooked some basic stuff that has cost you a lot of time and energy, when a push if a button was the real problem all along. On average, supplies aren't anywhere near as noisy as you have experienced, so in the future, look for other reasons for the condition.

    As far as the A/D, again I'd like to ask you to hook up 5 volts directly to an input of the A/D bypassing the pot and test the result. Then, hook up GND and test that, then try taking 2 10k resistors and making a divider(one 10k to Vdd, one 10K to GND), and read the junction of the two 10k's into an A/D input. The divider should produce around 2.5 volts if they are close to matched. You can read the voltage with your meter to be sure. Test and report all the results above. Then after that proves out, move back to the pot and we can help from there.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-08-29 06:44
    Originator99,

    I found a way over the power supply hurdle using the RShack LM317T Adjustable Voltage Regulator which I adjusted to 5.00v out from around 12v input. Since I had bad experiences with the RS 5v regulators I'll stay with this unless the coming Linear unit proves as good as the adjustable without having to adjust it.

    I still have the problem with occasional bad sequences on the 10K Pot to A/D to Stamp debugger. An example 2174 2175 2160 2173 2174 with 3n averaging.

    Unfortunately the Stamp may have bit the dust due to overvoltage when my sleeve brushed the regulator's pot when setting up for your 2 resistor voltage divider suggestion. I'll check it further tomorrow and order a new one if necessary. Thank God, it's not my BS2p40 which is soldered in place.

    One step forward, one step back.

    Kirk
  • T ChapT Chap Posts: 4,223
    edited 2006-08-29 09:02
    I blow stuff up all the time being careless and rushing. One thing about klling parts is you tend to learn a lot more trying to solve all the screwups you create, so in the end you are better off. Well, thats my rationalization anyway. If you can get some readings from a solid source instead of a pot I think you'd learn something about whats going on.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-01 07:39
    While awaiting the new Stamp, I can continue with some of the discussion. After converting to a quiet battery or regulated power supply A/D at GND returns to the debugger 0 and +5 returns 3600 with the correct formula. Also, channel 11 returns exactly 1800 with the same formula which I expect a proper twin resistor divider would do. So that means the variability that still exists after applying a 1Meg resistor in series between an A/D channel input and the pot which reduced some of it I'm guessing would be in the pot itself. But the pot seems fine when measured with a voltmeter.

    So there is some remaining problem in my circuit which perhaps more noise reducing could help -- perhaps more caps of various sizes or Tracy's program to match noise frequency -- or there is some quality the digital voltmeter has that my circuit doesn't. Before I go taking apart my voltmeter to attempt to track down the secret, are there any other suggestions?

    Thanks,
    Kirk
  • T ChapT Chap Posts: 4,223
    edited 2006-09-01 08:06
    Without rereading the entire thread to see what you are doing, here are my suggestions:

    1. Try a metal pot and shielded wire. Ground the shield as close to the A/D input as possible. Solder the GND to the pot casing
    2. Try some different caps betwen GND and the A/D input, .01, .1, maybe even some larger polarized caps like 1, 10, 100uF etc just to see what effect it has(+ side to the A/D of course). Since you aren't dealing with anything that has any real speed, a large cap isn't going to affect your circuit. But try a large one and a small ceramic in parallel though.
    3. Lose the series resistor and test it. Sometimes a resistor can add noise.
    4. Make sure you can read a straight line on the A/D input signal with your scope (non-ac coupled!)
    5. Look for any rheostats that may be on or halfway on in the building, or any other noise producing devices like motors or triacs. Try turning things off one at a time in the building to see if it affects the noise level. If you can get a solid signal with +5 and GND, then your pot is the problem. If you have a metal enclosure to put the whole project in, try that too, just make sure to ground the enclosure.

    Post Edited (originator99) : 9/1/2006 8:10:12 AM GMT
Sign In or Register to comment.