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

A/D with TLC2543 still buggy...

13»

Comments

  • NewzedNewzed Posts: 2,503
    edited 2006-09-01 11:52
    Kirk, if your 2543 is wired up properly, you should get an output of about 4094 with 5VDC applied to the input.· Sounds like your reference voltage is not 5VDC.

    Sid

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

    ·
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-01 17:48
    Originator99,

    Thanks much! I'll work at implementing your suggestions. When I get my new Stamp to use on my prototype board I can certianly try a metal enclosure. The supply of capacitors at the local RShack isn't excellent but I'll try what I can. The shutting down of the house I guess is easy enough but if there's something coming in from the nearby pole transformer I can't stop that except by moving the project to my brother's or someplace.

    Sid,

    The report of 3600 was using a formula to convert to degrees of rotation and tenths. The output I observed without the formula at 5v was exactly 4095 solid. Thanks for the concern.

    Kirk
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-01 20:55
    Sorry, it looks like I misread my voltmeter on my pot. I have two RS models, one recent which has about half a digit more precision than the older one. So it will show 4 digits upto 4K then 3 digits upto 10K and 4 digits slightly beyond.

    The voltmeter in any 4 digit spot will read the last digit with some variability. This exists inside an aluminum "glove" covering the whole test, it occurs with or without the 1M resistor and with or without the 0.1uF caps. It seems like I'll have to live with it, programming my own custom filter(s) to toss bad readings as described in an earlier post in this thread.

    Thanks for all the help to get this far. Tracy for correcting my programming error which was critical, and everyone suggesting more capacitors which seemed to help a little. Unfortunately shielding didn't seem to help. Perhaps living with 3 digits is doable in my applications, or tossing obviously bad figures, or resampling fast enough to not let a decision based on bad data get very far. If I find anything new like better success with the Linear parts, I'll post it.

    Kirk
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-09-02 18:42
    Hi Kirk,

    When I want to get the best possible reading from a voltmeter, I get out a short (6") test lead that is shielded coax, with a ground and signal clips on only 1" extensions. The long individual test leads that come with most RS multimeters are great antennas for pickup of all sorts of stuff.

    I still suspect that you could do something with your circuit layout to improve the situation of fluctuations in the reading. Layout is especially important with the BS2px that you have, because it is running at 50mhz and generates relatively high power spikes on the power supply lines and potentially through electromagnetic coupliing.

    Can you please post another photo of your layout? Maybe we can offer additional helpful criticism. Stress again: layout is everything. The reason the internal channel 11 gives a solid reading is that its layout is impeccable--contained inside the ADC chip. Even with that, it would still be possible to get bad readings if the software was bad or if the power supply or reference to the ADC was _extremely_ noisey. The fact that you are getting good readings there now takes us to the layout of the sensing pots in relation to the rest of the circuit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-05 22:37
    Hi Tracy,

    Ok, here's a picture.· The variable Regulator and supporting circuitry are in one corner.· The 5v Reference chip supplying only the TLC2543 is about 3" away.· The position sense pot is about 2" from that.· The input voltage (17v from a 12v wall transformer) comes in along an edge as a red and black wire.· The replacement BS2px24 and programming lines come in and the Stamp is connected via 4 wires to the TLC2543.

    In the real application the Stamp programming lines will eventually be removed of course.· The sense pots will be at various lengths upto 6 feet away line of sight plus a little more for wire routing.

    What are the important layout considerations?· I learned by experimenting with various suggestions·that having a seperate Reference supply helps improve results over a straight 5V from the regulator and of course the regulated current was much better in results·than straight 5V from a power supply.· Capacitors also help and I've ordered a selection of them to try.·

    There is one flaw in my plan for using a triple value weeding program -- there is enough memory for 3 pots but not 4,·probably·even less·with the variable squeeze due to calculus for acceleration / decelleration.· Would you recommend networking Stamps for this?

    Thanks,
    Kirk
    2080 x 1544 - 1M
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-09-06 01:43
    Hi Kirk,

    What are the binding posts for, three red ones and one black one? There is a red and a black wire coming in at the top of the picture across the 3M logo. Is that the 12volt nominal power input?

    I'll take a closer look at it and take a deep breath and have dinner before I get into the layout question.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-06 02:27
    Hi Tracy,

    The bannana plug binding posts are currently used as voltmeter test points, not power inputs. Normally they were intended to be black = Gnd, Red1 = 5v, Red2 = 12v, Red3 = 24v or some arrangement of that nature. Now that I know Regulation is necessary, I'll revise my useage of those posts when I think of something better. Or I may still use them mostly as above with the 12v being the 12v wall transformer which is really 17+V.

    Kirk
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-06 06:53
    Ok, to make it easier, they mean nothing, please ignore them. If it would help make it more easy, I can take another photo with the wires to the posts removed.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-09-06 16:48
    The binding posts are not a problem. I was just wanting to establish where the power was coming in to the circuit. Sometimes those breadboards have a power supply built in that is hidden under the board and feeds up through the binding posts, but now I know that is not the case here.

    The wiring is very spread out. In particular, the ground for the reference is on a completely different circuit branch from the potentiometer and the ADC, and digital currents from the BS2px and ground currents from the power supply also flow on that branch. The first thing to try is to move the Vss wire for the reference over to the hole next to the green wire that comes out of pin 13 of the TLC2543. Also, look at the ground for the capacitor that filters the output of the ADC. Move that side of the capacitor also over to bridge directly between pin 11 and pin 13 of the TLC2543. Same thing with the capacitor on channel 10--move it to bridge directly between pin 12 and pin 13. If possible, power the top end of the potentiometer and also the fixed voltage divider directly from the reference output, next to pin 14 on the TLC2543. (I forget which reference chip you are using and what its current drive capabilites are.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-06 20:41
    Tracy,

    This is getting expensive -- my replacment BS2px24 is reporting "No Basic Stamps Found" already.·· I again tested my computer connection by plugging it into my BS2p40 which works.· This time I can't recall anything I did that probably caused it, although removing power before changing any other wiring would have been safer.· Any suggestions to recover?

    REF02 from TI says on the data sheet:
    Current Drain················ 1 mA
    Load Current Source···· 21
    Load Current Sink······ -0.5
    Short Circuit Current···· 30
    Power Dissapation········ 15

    The small wiring changes you suggested were done as you can see below·but there is no way to test them until I get another new Stamp.· :-(·· Fortunately Parallax allows half off on non-working out of warranty replacements when the return has an RMA.

    Kirk
    2080 x 1544 - 1M
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-09-07 03:11
    The wiring changes look good, and it sounds like 21ma available source current from the ref02 will be plenty to excite the sensor.

    Too bad about the "not found". When that happens, I first check the power supply right at the chip with the voltmeter, and also the connections to the serial port. On a breadboard like that, it is so easy to bump something and get a short circuit or have a wire pull out. It is probably something like that, and not damage to the Stamp itself.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-07 22:44
    Tracy,

    Thanks much on the "not found" advice -- it prompted me to try untwisting the serial wires one turn and that fixed it! I don't know what went wrong except some short there. Now I'd bet I bought this Stamp and sent in my old Stamp unnecessarily.

    The wiring improvements look better not bridging over the chip but I haven't detected better function but maybe it's there in the 10th's position and I'm not comparing closely to what went on days ago. Currently I'm getting 0-1-2 on the grounded inputs and input 11 sometimes goes over or under by one or two. The pot frequently varies by 1 sometimes 3 with average of 8 values, code below. Variance by a few 10ths looks good but the debug display slowness and glitches look less good. I need the circuit to cycle at 200Hz or better according to a college professor who built a biped. So I will reduce the average and number of inputs to speed it up.

    With the speed up (about half the code commented out) it goes faster but occasionally it has a bad number in the one degree position such as 2053 2048 2053. So I think I'll have to program my filter. I hope the debug delays are simple communication glitches and not sense glitches. The only suggestion left is receiving my order of a variety of capacitors to try as Originator99 advised.

    Thanks,
    Kirk

    ' {$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
    avg0 VAR Word
    avg1 VAR Word
    avg2 VAR Word
    avg3 VAR Word
    avg4 VAR Word
    avg5 VAR Word
    avg6 VAR Word
    avg7 VAR Word
    avg8 VAR Word
    avg9 VAR Word
    avg10 VAR Word

    DO
    GOSUB Read_Inputs
    PAUSE 0
    LOOP

    Read_Inputs:
    avg0 = 0
    avg1 = 0
    avg2 = 0
    avg3 = 0
    avg4 = 0
    avg5 = 0
    avg6 = 0
    avg7 = 0
    avg8 = 0
    avg9 = 0
    avg10 = 0

    FOR a = 1 TO 8
    FOR ADch = 0 TO 10 'Read 11 analog inputs as digital 0 to 4095
    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
    IF NOT (ADch = 0) THEN A1
    avg0 = avg0 + ADout
    GOTO A11
    A1: IF NOT (ADch = 1) THEN A2
    avg1 = avg1 + ADout
    GOTO A11
    A2: IF NOT (ADch = 2) THEN A3
    avg2 = avg2 + ADout
    GOTO A11
    A3: IF NOT (ADch = 3) THEN A4
    avg3 = avg3 + ADout
    GOTO A11
    A4: IF NOT (ADch = 4) THEN A5
    avg4 = avg4 + ADout
    GOTO A11
    A5: IF NOT (ADch = 5) THEN A6
    avg5 = avg5 + ADout
    GOTO A11
    A6: IF NOT (ADch = 6) THEN A7
    avg6 = avg6 + ADout
    GOTO A11
    A7: IF NOT (ADch = 7) THEN A8
    avg7 = avg7 + ADout
    GOTO A11
    A8: IF NOT (ADch = 8) THEN A9
    avg8 = avg8 + ADout
    GOTO A11
    A9: IF NOT (ADch = 9) THEN A10
    avg9 = avg9 + ADout
    GOTO A11
    A10: IF NOT (ADch = 10) THEN A11
    avg10 = avg10 + ADout
    A11:
    NEXT
    NEXT
    avg0 = (avg0 ** 57615) / 8
    avg1 = (avg1 ** 57615) / 8
    avg2 = (avg2 ** 57615) / 8
    avg3 = (avg3 ** 57615) / 8
    avg4 = (avg4 ** 57615) / 8
    avg5 = (avg5 ** 57615) / 8
    avg6 = (avg6 ** 57615) / 8
    avg7 = (avg7 ** 57615) / 8
    avg8 = (avg8 ** 57615) / 8
    avg9 = (avg9 ** 57615) / 8
    avg10 = (avg10 ** 57615) / 8
    DEBUG " Avg0 ", DEC avg0, " Avg1 ", DEC avg1, " Avg2 ", DEC avg2," Avg3 ", DEC avg3," Avg4 ", DEC avg4," Avg5 ", DEC avg5," Avg6 ", DEC avg6," Avg7 ", DEC avg7," Avg8 ", DEC avg8," Avg9 ", DEC avg9, " Avg10 ", DEC avg10, CR
    RETURN
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-08 04:45
    Tracy,

    Here's my attempt at a filter. It seems to work for a run of as many as 52 then it has a bad one slip through. Some runs are far less on the pot and runs don't seem to exist at all on the ground. Any advice?

    Thanks,
    Kirk

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' {$PORT COM1}
    'Triple Filter on 2 inputs of A/D

    ' 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
    avg8a VAR Word
    avg8b VAR Word
    avg8c VAR Word
    avg8o VAR Word
    avg9a VAR Word
    avg9b VAR Word
    avg9c VAR Word
    avg9o VAR Word

    avg8a = 0
    avg9a = 0
    avg8b = 0
    avg9b = 0
    avg8c = 0
    avg9c = 0

    DO
    GOSUB Read_Inputs
    PAUSE 0
    LOOP

    Read_Inputs:
    avg8o = 0
    avg9o = 0

    FOR a = 1 TO 3
    FOR ADch = 8 TO 9 'Read 3 analog inputs as digital 0 to 4095
    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

    A8: IF NOT (ADch = 8) THEN A9
    avg8o = avg8o + ADout
    GOTO A10
    A9: IF NOT (ADch = 9) THEN A10
    avg9o = avg9o + ADout
    A10:
    NEXT
    NEXT
    avg8c = avg8b
    avg9c = avg9b
    avg8b = avg8a
    avg9b = avg9a
    avg8a = (avg8o ** 57615) / 3
    avg9a = (avg9o ** 57615) / 3
    avg8o = (avg8a + avg8b + avg8c) / 3
    avg9o = (avg9a + avg9b + avg9c) / 3

    IF (ABS (avg8o - avg8b) < 4) THEN
    avg8o = avg8b
    ELSEIF (ABS (avg8a - avg8c) < 4) THEN
    avg8o = avg8b
    ELSE
    avg8o = avg8a
    ENDIF

    IF (ABS (avg9o - avg9b) < 4) THEN
    avg9o = avg9b
    ELSEIF (ABS (avg9a - avg9c) < 4) THEN
    avg9o = avg9b
    ELSE
    avg9o = avg9a
    ENDIF


    DEBUG " Avg8 ", DEC avg8o," Avg9 ", DEC avg9o, CR
    RETURN
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-09-08 16:28
    Kirk,
    That kind of programming problem is often best attacked by use of a pointer or an array index, which would eliminate a lot of the redundant code. Something like this:

    ' using indexed variable
    avg VAR Word(11)
    FOR a=1 TO 8
      FOR ADch = 0 TO 10 'Read 11 analog inputs as digital 0 to 4095
        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
        avg(ADch) = avg(ADch) + ADout
      NEXT
    NEXT
    For ADch=0 TO 10
      DEBUG ? (avg(ADch) ** 57615) / 8
    NEXT
    


    or
    ' using pointer and Scratchpad ram for averages
    SPavg CON 20  ' location of start of  averages in scratchpad
    avg VAR Word
    idx VAR Byte  'pointer to SPram buffer
    FOR a = 1 to 8
      FOR ADch = 0 TO 10 'Read 11 analog inputs as digital 0 to 4095
        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
       GET idx*2+SPavg,WORD avg
       avg = avg + ADout
       PUT idx*2+SPavg,WORD avg
     NEXT
    
    
     NEXT
    



    That is a staight average. To do a windowed average, it is necessary to keep several raw samples from each channel in memory, and with each new sample, add it to the accumulation, subtract the oldest sample, and replace the oldest sample with the newest sample. I think that is what you are doing with your second program that samples ADch 8 and 9. It is possible to do that with pointers too. Instead of bubbling the actual data down in the queue, use a pointer that moves in a circle around the buffer, so it always points to the oldest data item, the one that will be subtracted from the accumlation and will be replaced by the newest datum, before the pointer is moved to point to the next oldest value modulo the buffer size.

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

    Post Edited (Tracy Allen) : 9/8/2006 5:19:11 PM GMT
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-08 20:00
    Tracy,

    Thank you. I had not previously noticed that Parallax's Basic was upgraded to offer indexing. I learned the new stuff about "if" statements but the last time I went through all of the commands available was back in about 1994 with the original Stamp and I never needed indexing before.

    My own computer language LogicTalk needs upgrades too but I can't afford it right now. I'll work on applying all these lessons to my Stamp applications and see if I can get one or both out the door. The hard part is dealing with the variability but I hope your, Sid's, Originator99's, and other's advice has gotten it down to at least 0.5 degree most of the time and something, either the speed of sense or a window filter or using triple processing of the same inputs or something will cover bad position decisions.

    I do have some older computer board electronics that can replace this but it's limited to 16 channels whereas Stamps appear to be networkable and I need about 70 channels.

    Kirk
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-11 00:24
    Well my electronics order came in so now I can test a bunch of different capacitors and am setting up to test a Linear LTC1291 A/D also. The hard piece of that is figuring out the serial program commands from their timing diagrams. There is a 4 bit input word mentioned on page 9 but the diagram below it shows 5 bits. On pg. 11 the input of odd/even seems almost double length. So do I input 4 bits, 5 bits, or 6 bits? I'm guessing 5 bits.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-13 00:16
    It would be nice if the forum had some way of going back and making these threads into tutorials -- tossing out the ideas that didn't work or putting them in an alternatives to try if the recommended approach doesn't work...·

    Anyway today I had success on getting my Linear ADC chip, LTC1291 working with the following code:

    Read_Inputs:
    FOR ADch = 0 TO 1  'Read 2 analog inputs as digital 0 to 4095
      LOW ADcs                                          ' select chip
        SHIFTOUT ADdati,ADclk,MSBFIRST,[noparse][[/noparse]3\2,ADch\1,3\2] ' 11#11 channel #
        SHIFTIN ADdato,ADclk,MSBPRE,[noparse][[/noparse]ADout\12]          ' input pot value
      HIGH ADcs                                         ' deselect chip
        DEBUG "Ain #",DEC ADch, "  Dout ",DEC ADout, REP 32\5,CR
    NEXT
    RETURN
    

    Creating the shiftout command from the data sheet was an interesting challenge.·

    The results were no better and the debug seemed to dawdle a bit more with this chip than the·TI chip.· However someone might have use for it·as it has less channels, smaller size, and it's·much cheaper.· It's still a problem to reduce noise to make all 12 bits useable.

    Fortunately the data sheet shares some other hints such as using 1N4148 diodes to limit stray voltages and shows how a ground plane should be used.· Maybe all the hints together will work.

    So, now on to test using multiple capacitors.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2006-09-13 08:06
    The advice in this long thread which works:
    1) Use the correct serout / serin command parameters for the A/D chip at hand per Tracy's website
    http://www.emesystems.com/OL2tlc2543.htm
    2) Use a 5v regulator on 12v power for Stamp.
    3) A variable regulator works best to get 5v but set by voltmeter before powering up the circuit.
    4) Use a 5v reference voltage chip for the A/D and sense pot.
    5) Use a 1M resistor between A/D input and sense pot.
    6) Use a 0.1uF cap between all three pot terminals (some may be unnecessary?)
    7) Use an average of 8 values.
    8) Convert to degrees and ignore 10ths for high stability.
    9) Wire a large metal mass to ground on sense pot.

    Reward: Shooting for 12 bits but only achieving 8.492 bits is still more satisfying than just 8 bits because you get a solid 360 degrees instead of 256. (Remain open to trying more tricks to try for the 10ths digit.)

    Advice which did not work for me but might for someone else:
    1) Use shielded wire for the pot connecting only one end to ground and other end to metal mass.
    2) Seperate ground path for regulator and reference voltage chip.
    3) Multiple capacitors of various values.
    4) Minimize distance between circuit components.

    My big mistakes:
    1) Making a programming change in variables, not checking the rest of the code for consequences.
    2) Buying an industrial 5v power supply instead of using a regulator on a cheap higher volt supply.
    3) Allowing Stamp serial programming wires to get twisted, falsely reporting "no stamp found."
    4) Not trying the long start program menu way to get to Basic Editor Help on Win98SE.
Sign In or Register to comment.