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



I2C Line Following sensor help Expand / Collapse
Author
Message
Posted Tuesday, April 26, 2011 10:18 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Tuesday, May 03, 2011 10:55 AM
Posts: 1, Visits: 9
Hi everyone (if there is anyone on this site), I just received my RC I2C Line Sensor and well... Things doesnt go as expected...
I am actually building an autonomous robot which will use, among other sensors, this line detector. This robot is based on the Parallax BASIC Stamp 2p24 microcontroller, so it includes I2C-specific commands like I2CIN.

So, to test the device, I made a testing program which retrieve the data from the sensor and display it on a serial LCD then repeat all over again. This program doesn't work. The only data the program show is always 255, which is only a full byte. I used the BASIC Stamp Manual and Syntax examples and I'm not sure to understand every parameters in this command (I'm an I2C noob, actually. I only have a basic understanding of this protocol).

Here it is (Mostly in french, sorry):

'************ DÉBUT D'ENTÊTE ******************************************
' Nom : I2Ctest
' Créé le : 12 avril 2011
' Modifié le : N/A
' Créé par : Dany B. Drolet
'
' Commentaires:
' Première tentative d'utilisation du protocole I2C.
'
' But:
' Recevoir et afficher graphiquement les données reçues du senseur détecteur de lignes.
'
'
'************** FIN D'ENTÊTE ********************************************

' {$STAMP BS2p}
' {$PBASIC 2.5}

'***************[ IDENTIFICATION I/O ]************************************
FollowerSerin PIN 0
FollowerCLK PIN 1
LeftEncoder PIN 2
RightEncoder PIN 3
MCserin PIN 4
MCreset PIN 5
RightPing PIN 6
CenterPing PIN 7
LeftPing PIN 8
LCDSerin PIN 9
Piezo PIN 10
SW1 PIN 11
SW2 PIN 12
SW3 PIN 13
SW4 PIN 14

'*************[ CONSTANTES ]********************************************

BaudRate CON 240 ' Baud Rate: 9600 = [ bs2 = 84 ] [ bs2p = 240 ]

CmConstant CON 904 ' 2260 for BS2 ; 904 for BS2P
InConstant CON 356 ' 890 for BS2 ; 356 for BS2P

'**************[ VARIABLES ]*********************************************

LFValue VAR Byte

'=======================================================================

'****************[ INITIALISATION ]****************************************

PAUSE 20

SEROUT LCDSerin, BaudRate, [ 22, 17, 12 ]

PAUSE 5

SEROUT LCDSerin, BaudRate, [ 148, "***INITIALISATION***" ]

GOSUB StartSound

SEROUT LCDSerin, BaudRate, [ 12 ]

PAUSE 5

SEROUT LCDSerin, BaudRate, [ 128 ]

'##### DÉBUT DE LA BOUCLE PRICIPALE ####################################

SEROUT LCDSerin, BaudRate, [ 128, "Test suiveur ligne:", 168, "Valeur:" ]

DO
I2CIN 0, $50, 0, [ LFValue ]
SEROUT LCDSerin, BaudRate, [ 177, "%", BIN LFValue ]
LOOP



'########## FIN DE LA BOUCLE PRICIPALE ##################################

GOSUB EndSound
END

'=====================================================================

'###### SOUS-ROUTINES ##############################################

'*************[ SOUS-ROUTINES CONSTANTES ]******************************

ResetMC:
LOW MCReset
PAUSE 2
HIGH MCReset

StartSound:
PAUSE 100
FREQOUT piezo, 566, 796
FREQOUT piezo, 566, 875
FREQOUT piezo, 566, 955
FREQOUT piezo, 566, 849
FREQOUT piezo, 472, 1000
PAUSE 200
RETURN

EndSound: 'A besoin d'être refait
PAUSE 250
FREQOUT piezo, 566, 796
FREQOUT piezo, 472, 875
FREQOUT piezo, 566, 955
FREQOUT piezo, 566, 849
FREQOUT piezo, 472, 1000
RETURN


Thanks anyone for the help!


Ignorance is never better than knowledge

-Enrico Fermi
Post #2099
« Prev Topic | Next Topic »


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

All times are GMT -8:00, Time now is 4:07pm

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0.063. 7 queries. Compression Disabled.