Component for MCP4728

Moderator: Benj

Post Reply
chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Component for MCP4728

Post by chad »

Hey, while you are at it ;) I am going to be using the mcp4728...Actually I am going to be using 4 of them.

thanks,
chad

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Component for MCP4728

Post by Benj »

Hi Chad,

I've had a go at adding this. I think it should work ok but I haven't done the code to allow you to set the I2C address on the onboard EE memory. Do you need this or will you have unique I2C pins for each device?

Available now via the update system.

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

Hi Ben, that's awesome!

I was hoping to use them all on the same i2c line so I didn't have to waste all of those pins and have multiple i2c bitbangs going.
Just took a look at the component. Looks great. One suggestion if possible. on the 3d display It would be cool of the 0-4.1 could scale with the vref setting. Not a big deal, Just a little thing. *EDIT Never mind, I see now that it does it.)

My friend has my 4728 and I will get it back from him later this week and give it a shot!

*EDIT. I got it back and was going to give it a try but the 446re target is broken, so I will test is as soon as i can..

Thanks!!

chad

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

I was looking at the data sheet and looking at some old arduino code. We really need to be able to write to the eeprom. I am going to have to be able to set the dac voltages to 0 on power up. Very picky laser diodes are going to be hanging of the back of these.

thanks
Chad

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Component for MCP4728

Post by Benj »

Hi Chad,

I've had a go for you, the latest component is now available via the update system.

Let us know how you get on.

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

Ok I will!

I'll give it a shot. I did have one question. In the properties you have sda and sda pins, scl, scl pins.

I don't get why there are 4 pin settings for those two pins.

Chad

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Component for MCP4728

Post by Benj »

Hi Chad,

SCL and SDA should be the fixed hardware pins. These should be read only.

SCL Pins and SDA Pins should only appear when you have remappable functionality onboard your target chip which lets you select the SCL and SDA pins. These should be selectable from a list of valid pins.

Looks like there may be a bug at the moment which makes SCL and SDA writable when in hardware mode. I'll investigate this as I've not come across this one before.

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

Yeah, something is funky, because I can't choose the pins that I want to use. I can select sda c9 and scl c8, but can't select them in the pins.

Chad

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

And btw, I can't select hardware at all. It only has the software option.

and it didn't work...
I am using the 446re chip target.
chad

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Component for MCP4728

Post by Benj »

Hi Chad,

I've re-exported the component and hopefully the pin properties should behave better for you now.

Currently no HW I2C support on the ST ARMs though Leigh is looking into this. Software should work fine.

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

Cool, I try it out. Thanks!

I'll give it a try when I get home later..

Chad

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

I Tried it out. I am not getting anything on the sda or scl pins.

Edit I had the pin wrong Scl is pb8 I get a blip on the scope but it isn't changing the dac output.
I'll dig into it later
thanks


C

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Component for MCP4728

Post by Benj »

Hi Chad,

Do you have pull up resistors fitted to the SDA and SCL pins? The MCP472 likely won't provide them for you.

It should be possible to use the internal pull ups using a line of C code to avoid external components. What pins are you using and I'll have a stab at the code for you.

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

Yeah I had 4.7k pullups. I also had a dud jumper wire... I don't want to talk about it...

Anyway I spent many hours testing it this evening. Here's a rundown.

Initialize works.
Dac channels work.
Enable channels work.
100kb,400kb works. 1meg is no different in speed to 400k. Have not verified actual 400k.
The DeviceAddress works when set to 0(default) and my default chip. Doesn't work when set to other than 0. Can't' test further.


The GainOP property setting is inverted on hardware. It's backwards.
The SetinitalEEOutput doesn't function.
The SetDeviceAddress doesn't function.
The PDOoption doesn't doesn't function.

Haven't tried disable channel yet.
Haven't tried ControlPins yet. Question on ControlPins, Do I have to toggle this manually or does it do it's thing when writing to this dac [component UseLDAC]?

A Properties: VREFOPtion,GAinOP,VrefVol issue. I run my dac at 3.3v. The 2.048 vref x2 gain only gets to 3.3 not 4.096 and probably isn't linear. The VREFOPtion>VDD doesn't allow you to set the slider values to match actual dac output based on voltage. Not quite sure how to fix this. If=VDD VrefVol (Input VDD voltage)?. If VREFOPtion>INTernal | Gain 1X everything matches. The chip works from 2.7v to 5.5v... Is any of that legible:)

So far so good.

Thanks,

chad

Here is my test prog.
dac test.fcfx
(11.83 KiB) Downloaded 261 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Component for MCP4728

Post by Benj »

Hi Chad,
The GainOP property setting is inverted on hardware. It's backwards.
Fixed.
The SetinitalEEOutput doesn't function.
I've added a new parameter to allow you to specify if the DAC is enabled or not on power up my guess is it's currently working but disabled.
The SetDeviceAddress doesn't function.
This macro requires you to have the Use LDAC pin set to True and each MCP4728 IC connected must have a unique LDAC pin. The macro then toggles the LDAC pin for you, hopefully as required.
The PDOoption doesn't doesn't function.
This is only active when the DAC is in the disabled state. I can't specifically find a fault with this code.
Haven't tried ControlPins yet. Question on ControlPins, Do I have to toggle this manually or does it do it's thing when writing to this dac [component UseLDAC]?
The component uses the LDAC pin when executing the SetDeviceAddress macro. Other then this it is not used by the component.

I'll get the updated component pushed to the update system for you tomorrow.

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: Component for MCP4728

Post by chad »

Hi ben,

Sorry I have been busy with work.. I'll give this a shot this weekend and let you know!

Thanks

chad

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Component for MCP4728

Post by Benj »

No Worries :D

I didn't manage to push the file to the update system in the end so here it is if you want to have a go.
DAC_Output_MCP4728.fcpx
(6.47 KiB) Downloaded 239 times

Post Reply