I2C Line Following Sensors Help
Navigates to RoboticsConnection.com Home RoboticsConnection.com HomePage
RoboticsConnection User Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        


««12

I2C Line Following Sensors Help Expand / Collapse
Author
Message
Posted Wednesday, April 23, 2008 10:55 AM


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: Yesterday @ 8:31 AM
Posts: 270, Visits: 396
You can look at our Line Following Example program for our Serializer Lib MF documentation, which shows logic you can use for performing line following.   However, like Ringo pointed out, line following speeds, etc. all depend on the physical robot configuration, which is up to you to figure out and spend time testing.

All the I2C information you need to interface the sensor is on the site for the Line Follower.  You just need to learn/read more about the I2C protocol and your compiler to understand how to query it.

Best Regards,

Jason Summerour
President,
Summerour Robotics Corporation
Microsoft MVP
www.roboticsconnection.com

Post #427
Posted Thursday, April 24, 2008 5:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Thursday, April 24, 2008 5:05 PM
Posts: 8, Visits: 12
do i need the pullup resistors or is it possible that they are already built on to the sensor board becuase it does have a +5V connection too?

this is the program i have tried on the PIC but it does not read the byte ...here i am trying to read the byte from the sensor and display that onto the 8 LEDs i have.....

#include
#include

unsigned int value;

void OpenI2C(unsigned char sync_mode,
unsigned char slew);
unsigned char WriteI2C(
unsigned char data_out);
unsigned char ReadI2C ();
void configure_LEDS(void);
void display_on_LEDS(unsigned char value);

void main() {

TRISCbits.TRISC3 = 1;
TRISCbits.TRISC4 = 1;
SSPCON1bits.SSPEN = 1;

while(1) {
OpenI2C(MASTER, SLEW_ON);
SSPADD = 9;

StartI2C();
WriteI2C(0x50);
WriteI2C(0x01);
RestartI2C();
WriteI2C(0x51);
value = ReadI2C();

display_on_LEDS(value);
}

}

void configure_LEDS(void) {
TRISD = 0x00;
}


can u please give a brief explanation wht i should do ....like wht shud i write to the I2C bus and how can i read that byte from the address location of 0x50 on the sensor?

Thank you
Post #437
Posted Thursday, April 24, 2008 7:57 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Moderators
Last Login: Thursday, July 10, 2008 1:17 PM
Posts: 32, Visits: 47
Your pic18f452 board is the master, so it needs the pullups. Use somehting around 1.5K or 1.8K on the slk and sda lines. without these it will not work at all.

As far as how to read and write it, just look back at my original code I posted and it will tell you.

Ringo Davis

Post #439
Posted Thursday, April 24, 2008 11:12 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Moderators
Last Login: Thursday, July 10, 2008 1:17 PM
Posts: 32, Visits: 47
Something I just thought of.

If you know how to just read an input pin with your compiler, then you could tap into the I/O from the sensors directly. If you look in the middle of the PCB on the opposite side of the board from the pic, you will see a series of header pads. They are labeled A-E and Vcc and Gnd. If you can solder a wire from A to an input on your chip, and from B to an input on your chip, etc, then you can see the I/O directly. When Sensor A sees something that line goes from high to low. You can supply Vcc and ground from those pads, or the I2C header either one.

If you do it this way you don't need to know I2C at all.

Ringo

Ringo Davis

Post #443
Posted Thursday, April 24, 2008 11:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Thursday, April 24, 2008 5:05 PM
Posts: 8, Visits: 12
hi,

that sounds like something good and easy....
jus need to confirm....u mean if i take the sensor and look on the side where the sensors are fixed i see a series of 7 holes in the middle of the board...are they the outputs from the sensors and if I solder them and take those wires to my PIC i will be able to read a 1 or a 0 directly for each sensor?

and could i jus connect vcc and gnd to the ones already given on the sensor board? so no need for any pull up resistors anymore?

Thank you
Post #444
Posted Thursday, April 24, 2008 11:27 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Moderators
Last Login: Thursday, July 10, 2008 1:17 PM
Posts: 32, Visits: 47
You are correct. I put those there when I designed the board, then forgot they were there.

Yes, if you connect Vcc and ground and hold the board up in the air, then put your finger very near 1 of the sensors, you will see the green led light up on the sensor board. when it does the line connected to that sensor goes low (0), move your finger away and the green led goes off and the line goes high (1).

the downside is that you must use 5 I/O lines in stead of just 2 for I2C, but you do not need the pulllup resistors anymore.

Ringo

Ringo Davis

Post #445
Posted Thursday, April 24, 2008 4:14 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Thursday, April 24, 2008 5:05 PM
Posts: 8, Visits: 12
Thank you very much for your kind help Ringo. I tried it this way for one of the sensors and i think it worked but did it in a hurry coz labs were closing at uni so ill try it again tomorrow but hopefully it will work and will let you know of the outcome....

thanks alot!
Post #450
« Prev Topic | Next Topic »

««12

Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: jsummerour, ringo

Permissions Expand / Collapse