CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Interfacing MCP4921 with PIC18F4620 through optocoupler

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
paddy



Joined: 04 Nov 2012
Posts: 15

View user's profile Send private message

Interfacing MCP4921 with PIC18F4620 through optocoupler
PostPosted: Wed Mar 11, 2015 12:24 am     Reply with quote

Hi,

Greetings of the day!!!

I am using driver files of MCP4921 to interface with PIC18F4620.
Compiler version is 4.119.

Everything working fine when I directly interface MCP4921 with PIC18F4620.
But when I insert KP1010 optocoupler in between DAC and microcontroller it is not working. I have tried same with 6N139 optocoupler. But in both cases it fails.

Please find attached schematic for reference.

Please advice.

Regards,
Paddy
https://www.dropbox.com/s/yrcfxx5tve6pr6d/MCP4921.bmp?dl=0
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Mar 11, 2015 2:37 am     Reply with quote

Have you looked at waveforms on both side of the optos with a 'scope?

Mike
paddy



Joined: 04 Nov 2012
Posts: 15

View user's profile Send private message

PostPosted: Wed Mar 11, 2015 2:47 am     Reply with quote

Hi Mike,

I do not have oscilloscope to check the waveforms. Crying or Very sad Crying or Very sad
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 11, 2015 6:12 am     Reply with quote

What speed is the SPI bus ?
Optocouplers generally are 'slow speed' devices, so you'll need to read the datasheets, and decide if the one you choose has the proper rise time,fall time, overall speed needed for your application.
You just can't 'grab one off the shelf' and expect it to work !
Ok, you can do that for 'line follower robots' but NOT for any high speed application.

You will need a 'scope' to SEE the waveforms and probably have to 'adjust' the resistors as well.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Wed Mar 11, 2015 6:54 am     Reply with quote

The KP1010, is only rated to 80KHz max. It'll not even be getting there though, the 10K output resistors will limit the rise time significantly. Something like 1K needed to get full speed.
Use something like a 6N137, with 470R resistors on the output, to get reasonable speed operation.
paddy



Joined: 04 Nov 2012
Posts: 15

View user's profile Send private message

PostPosted: Wed Mar 11, 2015 11:59 pm     Reply with quote

Hi all,

Thanks for your suggestions. I will check out the options which you have suggested.

Thanks,
Paddy
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri Mar 13, 2015 3:31 am     Reply with quote

First question:-

How fast do you HAVE to update the DAC?

Everything else depends on the answer.

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 13, 2015 6:35 am     Reply with quote

2nd question

WHY the optocouplers ?

I have to assume that the power supply may be common, SPI is a SHORT distance buss, and everything is on the same PCB ?

It'll take a LOT of R&D time and effort to get even 1 MHz SPI buss speed from an optocoupler configuration.


Jay
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Mar 13, 2015 10:30 am     Reply with quote

if you really need to use isolation - and you want high data rates
consider GMR type isolaters.

i used the following for a very reliable 4 mhz clock/data isolation circuit for
a veterinary life-sciences portable product and was quite happy.

it is under $4 ea in quantity.

note: it only has 2.5 kv or so isolation but the speed can't be beat.

http://www.nve.com/Downloads/il710.pdf
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Sat Mar 14, 2015 7:43 am     Reply with quote

I have used SPI driving a different DAC, for opto-coupled 4-20mA analog outputs. I used the 6N137, and ran the SPI at 1MHz.
This is why I suggested the 6N137, since it worked well for me. Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group