Interfacing the Pic16F877A with the MCP3201 12-Bit ADC.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
muxer107
Posts: 8
Joined: Fri Apr 27, 2007 2:39 pm
Contact:

Interfacing the Pic16F877A with the MCP3201 12-Bit ADC.

Post by muxer107 »

Hi

I intend on Interfacing the Pic16F877A with the MCP3201 12-Bit ADC using SPI. I was just wondering if anyone has done this in the past and have any routines for this. I know a bit of C programming, but I've never actually tried any sort of interface communication.

Ive most of the rest of the programme written in Flowcode V3 and its running fine.

Im kinda stuck at the moment on a project Im doing because of this and I could really use some help with it :)

Any input is appreciated and both data sheets are on Microchip.com if you need more info.

TIA
Muxer

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:

Post by Benj »

Hello Muxer

Can you just use the Flowcode SPI component.
You will need a PICmicro with SPI hardware capability.

You will also need to select a output pin to use as the Chip Select Pin. This enables the ADC module.

You will then need to create a flowchart with the following hardware macro calls.

SPI_Init
Send CS Output High
Send CS Output Low //Enable ADC
SPI_GetChar //Collect MSB
SPI_GetChar //Collect LSB
Send CS Output High //Disable ADC

You may possibly need a SPI_PutChar 0x00 before collecting the MSB to clock through the analog conversion.

Without having the hardware here to test it is a little difficult to say that this will perform correctly. However it shouldn't be far off. With maybe a minor tweak here or there you should be up and running.

muxer107
Posts: 8
Joined: Fri Apr 27, 2007 2:39 pm
Contact:

Post by muxer107 »

I wish it was that simple!!!
Take a look at the datasheet for the ADC and you'll see straight away what problems Im facing, Im just a novice and this stuff is slightly above me!

Just wanna say thanks a lot for the reply, tis well appreciated!

Muxer

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:

Post by Benj »

Referring to page 15 of the datasheet.

It just takes two SPI_GetChar operations to perform a capture and clock out of the data. If you construct the program that i mentioned before then you should get the data. It may then take a bit of formatting. eg shifting one bit to the right. this can be done with a calculation icon and >> 1 to shift one place to the right.

muxer107
Posts: 8
Joined: Fri Apr 27, 2007 2:39 pm
Contact:

Post by muxer107 »

Thats the issue I was having! thanks benj, ill give that a go and let you know how it goes.

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re:

Post by AbhijitR »

Hello! Ben

Kindly excuse to dig such an old post but honestly i did not find or you could say understand any relevant top on MCP3201 other then this post.
Benj wrote:
Tue May 22, 2007 3:33 pm

Can you just use the Flowcode SPI component.
May i request you or anyone to prompt me how can i use MCP3201, as i do not find any ADC component (spoon-feeding :D), no doubt it is very easy to use a 12bit ADC chip which is readily available but i want to explore another 4-20mA chip which has got MCP3201 onboard.

Thank you.

Abhi

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Interfacing the Pic16F877A with the MCP3201 12-Bit ADC.

Post by Steve001 »

Hi Abhi
AbhijitR wrote:
Sat Dec 19, 2020 10:48 am
i want to explore another 4-20mA chip which has got MCP3201 onboard.
can you expand on what you are looking for ?

Steve
Success always occurs in private and failure in full view.

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: Interfacing the Pic16F877A with the MCP3201 12-Bit ADC.

Post by AbhijitR »

Hello! Steve

Thanks for your reply.

Yes actually i received one small gadget recently, it is in below link for your reference, this gadget has INA196 to sense the 4-20mA current and also onboard ADC MCP3201, this ADC communicates on SPI, i have copy-paste the description as it is for your knowledge.

I was wondering if i could use a readymade component/macro like other available ADC (AD7680), unfortunately i do not understand what Ben mentioned in the other post to Muxer about using "SPI Component" :(
4-20mA R Click is an add-on board in mikroBUS form factor which serves as a receiver in a 4-20mA current loop standard. It features INA196 current shunt monitor, MCP3201 12-bit ADC as well as TPS61041 DC/DC boost converter. It receives output current (4-20mA) from transmitter and converts it into a voltage (0.4-2V). This voltage is converted into a 12-bit data signal in the MCP3201 A/D converter and sent via mikroBUS™ SPI lines. Together with 4-20mA T Click™ this board forms a complete 4-to-20mA current loop standard. It is designed to use either 3.3V or 5V power supply.
https://www.mikroe.com/4-20ma-r-click

I hope there is some way to read the MCP3201.

Thank you again.

Abhi

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Interfacing the Pic16F877A with the MCP3201 12-Bit ADC.

Post by Steve001 »

Hi Abhi

the MCP3201 is an analogue to digital convertor that measurer's DC Voltages.
Are you looking to read the 4 - 20 mA current ? in this case you will need to convert the current to a voltage first.

you have asked this question in Flowcode V2 & V3 forums when you are active in the V8 forums is this a V2, V3 related question?

some more information on current loops and various measuring techniques can be found here :

https://www.matrixtsl.com/mmforums/view ... =7&t=18048

Steve
Success always occurs in private and failure in full view.

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: Interfacing the Pic16F877A with the MCP3201 12-Bit ADC.

Post by AbhijitR »

Hello! Steve
good morning
Steve001 wrote:
Sun Dec 20, 2020 9:06 pm
the MCP3201 is an analogue to digital convertor that measurer's DC Voltages.
Yes absolutely, MCP3201 is a ADC chip which will measure the output voltage from INA196.
Steve001 wrote:
Sun Dec 20, 2020 9:06 pm
Are you looking to read the 4 - 20 mA current ? in this case you will need to convert the current to a voltage first.
Yes you got me right i need to read 4-20mA current from a pressure transmitter or any sensor which outputs 4-20mA signal, for that purpose INA196 do the work of sensing the current and it outputs voltage 0.4V to 2V for corresponding 4-20mA, in this particular gadget which i posted earlier, this is then feed to MCP3201.
Steve001 wrote:
Sun Dec 20, 2020 9:06 pm
you have asked this question in Flowcode V2 & V3 forums when you are active in the V8 forums is this a V2, V3 related question?
Kindly excuse me if i have posted or continued on a wrong version, is that okay if i start a new topic in V8 forum? kindly advise.

My concern is, is it possible to read the ADC from MCP3201 same like the existing component in FC8 AD7680, kindly excuse for posting on wrong version forum though i am a user of V8.

Thanks for the help topic.

Abhi

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Interfacing the Pic16F877A with the MCP3201 12-Bit ADC.

Post by Steve001 »

Hi Abhi
Abhi wrote:
Mon Dec 21, 2020 10:22 am
Kindly excuse me if i have posted or continued on a wrong version, is that okay if i start a new topic in V8 forum? kindly advise.
You will get better and more current advise in the V8 Forums

Steve
Success always occurs in private and failure in full view.

Post Reply