MCP4822 - 2 channel, 12-bit DAC.. Got Code??
davekorpi
Posts: 20
Hi all!
Hope EVERYONE had an AWESOME Holiday for sure!
Anyone know if the code here..
MCP4922 - 2 channel, 12-bit DAC
Will work for the MCP4822- 2 Channel, 12-bit DAC with some small mods??
I have a bunch of MCP-4822's that I want to use and I wonder if yall know if the MCP4922 code in the OBEX will work...
Reference:
http://ww1.microchip.com/downloads/en/DeviceDoc/22250A.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/22249A.pdf
I have tried it and can not get the things to sing... I have a beautiful +5 VDC Ref
OutZS := 2048
DAC.Set(0, OutZS) ' Channel A 0-5 VDC half-range 2048 = 2.5V with 5V reference)
DAC.Set(1, OutZS) ' Channel B 4-20 mA half-range 2048 = 2.5V with 5V reference)
Here is a snagit of the quick scheemo I am breadboarding..
http://www.screencast.com/t/gtWVaQngHd
Thanks a million yall!!!
I know.. Why don't I get some 4922's??!!! Wellll.. cuz I have 4822's and PROBABLY some smart folks KNOW that they SHOULD both work the same... I ain't that smart by golly!
Hope EVERYONE had an AWESOME Holiday for sure!
Anyone know if the code here..
MCP4922 - 2 channel, 12-bit DAC
Will work for the MCP4822- 2 Channel, 12-bit DAC with some small mods??
I have a bunch of MCP-4822's that I want to use and I wonder if yall know if the MCP4922 code in the OBEX will work...
Reference:
http://ww1.microchip.com/downloads/en/DeviceDoc/22250A.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/22249A.pdf
I have tried it and can not get the things to sing... I have a beautiful +5 VDC Ref
OutZS := 2048
DAC.Set(0, OutZS) ' Channel A 0-5 VDC half-range 2048 = 2.5V with 5V reference)
DAC.Set(1, OutZS) ' Channel B 4-20 mA half-range 2048 = 2.5V with 5V reference)
Here is a snagit of the quick scheemo I am breadboarding..
http://www.screencast.com/t/gtWVaQngHd
Thanks a million yall!!!
I know.. Why don't I get some 4922's??!!! Wellll.. cuz I have 4822's and PROBABLY some smart folks KNOW that they SHOULD both work the same... I ain't that smart by golly!
Comments
Have you verified the pin assignments?
DAC.Init(11, 12, 13) 'CS, SCK, SDI respectively
FINAL ANSWER!!!
The MCP4822 will drive the MCP4922 directly..
when I am not a weenie and forget to hook up the VDD Pin!
Sorry for the hassle guys and gals. My stupidity on the wiring..
If you want to get 0-4.096 so I adjust the Gain value to 0 instead of the 1 that I was also messing with.
' Channel, Gain, Shutdown, Value
data := (Channel << 15) + (0 << 13) + (1 << 12) + Value 'Bit 13 = 0 for 5 VDC
See the code by Ryan David with a few notes of mine...
I am not sure your pin order matters, I took a quick glance and don't see anything obvious that requires the order be in reverse of this, but I use CS = 0, SCK= 1 SDI = 2 in that order versus what you are doing.
Go back and verify you have 5V at the VDD pin, VSS at both the VSS and LDAC pin. If you are breadboarding this, you may want to change to a different section of the board. It does happen that bad contacts on a breadboard can cause a lot of wasted time. Try different pins on the Prop to confirm you don't have dead pins, or at least do simple output tests on prop pins to confirm you have connections.
I see this on page 66 of the Propeller Manual..
http://www.parallax.com/sites/default/files/downloads/P8X32A-Web-PropellerManual-v1.2.pdf
Any hints whi it does not work as per this:
_clkmode = xtal2 ' For 10 MHZ Xtal div by 8 on xtal1
_clkfreq = 10_000_000 ' From Pg 66/399 of Propeller Manual
When I do this:
_clkmode = xtal1 + pll8x ' For 10 MHZ Xtal div by 8 on xtal1
_xinfreq = 10_000_000
The Serial Port works with my 10 MHz clock.. Would tell me the timing is happy...
Know any different??
Am I messing up?
Anyone ever got a 4822 to work with 4922 code?
Is your 10Mhz in a crystal or a clock?
If it is a crystal, the crystal capacitance should be 36pf to work correctly. Then you would use:
_clkmode = xtal1 + pll8x ' For 10 MHZ Xtal div by 8 on xtal1 "It is actually multiply x 8"
_xinfreq = 10_000_000
I have two boards with 10 Mhz Xtals and they work fine at pll8x.
Both were commercially produced, on being :
http://www.parallax.com/product/28327
GOT SCHEEMOES on the Backpack??
http://www.parallax.com/product/28327
COOL!!! I used the same clock defs as you!!
_clkmode = xtal1 + pll8x ' For 10 MHZ Xtal div by 8 on xtal1 "It is actually multiply x 8"
_xinfreq = 10_000_000
Can we use the 4922 code to make a 4922 (also a 2 chan SPI DAC) work???
MCP4922 - 2 channel, 12-bit DAC
Schematics can be gotten of the product page, under "Downloads"
I don't believe there is a Bill of Materials list for the part number, but I think it has been mentioned in a few threads here if you search for such things as :10 Mhz Xtal"
MCP4802/4812/4822
4.1.3 POWER-ON RESET CIRCUIT
The internal Power-on Reset (POR) circuit monitors the
power supply voltage (VDD) during the device
operation. The circuit also ensures that the DAC
powers up with high output impedance (<SHDN> =0
The devices will continue to have a
high-impedance output until a valid write command is
received and the LDACpin meets the input low threshold.
5.2 Write Command
The write command is initiated by driving the CS
pin low, followed by clocking the four Configuration bits and
the 12 data bits into the SDI pin on the rising edge of
SCK. The CS pin is then raised, causing the data to be
latched into the selected DAC’s input registers.
The 4922 has hardware shutdown using a pin but also uses the same software power on reset + shutdown. The 4822 uses a software shutdown and on power up, the device is shutdown until you send a write command. However, it does appear that the write command for both 4922 and 4822 is identical except for bit 14 on the 4822 which is a don't care bit. I can't see why it doesn't work.
DAC.Set(0, 0) In your code you are only setting channel A, have you tried setting B as well to see what happens? This is sounding more like a connection, noise, or bad chip problem. You do now show any bypass caps on the schematic. Any transients on the power lines could cause the chip to reset it's outputs to shutdown. Transients on CS could cause the write to be aborted. Are the Prop and the 4822 powered from the same rails? You should have a ,1uf and a 10uf at the 4822 between +5 and GND.