Shop OBEX P1 Docs P2 Docs Learn Events
Up to date driver for MAX1202 A/D chip — Parallax Forums

Up to date driver for MAX1202 A/D chip

RsadeikaRsadeika Posts: 3,837
edited 2014-12-26 10:32 in Propeller 1
Does anybody have an updated driver for the MAX1202 chip? Since I am destroying my electronics stuff (Activity Board) with my latest experiments, I am going a cheaper route, individual parts. I dug out my old Propeller Platform Board and I found a MAX1202 chip. I will breadboard the MAX1202 and if something goes wrong, it will cost me less than $10.00 which include a Propeller chip, I think.

I would prefer a C driver, this is a big stretch, but I would be very happy with Spin driver. I did find a driver in the OBEX, but it relies on a BS2 object, the last time I worked with a BS2 was probably 10 or 15 years ago, not sure if I want to go backwards. Hopefully somebody has something that is the latest.

Thanks

Ray

Comments

  • PublisonPublison Posts: 12,366
    edited 2014-12-25 15:00
    Don't be afraid of the BS2 Functions. Martin wrote that object to make BS2 users to be comfortable with SPIN.

    For example, the call to
    bs2.SHIFTOUT(AoutAdc, ClkAdc, Value2Pass, BS2#MSBFIRST,8 )
    

    just does this in SPIN
    PUB SHIFTOUT (Dpin, Cpin, Value, Mode, Bits)| bitNum
    {{
       Shift data out, master clock, for mode use ObjName#LSBFIRST, #MSBFIRST
       Clock rate is ~16Kbps.  Use at 80MHz only is recommended.
         BS2.SHIFTOUT(5,6,"B",BS2#LSBFIRST,8)
    }}
        outa[Dpin]:=0                                          ' Data pin = 0
        dira[Dpin]~~                                           ' Set data as output
        outa[Cpin]:=0
        dira[Cpin]~~
    
        If Mode == LSBFIRST                                    ' Send LSB first    
           REPEAT Bits
              outa[Dpin] := Value                              ' Set output
              Value := Value >> 1                              ' Shift value right
              !outa[Cpin]                                      ' cycle clock
              !outa[Cpin]
              waitcnt(1000 + cnt)                              ' delay
    
        elseIf Mode == MSBFIRST                                ' Send MSB first               
           REPEAT Bits                                                                
              outa[Dpin] := Value >> (bits-1)                  ' Set output           
              Value := Value << 1                              ' Shift value right    
              !outa[Cpin]                                      ' cycle clock          
              !outa[Cpin]                                                             
              waitcnt(1000 + cnt)                              ' delay                
        outa[Dpin]~                                            ' Set data to low
    

    You can get rid of the BS2 object, and just use to SPIN code for the Shiftout.
  • RsadeikaRsadeika Posts: 3,837
    edited 2014-12-26 03:19
    Thanks Publison, it does not look like there are too many people using the MAX1202. I will give the existing object a try and see what happens. There is also spin2cpp available to convert it too C if I find this to be handy, not sure where this will end up.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2014-12-26 04:55
    After looking at the MAX1202 object, the first stumbling block, wiring up to the chip. Below is the chart for the Spin pin requirements and the MAX1202 pin usage. Some are obvious while others, not so.

    Spin - Max1202
    5 - 18
    3 - 16
    Not sure about the rest of them, if somebody could enlighten me, would be appreciated.

    Ray
    Spin program CON
    ClkAdc = 11 ' A/D clock (Change These Values/Pins As Needed)
    CsAdc = 5 ' Chip Select for ADC
    AoutAdc = 13 ' A/D Data sent to the ADC
    AinAdc = 12 ' A/D Data recieved from the ADC
    Sstrb = 3 ' SSTRB signal for max 1202
    ready = 16 ' Cog ready signal (pin to read for ready state)


    PIN NAME FUNCTION
    1–8 CH0–CH7 Sampling Analog Inputs
    9 VSS Negative Supply Voltage. Tie VSS to -5V ±5% or to GND.
    10 SHDN Three-Level Shutdown Input. Pulling SHDN low shuts the MAX1202/MAX1203 down to 10μA (max)
    supply current; otherwise, the MAX1202/MAX1203 are fully operational. Pulling SHDN to VDD puts
    the reference-buffer amplifier in internal compensation mode. Leaving SHDN unconnected puts the
    reference-buffer amplifier in external compensation mode.
    11 REF Reference-Buffer Output/ADC Reference Input. In internal reference mode (MAX1202 only), the
    reference buffer provides a 4.096V nominal output, externally adjustable at REFADJ. In external
    reference mode, disable the internal buffer by pulling REFADJ to VDD.
    12 REFADJ Input to the Reference-Buffer Amplifier. Tie REFADJ to VDD to disable the reference-buffer amplifier.
    13 GND Ground; IN- Input for Single-Ended Conversions
    14 VL Supply Voltage for Digital Output Pins. Voltage applied to VL determines the positive output swing of
    the Digital Outputs (DOUT, SSTRB). 2.7V ≤ VL ≤ 5.25V.
    15 DOUT Serial-Data Output. Data is clocked out at SCLK’s falling edge. High impedance when CS is high.
    16 SSTRB Serial-Strobe Output. In internal clock mode, SSTRB goes low when the MAX1202/MAX1203 begin
    the analog-to-digital conversion, and goes high when the conversion is finished. In external clock
    mode, SSTRB pulses high for one clock period before the MSB decision. High impedance when CS is
    high (external clock mode).
    17 DIN Serial-Data Input. Data is clocked in at SCLK’s rising edge.
    18 CS Active-Low Chip Select. Data is not clocked into DIN unless CS is low. When CS is high, DOUT is
    high impedance.
    19 SCLK Serial-Clock Input. SCLK clocks data in and out of the serial interface. In external clock mode, SCLK
    also sets the conversion speed (Duty cycle must be 40% to 60% in external clock mode).
    20 VDD Positive Supply Voltage, +5V ±5%
  • kwinnkwinn Posts: 8,697
    edited 2014-12-26 08:14
    Propeller > MAX1202

    ClkAdc = 11 > 19 ' A/D clock (Change These Values/Pins As Needed)
    CsAdc = 5 > 18 ' Chip Select for ADC
    AoutAdc = 13 > 17 ' A/D Data sent to the ADC
    AinAdc = 12 > 15 ' A/D Data received from the ADC
    Sstrb = 3 > 16 ' SSTRB signal for max 1202
    ready = 16 > ?? ' Cog ready signal (pin to read for ready state)

    ?? - Not sure where this connects. Could be the SHDN, it is the only control signal not accounted for, but I do not have time to hunt through the code to find it.

    Pin 14 is the low voltage power input and should be connected to 3.3V if you want to connect the ADC pins directly to the propeller pins. If you connect +5V here you will need protection resistors for propeller input pins.

    You can download the data sheet here if you do not have it already. http://www.maximintegrated.com/en/products/analog/data-converters/analog-to-digital-converters/MAX1202.html/tb_tab2
  • RsadeikaRsadeika Posts: 3,837
    edited 2014-12-26 09:08
    Thanks kwinn, I went through the code and could not find how or where it uses "ready = 16 > ?? ' Cog ready signal (pin to read for ready state)". This particular program by James Long seems to be a specialized program for reading Altitude and Airspeed instruments. Not sure how I could use this program to do Voltage readings @ ~20V. In the chip documentation it mentions something about a 4.096V as reference, so that means I would have to reconfigure all my resister values, I think I will turn back the clock and make it so I did not find that chip.

    So now I have two choices, use my PropBOE board or use my C3 board, which one is expendable? The PropBOE has some code for doing voltages, but the code would need to be changed to suit my purposes, this is Spin code, now I am used to working with C. I believe the same thing is true with the C3, would have to make code changes to make it work for me.

    Ray
  • kwinnkwinn Posts: 8,697
    edited 2014-12-26 10:32
    Those are pretty expensive boards to risk frying. A protoboard would be much less, and a dip prop chip in a socket on a small pad per hole pcb is about a third of that. Another idea would be to build a 3.3V to 5V buffer board to go between the propeller and circuit under development.
Sign In or Register to comment.