Shop OBEX P1 Docs P2 Docs Learn Events
Timing Shiftout on BS2PX for D/A via TLV5618A — Parallax Forums

Timing Shiftout on BS2PX for D/A via TLV5618A

Kirk FraserKirk Fraser Posts: 364
edited 2005-11-22 21:47 in BASIC Stamp
I need advice on how to make sure my BS2PX and D/A chip are communicating.

I have the Stamp working as far as debug statements say but the docs say it is communicating at 3.6 us / 11.8 us where the chip docs say 5 ns / 25 ns minimum.· I would think that working many times slower wouldn't hurt.· But the chip output voltage levels aren't acting smoothly·going up·scale with my software increment.

Should I try some other data output command to properly communicate with the TI 3-wire bus?

I can supply the software and diagram if needed but it's really simple, the stamp has 3 wires going to the D/A chip which has two wires going to power transistors such as the·IRL 520 or TIP 24.

The current D/A is only a 2 channel which provides proportional control on the two coils of a valve.· All advice appreciated!

·
«1

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-15 02:07
    Kirk,

    ·· I'm not sure where you're getting these two values...But if the docs say 5uS minimum and you're communicating at 3.6uS that is faster than the minimum.· Again, I am unclear on your specs.· What is 3.6uS?· Measured speed?· Or some other docs?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-09-15 07:52
    Chris,

    The BS2PX 12 page document in table·22 on page 11·lists 4 figures between 3.6us and 11.8us for unknown timing values related to the SHIFTOUT command.

    The Texas Instruments TLV5618A Digital to Analog document has timing figures on pages 5 and 6.· The figures I quoted are the digital input timing requirements which I now see are 5 ns to 25 ns per cycle, and each input takes 16 cycles.· The output settling time is 1 us to 10 us.·

    Frankly I don't know if I'm talking apples and oranges or if timing is in any way related to the problem of not getting hoped for progression from 0 to 24 volts at the·power transistor.·

    I'm assuming the A/D chip can provide 0v-5v which can control a power transistor's gate to leverage 0v-24v.· Is that correct?

    Thanks,
    Kirk
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-15 14:30
    Kirk,

    ·· I wasn't sure which numbers those were, but some datasheets for older parts list a minimum cycle time or something similar for which the chip cannot communicate faster than that.· I thought that's what you referred to.· The fact is if the chip you're using is still in production it would most certainly work.· It was older (Usually obsolete chips) which have slower bus speeds.··In any event, if you post a link to the datasheet I will take a look at it.· You should probably also post the code you're using so a comparison can be made.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-09-15 15:09
    Kirk,

    There should be no problem at all with SHIFTOUT. The specs show that the TLV5618 is capable of operating its serial interface at a much much faster speed than even the 'px Stamp is capable of. However, there is no limit on the slow end for this type of interface.

    From your post, it is not clear to me where you are making the measurements. The phrase, "I'm assuming the A/D chip can provide 0v-5v which can control a power transistor's gate to leverage 0v-24v. Is that correct?", is the puzzle. The TLV5618 is a voltage output DAC, and translating that to 0-24 volts may not be as easy as you make it out to be. Could you post your schematic?

    As to the operation of the TLV--First just check the operation at its voltage output pin with no additional circuitry. Note that you have to observe common mode restrictions on the reference voltage, and the configuration of the device has to be set up in the data word.

    Data sheet from TI: www-s.ti.com/sc/ds/tlv5618a.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-09-15 19:36
    Ok here attached·is my circuit diagram and my code.· I think my wiring is correct but I probably have a bug in my code.·

    I don't know if basing my increment on 100 or 1000 is the data required by the DA chip.· With 12 bits available, perhaps it should increment to 4096.· Even with the smaller increments the value measured where the load will go jumps all over the range, never going down to zero.· Do I need software changes, more hardware, or both?

    I tried to scope the serial·commands from the Stamp to the DA·but I couldn't get my cheap scope to make a readable display of it.· Perhaps I should have used a longer pause in the program.

    Anyway I appreciate the help.· Thank you.

    Kirk Fraser
    566 x 609 - 42K
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-09-16 16:30
    I don't have one of the chips, but it looks to me from reading the data sheet (?!) that the reference pin (TLV5618 pin 6) needs to be connected to 2.048 volts. The maximum reference input is Vdd-1.5 (=3.5 volts when Vdd=5). The output amplifier has a fixed gain of x2. So with a 2.048 volt reference, the DAC output would be 4.096 volts. The output amplifiers cannot swing all the way to the supply, max Vdd-0.4 (=4.6 volts when Vdd=5). On your schematic, the reference is connected to +5 volts.

    Also, in your schematic, the base or gate of the transistor is connected directly to the output of the DAC. That is probably not what you want. When the DAC reaches the threshold of the transistor, the transistor and the attached coil will switch all the way from off to on over a very narrow range of control inputs, and the switching will be quite unstable as the transistors heat up. What you need there is a different circuit, probably a VCCS (voltage controlled current source).

    The transistor can't be a TIP42--that is a PNP type. It should be NPN or N-fet What is the JRL530? Do you mean IRF530?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-09-16 17:32
    Tracy,

    Thank you, I'll try to reduce the voltage at pin 6 to 2.048. Unfortunately the font available in my old Autocad LT is not very readable - I tried an IRL530 device. In trying to locate an example VCCS voltage controlled current source circuit some university webpages equate this to an Op-Amp. I will look for any Op-Amps that can handle 24v 1A or 24W. A good sample circuit with explination appears at http://xtrsystems.com/magnetometer/electronics

    Thank you for the tips.

    Kirk Fraser
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-09-17 01:47
    I'm sorry to throw around technical shorthand like VCCS. The op amp can be your friend in this, and the magnetometer URL is interesting in its own right. VCCS is a broad term. A bipolar transistor is intrinically a VCCS device.

    A single transistor bipolar can be a VCCS, but you have to hook it up in a little different way than your original circuit. There has to be a resistor in the lower leg of the transistor, as seen in the first attachment.

    attachment.php?attachmentid=38862

    The resistor Rset has to be chosen for the current range you need. If it is 100 milliamps at full scale, then the resistor would be Rset = (4.096 - 0.6)/.1 = 35 ohms. That is, the full scale output of the DAC, minus 0.6 volt for the transistor base emitter junction, divided by the desired current. There is in effect feedback from the emitter to the base of the transistor, regulating the current proportional to the input voltage.

    You could in theory use a mosfet like the IRF520 in this circuit, but as a practical matter most mosfets have a threshold voltage much higher than 0.6 volt (3 volts typical for the IRF520), so you really can't drive them off of a 5 volt analog DAC output. I know you said you need 1 amp full scale. To get that, you would need a nice beefy NPN darlington transistor which would have the necessary much higher current gain. A darlington has a threshold near 1.2 volts instead of 0.6 volts.

    Now, here is where the op-amp can be your friend. The second attachment puts an op amp in the feedback loop, and makes the output current directly proportional to the input voltage.

    attachment.php?attachmentid=38863

    Again, for higher currrents like 1 amp, you would need a beefy NPN Darlington transistor. And a MOSFET wouldn't work directly. However, your IRF520 work if we operate the op amp off of the 24 volt power supply. That is probaby your best option. I'll redraw the circuit for that. Note that feedback around the op amp removes the base-emitter (or gate-source) voltage from the equation.

    There may be other precautions to take for stability when driving magnetic proportional valve.

    Be sure to test the output of the DAC directly before it goes into the transistors. That is how to do "divide-and-conquer" troublshooting!

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

    Post Edited (Tracy Allen) : 9/17/2005 1:46:40 AM GMT
    222 x 254 - 3K
    253 x 254 - 3K
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-09-17 23:07
    Well, I'm sorry I'm not educated in electronics enough. I don't know how to reduce the voltage of the DA chip's reference. I tried putting in a 10K pot but at 10K my digital VOM kept incementing slowly as long as it was connected. So I suspect some kind of interaction with a capacitor in the meter. So how would I proceed?

    Thanks,
    Kirk
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-09-19 20:18
    Hi Kirk,

    The reference input on this DAC chip is a high impedance (>10 megaohms) so you should be able to supply it from a potentiometer. Something like the attached circuit.

    attachment.php?attachmentid=38889

    Set the reference voltage to close to 2 volts. The capacitor may not be necessary, but it can't hurt to have it there for a little more stability.

    I'm not sure what you meant by your comment about the VOM incrementing slowly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
    118 x 91 - 2K
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-01 13:34
    My TLV5618A still isn't working with a Stamp program looping 500 to 4096 by 100 putting the same values with the chip programming serially out to A and B.· Even with a 2.0 v reference voltage using·the above·10K pot & 0.1mfd cap·the voltage out switch between about 2.5 v and 4.9 v without the linear ladder like increments expected.· I even tried reversing my voltmeter contact points since I know some chips use negative logic.

    I will try another chip in case the test unit is bad.· It was a good suggestion to get the D/A working before working on the transistor coil driver stage.· Any other suggestions?· Should I get out of using a D/A chip and instead use a digitally variable resistor I once read of on this site?· If so I need a part number.

    Thanks.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-01 17:28
    Hi Kirk,

    Please attach your current program. So, let me understand this, you see either 2.5 volts or 4.9 volts at the output, and not the 0.1 volt steps you expect to see?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-01 18:57
    Hi Tracy,

    This morning the voltages shown were different, mostly 0.0, 1.0 and 3.0.· Here is the program used for both runs.·

    Kirk


    'DAC.bpx shows Digial to Analog controller functions via Parallax BS2px Stamp
    'when connected to Texas Instrument's DA chip TLV5618A, a 2 channel DA for
    'proportional control of a 2 coil fluid valve
    '{$STAMP BS2px}
    '{$PBASIC 2.5}
    '{$PORT COM1}
    'Three wire bus
    din······ CON·· 0····· ' data pin on BS2PX to TLV5618A
    sclk····· CON·· 1····· ' clock pin on BS2PX TO TLV5618A
    lcs······ CON·· 2····· ' TLV5618A chip select, active low
    'Software Vars
    'A· CON·· %1100000000000000·· 'Set A· Fast (momentary non-proportional)
    'B· CON·· %0100000000000000·· 'Set B
    A· CON·· %0001000000000000·· 'Buffer B· Slow Proportional
    B· CON·· %1000000000000000·· 'Set A & B· Set at same time
    DA······· VAR·· Word·· ' Data for A channel
    DB······· VAR·· Word·· ' Data for B channel
    Prop····· VAR·· Word·· ' Proportion of A coil on
    start:
    Prop = 500
    demo:················· ' exercise write subroutine
    · DEBUG "Prop: ", DEC Prop, CR
    · GOSUB DAwrite······· ' send millivolt data
    · PAUSE 500··········· ' demo delay
    · Prop = Prop + 100····· ' Increment proportion
    · IF Prop >= 4096 THEN start
    GOTO demo

    DAwrite:·············· ' send coil proportion of 100% as millivolts
    · DA = Prop '// 1000
    · DB = Prop '1000 - DA······· ' Set DB proportional to DA
    · DA = A + DA········· ' Put bits into DA as required by TLV5618
    · DB = B + DB········· ' Put bits into DB as required by TLV5618
    · DEBUG BIN DA, ": ", BIN DB, CR
    · LOW lcs············· ' select chip
    · SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]DA]
    · SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]DB]
    · HIGH lcs············ ' deselect chip
    RETURN
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-02 20:50
    Hi Kirk,

    I think the problem is that you need your SHIFTOUT commands to send 16 bits, and as you have it now they are only sending the default 8 bits.

    SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]DA\16]    ' <-- need \16  !!!!!
      SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]DB\16]
    
    



    See the help file for SHIFTOUT for more detail on the number of bits.

    Also, I think the A and the B are a little mixed up. The one you are naming DA is actually updating the "B" buffer and the one you named DB updates "A" and transfers the buffer to "B".

    The data sheet is not too clear on the meaning of "fast" versus "slow". I think it has to do with the analog bias settings, so the output buffer can respond with a higher bandwidth (and higher current consumption) on the fast setting. It has nothing at all to do with the data interface. For your purpose I think you are okay using either setting.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-02 23:08
    Hi Tracy,

    You are correct based on SHIFTOUT·help file·that I didn't correctly specify 16 bits so it defaulted to 8.· That is now fixed apparently but the result out of the chip is still not correct.· In the TI data sheet, pg. 11 I found I was also incorrectly sending the A value first instea of the B which comes first in the slow setting.·· So here's my new software segments, which unfortunately cause channel A to read 3.25 v and B to vary under 1 v.

    'A CON %1100 'Write & Set A - Fast mode (momentary non-proportional) 
    'B CON %0100 'Write & Set B 
    B CON %0001 'Write to Buffer B - Slow Mode 
    A CON %1000 'Write to Buffer A, Set A & B at same time
    

    (My·misreading the data sheet on this·leads me to try the fast mode next.)
    DEBUG "A ", BIN4 A, " : ", BIN12 DA, " B ", BIN4 B, " : ", BIN12 DB, CR 
    SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]B/4, DB/12] 
    SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]A/4, DA/12]
    

    This "appears" to be correct for the slow mode but it sure doesn't work at the A·and B outputs.

    Any further suggestions?· Thanks for your help.

    Kirk
    ·
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-02 23:22
    Hi Kirk,

    The number of bits for SHIFTOUT is specified after a backslash \, not a forward slash /. The forward slash will cause the data to be divided and 8 bits sent; not what you want!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-03 01:07
    Hi Tracy,

    I'm amazed that I've made such easy mistakes. Thanks for catching them. Changing the slash and also changing to fast mode seems to have fixed the first output -- it increments smoothly now although not quite the full range reading 0 v to 3.9 v. Switching the order of SHIFTOUT commands between A and B causes the second one to not work. Since the exact SHIFTOUT works in the first position for both A and B channels, I'm assuming my commands are now correct or close to it. I tried putting in a pause between the two SHIFTOUTs at 50 then 500 and no indication of accepting the second command.

    I tried integrating both sets of data into a single SHIFTOUT with no improvement. No idea on anything to try on the slow mode.

    Kirk
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-03 04:15
    It is important that the two commands come in the correct order. Both outputs change to the desired value simultaneously, when the last bit is clocked out.
    DA=1024   ' to set output A to 1/4 of full scale
    DB=2048   ' to set output B to 1/2 of full scale, and equal to the reference voltage.
    LOW lcs
    SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]1\4, DB\12]   ' sends data DB to the buffer
    SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]8\4, DA\12]    ' sends data DA to output A and the buffer contents to output B
    HIGH lcs
    END
    
    



    You could I think combine the shiftout all into one, as follows

    SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]$1000 + DB \16, $8000 + DA \16]
    



    The command + data words are transmitted as 16 bits and then another 16 bits.

    I think that the pauses you put in will not make a difference, as "fast" and "slow" have nothing to do with the interface to the BS2px. The terms "fast" and "slow" have only to do with the bandwidth & slew rate of the output drivers. With the "fast" bit set, the output can slew 3 volts in one microsecond, but with it unset, that is, "slow", the output can only change 0.5 volts in one microsecond. To achieve the higher speed, the chip draws twice as much current from the power supply, wow, 2 milliamps instead of 1 milliamp. There are other bandwidth specs that change too, but those fast vs slow specs might not make much difference to you in your application because microseconds are so much faster than the response of the proportional valve. The emphasis is that "fast" and "slow" on the TLV5618 have nothing to do with the interface to the Stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-03 17:12
    Hi Tracy,

    In my humble opinion, in theory the correct order is only required in the slow mode (since B is buffered to wait for A then update both outputs simultaneously) and the fast mode should update either value as soon as sent. So far I have no evidence showing the slow mode works at all.

    Today I'm still getting success on only the first channel in fast mode as described previously. I did not get success with your all in one command. I'll try to deselect the chip and reselect before the second command.

    Do you have another part or manufacturer to suggest? Thank you.

    Kirk
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-03 17:44
    The deselect reselect before the second command didn't work. Putting a pause between the deselect and reslect didn't work. I am out of ideas to try. I'll contact Texas Instruments. I can abandon their chip and company but I can't abandon the project.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-03 19:19
    First, did you try it with a fresh TLV5618? Is it possible that a fault in the earlier connection to 24 volts might have burnt out one of the channels?

    I can't offer more than hypotheses about the operation, because I don't have one of the chips. The data sheet is pretty skimpy on some of the details. You are left to experiment. I'm suprised it doesn't work. It ought to, and there is probably some little tidbit missing or a typo.

    There are only 6 possible action commands. They are:
    %0000 write data to buffer and to output B after lsb of data, slow mode
    %0100 write data to buffer and to output B after lsb of data, fast mode
    %0001 write data to buffer only, slow mode (no change at output)
    %0101 write data to buffer only, fast mode (no change at output)
    %1000 write data to output A and transfer buffer to output B after lsb of data A, slow mode
    %1100 write data to output A and transfer buffer to output B after lsb of data A, fast mode

    So, in either fast mode or slow mode, the commands allow you to update A or B outputs separately, or by using the buffer have both A and B outputs update at the same instant of time.

    As to alternatives to this chip, the only one I have extensive experience with is the MAX520 and MAX521, which are 8 channel, 8 bit DACs. Maybe other folks here have other recommendations.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-03 23:24
    Hi Tracy,

    Yes, I just tried a fresh TLV5618 and the result was exactly the opposite!! Instead of working at the first fast command, the new chip works on the second command ignoring the first. I don't know what could cause that.

    I'll look into the Max line, maybe they have a 12 bit unit. I also contacted Analog Devices but no response yet. Texas Instruments wants me to send a screen shot of the timing diagram but I'm not sure how to get my scope to produce it. That will require some experiements...

    Thanks for all your help and suggestions.

    Kirk
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-04 02:38
    Another hardware question. Do you have a good bypass capacitor (0.1 to 1 uf) directly from Vdd to AGND right next to the TLV5618? The result being "exactly the opposite", suggests parasitic power or unstable power supply. I'm sure you've double checked the wiring over and over!

    For the channels that do work, are you getting the correct value that you expect from the data sent?

    The TI engineer may surmise that your project violates the setup or hold time parameters of the TLV5618. Very unlikely with the BASIC Stamp. But that's why they want to see the 'scope trace.

    -- The BS2px SHIFTOUT transmission rate is 65 KILOhertz, with the clock high for 3.6 MICROseconds and low for 11.8 MICROeconds. The data line sets up 4 MICROseconds before the leading edge of the clock pulse and holds for 7.8 MICROseconds after the falling edge of the clock pulse. While that is a lot faster than SHIFTOUT on the earlier BASIC Stamps, it is way, way slower than the speed permitted by the TLV5618.

    -- The TI chiip allows data rates up to 20 MEGAhertz, with a minimum clock pulse width of 25 NANOseconds, with setup and hold times at 5 volts of only 5 NANOseconds. The TLV5618 shifts in the data on the falling edge of the clock. The message for the TI engineer is that the BS2px is clocking at 3 orders of magnitude slower than the rate allowed by the TLV5618.

    However, suppose that for some reason, you connected a 100 kohm resistor between your BASIC Stamp clock output over to the clk input of the TLV5618. Maybe it is a real resistor, or maybe the connection is just loose. And suppose the TLV5618 is mounted on one of those white breadboard thingies, which have quite a high pin to pin capacitance, about 100 picofarads. Well, the effect would be to slow down the clock pulse with a time constant of about 10 microseconds and it probably wouldn't work or it would be erratic. I'm not saying that is the problem. It is just one of those things, where the 'scope can help verify that the power supplies are stable and that the signals are clean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-05 06:34
    Tracy,

    I sent your last comments above to the support@ti.com Carlos but he still wants a scope shot without answering my specific question on exactly what to connect channel 1 and 2 to and what to set the vertical, horizontal, and trigger at. I have one of the newer cheap Tek scopes and don't know how to get a proper display out of it. So lacking any support there, I found a vendor listing hundreds of potentially better D/A parts from these manufacturers:

    Analog Devices
    Burr-Brown/Div of Texas Inst
    Linear Technology
    Maxim Integrated Products
    Microchip Technology

    Unfortunately the retailer didn't mention which parts have more than one channel so I'll have to look them up and get some samples from each to see which is going to work. Do you have any suggestions on what specs are best to reduce parts to drive a BUZ71 transistor or equivalent in your drawing from 9/16? Thanks.

    Kirk
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-07 15:40
    Most manufacturer have excellent web tools that help you narrow down your search for a part. These are usually called something like "parametric search" or "selection tree". For example, you can narrow down your search to include only dual channel 12 bit DACs available in DIP packages. Vendors, Digikey in particular, have very convenient links to the manufacturer's data sheet for each and every part they sell.

    For the 'scope, you will want to attach the probes to the Stamp/TVL5618A as follows:
    trigger to LCS\
    channel 1 to din
    channel 2 to sclk
    set to trigger on high to low transition of LCS\
    horizontal sweep to something between 10 to 50 microseconds per division. Once you have a good trace, you may want to try the expanded sweep options.
    Run a test program in the Stamp that repeats the salient SHIFTOUT over and over the same way each time:



    LOW lcs
      SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]$0100 \16]  ' preset channel B to output V=Vref
    HIGH lcs
    DO    ; this same thing over and over
      LOW lcs   ' scope trace will lock on to this transition
        SHIFTOUT din,sclk,MSBFIRST,[noparse][[/noparse]$1555 \16]  ' repeat over and over, pattern %0001010101010101
      HIGH lcs
    LOOP
    



    The 'scope is a powerful tool for exloration and it would be naive to expect that one canned setting will give you the result you need. You have to play with it. Different settings will reveal different aspects of the signal. Also, a caveat, you will probably see things that don't make any sense at all, because the 'scope can lock onto things in unexpected ways that fool you. It takes understanding of how the 'scope works and good results come from experience. If you don't know how to use the 'scope, you should get a text on the subject. Maybe start with the Parallax "Understanding Signals", which is based around the USB 'scope, but I'm sure the lessons would carry over to your 'tek 'scope. Good luck!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-11 03:30
    Hi Kirk, any luck on this yet?

    Looking through a parts and samples box today, I ran across a MAX5722, which is a dual 12 bit DAC in an 8 pin package with SPI serial interface. I've attached a program that ramps channel A up from 0 to 5 volts while it ramps channel B down. The interface is similar to the TI part that has been giving you so much trouble, but not exactly. On the hardware side, the reference can be tied directly to the +5volt supply, and then the output buffer can swing rail to rail from 0 to 5 volts. On the software side, there are two buffers, one for each channel, and the data you send can be directed to either the buffer or directly to either output. The power-down control has more options too.

    I had the following difficulties at first getting the chip to work. 1) it is in the Maxim uMax package, so I had to solder it onto a carrier to turn it into dip format, and in doing so I didn't solder the sclk pin, so it didn't work until I corrected that. 2) The chip powers up in a disabled state with the outputs connected to ground via on chip 100k resistors, so the chip didn't work until I sent it the command that enables the outputs. 3) The data for two commands cannot be concatenated, so getting both channels to work requires two separate select & shiftout sequences. Once past those difficulties, it worked exactly as advertised.

    ' {$STAMP BS2pe}
    ' {$PBASIC 2.5}
    ' MAX5722 demo
    ' demo routine for the Maxim 12 bit dual DAC chip, 8 pin uMax
    ' demo makes channel A ramp up while channel B ramps down
    
    cs PIN 3    ' chip select for MAX5722
    sclk PIN 1    ' clock for MAX5722
    sdat  PIN 0   ' data for MAX5722
    dacval  VAR Word   ' data value to send to chip, 0<=dacval<=4095
    HIGH cs : LOW sclk : LOW sdat   ' start with pins in known state.
    LOW cs
    SHIFTOUT sdat,sclk,MSBFIRST,[noparse][[/noparse]$F010\16]   ' wake up and enable both channels
    HIGH cs
    DO
      dacval = dacval+1 // 4096  ' channel A will ramp up, B will ramp down
      LOW cs
      SHIFTOUT sdat,sclk,MSBFIRST,[noparse][[/noparse]$0000 + dacval \\ 16]  ' data to channel A
      HIGH cs
      LOW cs
      SHIFTOUT sdat,sclk,MSBFIRST,[noparse][[/noparse]$1000 + (4096-dacval) \\ 16]  ' data to ch B
      HIGH cs
    LOOP
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-27 00:34
    Hi Kirk, to revisit this subject.

    I returned from Chicago to find samples of the TLV5618 waiting. I did get it working, but not without some initial frustration. The trick is that the Stamp has to send the chip 17 bits, not just 16. I think this explains our confusion . Here is a program that works for me, to ramp up output A and ramp down output B:

    ' for tlv5618, reference =2 volts, Vdd=5 volts
    ' A and B outputs ramp up/down to 4 volts
    sdta PIN 0
    sclk PIN 1
    cs PIN 2
    wx VAR word
    wy VAR word
    
    HIGH cs
    
    DO
      wx = wx+4//4096   ' for A ramp up
      wy = 4096 - wx     ' for B ramp down
      LOW cs
        SHIFTOUT sdta,sclk,MSBFIRST,[noparse][[/noparse]1\4,wy\12,0\1]  ' wy to B buffer
      HIGH cs
      LOW cs
        SHIFTOUT sdta,sclk,MSBFIRST,[noparse][[/noparse]8\4,wx\12,0\1]  ' wx to A output and B buffer to B output
      HIGH cs
    LOOP
    
    



    See the additional 0\1 bit sent at the end of each SHIFTOUT? The data is actually transferred on the rising clock edge of that bit. The data does not mattter; it is just clocking. The TI data sheet implies at one point that the data might be transferred by the rising edge of the chip select after 16 bits, but no, that is misleading. Each SHIFTOUT does have to be framed by the cs low-high. If you reread the data sheet and look at the timing diagram carefully you can see the 17th clock edge is shown & is required before the cs goes back high.

    I'd like to hear if this will work for you. (Or maybe you have already had success with one of the other sample chips?!)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-27 22:43
    Hi Tracy,

    Thank·you for your sustained interest and help.· Your TLV5618 fix worked!· I also added statements to run chips MAX539 and LTC1257 and they all worked.· The LTC1257 is the better chip since its output range is limited by the reference voltage so it can be 0-2v or 0-5v or whatever.··Comparing prices at DigiKey for example make the TLV5618 (in a DIP package for soldering ease) the cheapest considering it has two channels and the other two·have one channel each.

    Now then on to the full circuit you proposed earlier.· What transistor do you recommend to transform the TLV5618's output to 0-24v at 1A?· (I have Notify on now, sorry about before.)

    Thanks again,
    Kirk
  • Kirk FraserKirk Fraser Posts: 364
    edited 2005-10-28 16:23
    Tracy,

    Ok I've re-read your post from 9/16 (my birthday) and see the recommendation for an op-amp, my IRL530, and the 24v supply. I'll give it a try and report the results. I assume any Radio Shack op-amp will do.

    Kirk
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-28 17:03
    With regard to the 'scope. I really do suggest that you work through a tutorial on how to use it. There are probably some avaialable online, in addition to the Optoscope/Understanding Signals tutorial offered by Parallax. My own first 'scope was a Heathkit, a simple one with only the bare essentials for gain and triggering. There was also a Heathkit tutorial that was helpful. You have to know how to lock on to simple signals first, before you tackle more complcated ones.

    With regard to the circuit from 9/16. There are refinements that are needed before it is practical. I was going to post a more complete version, but then we got onto the issue with the DAC. I'll dig around and post a schematic later. Not just any op-amp will do. It needs to be a single supply op amp, and prefereably it will be one that can operate from the 24 volt power supply, to give more headroom to drive the power transistor. An LM358 would be good, and I think Radio Shack might have it. The revised circuit will have a 10:1 voltage divider to feed a lower voltage around 0.4 volts full scale into the op-amp, so that the circuit can use a low resistance sense resistor. The sense resistor will be around 0.4 ohm, so with one amp flowing it will only have to carry 0.4 volt and dissipate 0.4 watt. You will need to find or construct (out of fine wire) a 0.4 ohm resistor capable of carrying one amp. Or a resistance approximately in that range. The power transistor should be an N-channel mosfet capable of carrying one amp and also capable of dissipating substantial power, 10 or 20 watts. An IRF520 with a big heat sink might do the trick. Do you already have a transistor? You will also need a diode like a 1N4001 to put across the valve, for dump protection, and a capacitor of around 0.01uF. The feedback around the op amp will regulate the current flowing through the valve.

    -- Tracy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.