EmbeddedRelated.com
Forums

regarding srf08(ultrasonic sensor) comm prob with lpc2138

Started by Viren Dobariya March 17, 2009
Yes, sounds OK. Now after 65 ms timeout you should READ (ADDRESS+R) the device. Two bytes (in big endian) should tell you the range.

--- In l..., Viren Dobariya wrote:
>
> hi,
> in my interrupt routine of srf08,
> 1)in the case 0x08: i am writing 0xE0(I2cAddress of srf08)
>
> 2)in the case 0x18: i am writing 0x00(reg addr of srf08)
> 3)in the case 0x28: i am writing 0x51(to define range)
> and I2CONSET = 0X10 (stop condition)
>
> so,i move out from interrupt routine.
> now i generate delay of 65ms using timer,but it is outside the i2c interrupt routine.
> uptil now is it ok??
> please tell me,so i can go ahead.
> datasheet of srf08 is attached.
>
> thanks
>
> ________________________________
> From: this_ip_address
> To: l...
> Sent: Friday, 20 March, 2009 12:47:59 AM
> Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138
> I really don't have time to debug your code, but it looks to me
> that your I2C states screwed up. Roghly, this thing should work
> like below. You should see states in this sequence. If not
> something went wrong. You need an additional timer interrupts
> to (1) define ranging frequency and (2) define ranging time interval
> on state 5.
>
> 1. State 0x00
> Prepare I2C to master transmitter mode.
> Issue start condition.
>
> 2. State 0x08
> Send ADDRESS+W
>
> 3. State 0x18
> Write register address - 0 in simplest case.
>
> 4. State 0x28
> Write command. Indicate end of data
>
> 5. Wait for ranging complete
> This depends on gain and ranging registers.
> Default 65 ms. If you try to read before sonar finished
> ranging, you will get I2C error.
>
> 6. You should be in master read mode. Issue START.
>
> 7. State 0x10
> Send ADDRESS+R
>
> 8. State 0x40
> Response started. Send ACK
>
> 9. State 0x50
> First byte
>
> 10. State 0x58
> Second byte. Stop. Return result to user.
>
> 11. Timeout before next ranging.
> Go to 1.
>
> --- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
> >
> > i am using keil uvision3.
> > i am using lpc21xx.h provided by keil compiler
> > yes i have logic analayzer.
> > no, i never tried eeprom of i2c.how can i use it??
> >
> > data sheet of srf08 is attached with this mail
> >
> > thanks
> >
> >
> >
> >
> > ____________ _________ _________ __
> > From: donhamilton2002
> > To: lpc2000@yahoogroups .com
> > Sent: Wednesday, 18 March, 2009 5:59:21 PM
> > Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138
> >
> >
> > --- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
> > >
> > > hi,
> > > see the code of sfr08..
> > > and guide me.
> >
> > What compiler are you using ?
> >
> > What ..h files are you using ?
> >
> > What exactly are you seeing ?
> >
> > Do you have a O'scope or logic analyzer ?
> >
> > Have you tried an I2C EEPROM ?
> >
> > Do you have a data sheet for the sft08 ?
> > ( please link to it )
> >
> > don
> >
> >
> >
> >
> >
> > Unlimited freedom, unlimited storage. Get it now, on http://help. yahoo.com/ l/in/yahoo/ mail/yahoomail/ tools/tools- 08.html/
> >
> >
> >
>
> Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
>
>
>

An Engineer's Guide to the LPC2100 Series

After 65 ms delay,
now, i want to read the data from location 2 and 3 of srf08.
can u tell me, how can i read these two locations??

Thanks

________________________________
From: this_ip_address
To: l...
Sent: Friday, 20 March, 2009 11:48:55 PM
Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138
Yes, sounds OK. Now after 65 ms timeout you should READ (ADDRESS+R) the device. Two bytes (in big endian) should tell you the range.

--- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
>
> hi,
> in my interrupt routine of srf08,
> 1)in the case 0x08: i am writing 0xE0(I2cAddress of srf08)
>
> 2)in the case 0x18: i am writing 0x00(reg addr of srf08)
> 3)in the case 0x28: i am writing 0x51(to define range)
> and I2CONSET = 0X10 (stop condition)
>
> so,i move out from interrupt routine.
> now i generate delay of 65ms using timer,but it is outside the i2c interrupt routine.
> uptil now is it ok??
> please tell me,so i can go ahead.
> datasheet of srf08 is attached.
>
> thanks
>
> ____________ _________ _________ __
> From: this_ip_address
> To: lpc2000@yahoogroups .com
> Sent: Friday, 20 March, 2009 12:47:59 AM
> Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138
> I really don't have time to debug your code, but it looks to me
> that your I2C states screwed up. Roghly, this thing should work
> like below. You should see states in this sequence. If not
> something went wrong. You need an additional timer interrupts
> to (1) define ranging frequency and (2) define ranging time interval
> on state 5.
>
> 1. State 0x00
> Prepare I2C to master transmitter mode.
> Issue start condition.
>
> 2. State 0x08
> Send ADDRESS+W
>
> 3. State 0x18
> Write register address - 0 in simplest case.
>
> 4. State 0x28
> Write command. Indicate end of data
>
> 5.. Wait for ranging complete
> This depends on gain and ranging registers.
> Default 65 ms. If you try to read before sonar finished
> ranging, you will get I2C error.
>
> 6. You should be in master read mode. Issue START.
>
> 7. State 0x10
> Send ADDRESS+R
>
> 8. State 0x40
> Response started. Send ACK
>
> 9. State 0x50
> First byte
>
> 10. State 0x58
> Second byte. Stop. Return result to user.
>
> 11. Timeout before next ranging.
> Go to 1.
>
> --- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
> >
> > i am using keil uvision3.
> > i am using lpc21xx.h provided by keil compiler
> > yes i have logic analayzer.
> > no, i never tried eeprom of i2c.how can i use it??
> >
> > data sheet of srf08 is attached with this mail
> >
> > thanks
> >
> >
> >
> >
> > ____________ _________ _________ __
> > From: donhamilton2002
> > To: lpc2000@yahoogroups .com
> > Sent: Wednesday, 18 March, 2009 5:59:21 PM
> > Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138
> >
> >
> > --- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
> > >
> > > hi,
> > > see the code of sfr08..
> > > and guide me.
> >
> > What compiler are you using ?
> >
> > What ..h files are you using ?
> >
> > What exactly are you seeing ?
> >
> > Do you have a O'scope or logic analyzer ?
> >
> > Have you tried an I2C EEPROM ?
> >
> > Do you have a data sheet for the sft08 ?
> > ( please link to it )
> >
> > don
> >
> >
> >
> >
> >
> > Unlimited freedom, unlimited storage. Get it now, on http://help. yahoo.com/ l/in/yahoo/ mail/yahoomail/ tools/tools- 08.html/
> >
> >
> > Add more friends to your messenger and enjoy! Go to http://messenger. yahoo.com/ invite/
>
>
>

Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/



--- In l..., Viren Dobariya wrote:
>
> After 65 ms delay,
> now, i want to read the data from location 2 and 3 of srf08.
> can u tell me, how can i read these two locations??
>
> Thanks

The problem with the SRF08 and I2C in general is that it is time consuming to write the code. Nobody is going to do that for you.

There are examples all over the Internet but they are probably not specific to the LPC2138.

You may find the I2C code in jc wren's sample code useful: www.jcwren.com/arm It is for the LPC2148 so it will probably work. But it isn't specific to the SRF08.

There is example code, directly to the point of reading distance using the SRF08 but it isn't for an ARM. Nevertheless, you can adapt it if you don't mind using polled code. See http://www.bdmicro.com/code/srf08/ It is SPECIFIC to what you are trying to do.

You can also try: http://www.robot-electronics.co.uk/htm/using_the_i2c_bus.htm It has, at the bottom of the page, an example of reading the SRF08. It is written for a PIC and it is bit-banged but the flow is correct.

