Discussion in "PIC Microcontroller Discussion" started by    Anup Teke    Jul 21, 2014.
Mon Jul 21 2014, 03:38 AM
#1
Dear All,

I'm working on a project where I want to read DC Battery charging discharging Current from a shunt. For that I'm using MCP3901(it has differential input plus 24 bit resolution) and PIC18F46K22. I'm using Hi-Tech compiler demo and its SPI library. Reading and writing in to all internal registers is going well but when i read ADC Data registers (applied voltage at inputs is 5V ref is 2.37V) it should give me 0x7FFFFF i.e. full scale reading. But its giving me 0x7F7F7F. What should be the problem.

Kindly help me out.
Mon Jul 21 2014, 04:06 PM
#2
That MCP3901 is a very complicated chip.
I have no idea what some of its settings do !
I'd advise you to use a simpler device, or use the ADC built into the 18F46K22.

A 10 bit resolution may not seem much compared to 24,
but I believe it is good enough in practise.

The 18F46K22 has many channels, so you could scale inputs with external
amplifiers to get good results.


[ Edited Mon Jul 21 2014, 06:48 PM ]
Tue Jul 22 2014, 01:54 AM
#3
are you sure your read is working properly? I mean you're not getting first byte again and again.
Tue Jul 22 2014, 02:19 AM
#4
Wed Jul 23 2014, 03:28 AM
#5
Sir,

I was doing like this

MCP3901_CS = 0;
WriteSPI1(0x01);
TempData = ReadSPI1( );
TempData <<= 8;
TempData |= ReadSPI1( );
TempData <<= 8;
TempData |= ReadSPI1( );
MCP3901_CS = 1;

and my problem solved by doing like this

MCP3901_CS = 0;

WriteSPI1(0x01);
TempData = ReadSPI1( );
TempData <<= 8;
MCP3901_CS = 1;

MCP3901_CS = 0;

WriteSPI1(0x03);
TempData |= ReadSPI1( );
TempData <<= 8;
MCP3901_CS = 1;

MCP3901_CS = 0;

WriteSPI1(0x05);
TempData |= ReadSPI1( );

MCP3901_CS = 1;
Thu Jul 24 2014, 12:57 AM
#6
I really do not understand why are you reading register 1, 3 and 5 register 1 belongs to CH0 and 3,5 belongs to CH1. I think you should read chapter 6.7 of datasheet for reading in continuous mode.
Thu Jul 24 2014, 01:08 AM
#7
Ajay Sir,

CHannel 0 Register is 24 Bit. it register address is from 0x00 to 0x02. To read any register we have to send command with first bit 1(Read Bit). so to read CH0 register address will be 0x01 (MSB)
0x03(Middle Byte)
0x05(LSB).
Fri Jul 25 2014, 05:32 PM
#8
I get it now.. Did not read that part, sorry for misunderstanding.

Get Social

Information

Powered by e107 Forum System

Conversation

Wed Mar 25 2020, 09:39 AM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 06:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 08:55 AM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 12:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 11:58 AM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 05:12 AM
Pearl Olin
Hello,
Wed Jan 22 2020, 01:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 02:08 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me
Tue Dec 17 2019, 08:44 AM
Devangi
hello..i am programming industrial timer using 8051 with 24lc64 eeprom. i have query in storing the 3 diff value in eeprom with enter button. can anyone share c code ?
Tue Dec 17 2019, 05:30 AM
Andrius
Hello. Can anyone share the code in Bascon and scheme in Proteus?

Downloads

Comments

ukkorikerist
Thu Apr 09 2020, 12:05 AM
Oswaldrib
Wed Apr 08 2020, 11:08 PM
Rachelsig
Wed Apr 08 2020, 04:57 PM
Franksig
Wed Apr 08 2020, 03:38 AM
OliverKiz
Mon Apr 06 2020, 07:54 PM
Nikolaynom
Mon Apr 06 2020, 09:13 AM
Paulinewop
Sun Apr 05 2020, 10:33 PM
NormanJeops
Sun Apr 05 2020, 03:26 AM

Online

Guests: 37, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 01:37 AM

Members: 38149
Newest member: ukkorikerist
Forum Activity
PHANTOM28 Avatar
Posted By PHANTOM28
Fri Feb 28 2020, 10:25 AM
Hi.I hope you all can help me. I am relatively ne...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 21 2020, 05:05 PM
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Feb 21 2020, 04:45 AM
Yes you can do that.1. Create a channel @Thingspea...
ananyagupta Avatar
Posted By ananyagupta
Thu Feb 20 2020, 03:58 AM
With regards to the particular characters sent to ...
sarrahjuzar Avatar
Posted By sarrahjuzar
Wed Feb 19 2020, 04:24 AM
I have a gsm module sim900a and dht22 connected to...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Feb 18 2020, 04:52 PM
figureyang Avatar
Posted By figureyang
Tue Feb 18 2020, 04:59 AM
figureyang Avatar
Posted By figureyang
Tue Feb 18 2020, 04:50 AM
wounder Avatar
Posted By wounder
Mon Feb 10 2020, 03:32 AM
From below sample code for nuvoton 8051 timer0 mod...
Just4Fun Avatar
Posted By Just4Fun
Sat Feb 01 2020, 09:20 AM
If you want to use a CH55x MCU there isn't any adv...