Component for MCP4728

Moderator: Benj

chad
Posts: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Component for MCP4728

Postby chad » Mon Feb 11, 2019 6:50 pm

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: 14216
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4355 times
Been thanked: 4095 times
Contact:

Re: Component for MCP4728

Postby Benj » Wed Feb 13, 2019 6:07 pm

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.
These users thanked the author Benj for the post:
chad (Thu Feb 14, 2019 6:49 pm)
Rating: 5.26%
 

chad
Posts: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Wed Feb 13, 2019 8:19 pm

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: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Sun Feb 17, 2019 3:11 am

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
These users thanked the author chad for the post:
Benj (Mon Feb 18, 2019 6:18 pm)
Rating: 5.26%
 

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

Re: Component for MCP4728

Postby Benj » Tue Feb 19, 2019 5:26 pm

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.
These users thanked the author Benj for the post:
chad (Tue Feb 19, 2019 6:08 pm)
Rating: 5.26%
 

chad
Posts: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Tue Feb 19, 2019 6:11 pm

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: 14216
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4355 times
Been thanked: 4095 times
Contact:

Re: Component for MCP4728

Postby Benj » Tue Feb 19, 2019 6:16 pm

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: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Tue Feb 19, 2019 6:23 pm

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: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Tue Feb 19, 2019 6:25 pm

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: 14216
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4355 times
Been thanked: 4095 times
Contact:

Re: Component for MCP4728

Postby Benj » Tue Feb 19, 2019 6:30 pm

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: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Tue Feb 19, 2019 6:41 pm

Cool, I try it out. Thanks!

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

Chad

chad
Posts: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Tue Feb 19, 2019 6:47 pm

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: 14216
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4355 times
Been thanked: 4095 times
Contact:

Re: Component for MCP4728

Postby Benj » Tue Feb 19, 2019 11:39 pm

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: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Wed Feb 20, 2019 7:39 am

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 15 times
These users thanked the author chad for the post:
Benj (Wed Feb 20, 2019 3:38 pm)
Rating: 5.26%
 

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

Re: Component for MCP4728

Postby Benj » Thu Feb 21, 2019 2:21 pm

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: 109
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 17 times
Been thanked: 27 times
Contact:

Re: Component for MCP4728

Postby chad » Fri Feb 22, 2019 5:20 pm

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: 14216
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4355 times
Been thanked: 4095 times
Contact:

Re: Component for MCP4728

Postby Benj » Fri Feb 22, 2019 9:45 pm

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.48 KiB) Downloaded 34 times