Richard

After 65 ms delay,
now, i want to read the data from location 2 and 3 of srf08.
can u tell me, how can i read these two locations??

Thanks

____________ _________ _________ __
From: this_ip_address
To: lpc2000@yahoogroups .com
Sent: Friday, 20 March, 2009 11:48:55 PM
Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138

Yes, sounds OK. Now after 65 ms timeout you should READ (ADDRESS+R) the device. Two bytes (in big endian) should tell you the range.

--- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
>
> hi,
> in my interrupt routine of srf08,
> 1)in the case 0x08: i am writing 0xE0(I2cAddress of srf08)
>
> 2)in the case 0x18: i am writing 0x00(reg addr of srf08)
> 3)in the case 0x28: i am writing 0x51(to define range)
> and I2CONSET = 0X10 (stop condition)
>
> so,i move out from interrupt routine.
> now i generate delay of 65ms using timer,but it is outside the i2c interrupt routine..
> uptil now is it ok??
> please tell me,so i can go ahead.
> datasheet of srf08 is attached.
>
> thanks
>
> ____________ _________ _________ __
> From: this_ip_address
> To: lpc2000@yahoogroups .com
> Sent: Friday, 20 March, 2009 12:47:59 AM
> Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138
> I really don't have time to debug your code, but it looks to me
> that your I2C states screwed up. Roghly, this thing should work
> like below. You should see states in this sequence. If not
> something went wrong. You need an additional timer interrupts
> to (1) define ranging frequency and (2) define ranging time interval
> on state 5.
>
> 1. State 0x00
> Prepare I2C to master transmitter mode.
> Issue start condition.
>
> 2. State 0x08
> Send ADDRESS+W
>
> 3.. State 0x18
> Write register address - 0 in simplest case.
>
> 4. State 0x28
> Write command. Indicate end of data
>
> 5.. Wait for ranging complete
> This depends on gain and ranging registers.
> Default 65 ms. If you try to read before sonar finished
> ranging, you will get I2C error.
>
> 6. You should be in master read mode. Issue START.
>
> 7. State 0x10
> Send ADDRESS+R
>
> 8. State 0x40
> Response started. Send ACK
>
> 9. State 0x50
> First byte
>
> 10. State 0x58
> Second byte. Stop. Return result to user.
>
> 11. Timeout before next ranging.
> Go to 1.
>
> --- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
> >
> > i am using keil uvision3.
> > i am using lpc21xx.h provided by keil compiler
> > yes i have logic analayzer.
> > no, i never tried eeprom of i2c.how can i use it??
> >
> > data sheet of srf08 is attached with this mail
> >
> > thanks
> >
> >
> >
> >
> > ____________ _________ _________ __
> > From: donhamilton2002
> > To: lpc2000@yahoogroups .com
> > Sent: Wednesday, 18 March, 2009 5:59:21 PM
> > Subject: [lpc2000] Re: regarding srf08(ultrasonic sensor) comm prob with lpc2138
> >
> >
> > --- In lpc2000@yahoogroups .com, Viren Dobariya wrote:
> > >
> > > hi,
> > > see the code of sfr08..
> > > and guide me.
> >
> > What compiler are you using ?
> >
> > What ..h files are you using ?
> >
> > What exactly are you seeing ?
> >
> > Do you have a O'scope or logic analyzer ?
> >
> > Have you tried an I2C EEPROM ?
> >
> > Do you have a data sheet for the sft08 ?
> > ( please link to it )
> >
> > don
> >
> >
> >
> >
> >
> > Unlimited freedom, unlimited storage. Get it now, on http://help. yahoo.com/ l/in/yahoo/ mail/yahoomail/ tools/tools- 08.html/
> >
> >
> > Add more friends to your messenger and enjoy! Go to http://messenger. yahoo.com/ invite/
>
>
>

Add more friends to your messenger and enjoy! Go to http://messenger. yahoo.com/ invite/



Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/