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

MPU6050 and PIC16F877 with CCS C

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



Joined: 29 Mar 2013
Posts: 2

View user's profile Send private message

MPU6050 and PIC16F877 with CCS C
PostPosted: Sun Mar 31, 2013 6:25 am     Reply with quote

hi Guys! I am making a quadcopter with MPU6050 and PIC16F877. But I dont know how can I connect each other, and I use CCS C as software but I dont do it too. This mpu6050 sensor works with I2C protocol. Can anyone help me about this issue? Wait your helps.. please..!
temtronic



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

View user's profile Send private message

PostPosted: Sun Mar 31, 2013 6:46 am     Reply with quote

Normal things to consider...
1) PIC runs on 5volts, sensor on 3. So you'll need to decide to either replace the PIC with a 3volt rated one or add 'logic level' conversion between them.You might be able to use certain pins of the PIC for interface but choose carefully or 'magic smoke' will come out !

2) Choose the I2C pullups based on speed,distance, and voltage level..

3) Google search the sensor for code/comments/etc. You are NOT the first one using it. Others may have used another language, but see what they've come up with.

4)Ask the mfr of the sensor for 'typical code'. Assuming this is a premade 'module' and not the chip alone, see what the board maker's website has to offer.

5) Learn to use the 'search' engine on this site. Again, others may have used it.

6) Download PCM Programmer's 'I2C diagnostic/scanner' program. Use this to confirm your PIC sees the sensor before you cut any 'copter code'.

7) report back on progress, lots of talent here, but you'll need to show us your code before we can help you further.


hth
jay
Mike Walne



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

View user's profile Send private message

3V to 5V conversion
PostPosted: Sun Mar 31, 2013 7:57 am     Reply with quote

Philips 2000 manual shows this, as a way to deal with 3V & 5V devices on same I2C buss.
MOSFET needs to have threshold voltage <3V.

Apply this fix to both data and clock lines.
All 3V devices to Source side of MOSFET.
All 5V devices to Drain side of MOSFET.

Code:
         3V |                                   5V |
            |--------                              |
            |        |                             |
            >        |                             >
            >      G | N chan MOSFET               >
            >       ______                         >
            |     S |    | D                       | 
 3V device----------      ---------------------------- 5V device
                    |    |
                     -|>-     
               MOSFET parasitic diode

(Please excuse drawing for MOSFET which is not quite accurate)

There are three cases to consider

1) Both devices off.
2) 3V device pulling down.
3) 5V device pulling down.

In all cases, MOSFET Gate held @ 3V.
Bear in mind MOSFET Drain-Source behaves as bidirectional resistor.

Case 1)

3V device pulled up to 3V rail.
MOSFET turned OFF when Source reaches 3V.
MOSET Drain-Source now high impedance.
MOSFET Source held at 3V.
5V device will be pulled up to 5V rail.

Case 2)

3V device pulls Source to 0V.
MOSFET now turned ON with gate @ 3V.
MOSET Drain-Source now low impedance.
3V device pulls 5V device to 0V via MOSFET Drain to Source.

Case 3)

5V device pulls MOSFET Drain to 0V
MOSET Source pulled near to 0V (~0.6V) via parasitic diode.
With Gate @3V, Source ~0.6V MOSET Drain-Source now low impedance.
MOSFET Drain-Source shorts out the parasitic diode.
5V device pulls 3V device to 0V via MOSFET Source-Drain.

Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 31, 2013 9:17 am     Reply with quote

This has already been discussed in the 4-page MPU6050 thread, and
Ttelmah summarizes it in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=48899&start=21
If you have a PIC which has a port which has TTL-compatible inputs,
(such as PortB on a 16F877), then you don't need any 3v to 5v
converter chips. Please go back and read that huge 4-page thread.

With regard to endezya04, it looks like he is another one of the young
people on this forum who doesn't want to read any existing thread,
or links, or data sheets. Then we are supposed to spoon-feed him
all the information all over again. There is another thread like that
currently in progress on the forum.
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