PDA

View Full Version : URM37 and Picbasic



swingeyp
- 13th September 2010, 22:16
Hello. Can anyone help me please.

I have the URM37 Ultrasonic sensor and im desperately trying to talk to it with a PIC16f648A and pic basic. I have to admit it's a competitors flavour but the principle should be the same.

I have the device wired as :

URM37 pin 8 - RXD to PIC pin 2 - RA3
URM37 pin 9 - TXD to PIC pin 3 - RA4

Its also set to TTL mode.

I have no idea what command im supposed to be sending.
11+00+00+11 (temperature - command+highbyte+lowbyte+sum) according to the manual.

Is that 11 or #11 or 0x11 or what? - I've ried em all :-(

Can anyone please save my sanity.

Regards - Paul

rsocor01
- 14th September 2010, 08:00
From your code


readserial:
'serial setting of port rate: 9600; parity: none; stop Bit: 1'
Serin PORTA.4, 9600, datain
Return

RA.4 is an open drain pin. Try using another pin or use a pullup resistor.


I have no idea what command im supposed to be sending.
11+00+00+11 (temperature - command+highbyte+lowbyte+sum) according to the manual.

Is that 11 or #11 or 0x11 or what? - I've ried em all :-(


These numbers are in HEX according to the datasheet.

Also, there is a note in red in the datasheet that says

1. PWN_ON must be set to High to enable sensor.

I hope this helps :).

Robert

swingeyp
- 15th September 2010, 09:55
Yeah I have read the manual over and over and over. Its not very imformative really.

I see the red PWM must be on and have tried that also in my early expirements.

I can get the unit to work with the supplied software connected via RS232 to the PC.

I have found no one in any forum that has this device working with TTL on a pic though.

I was told tha the unit sends and receives single byte data but how do I get 11+00+00+11 to be single byte? - Doesn't that just make it 11?

Here's a reply from the guy that wrote the PC RS232 software.


I did miss lead you somewhat, sorry about that.

That data you see on your lcd display is really single byte data. this will need to be converted
to something useful for you like hex, decimal etc,etc.

So when I send : 11 00 00 11 it is a string that was entered by the program user, I then covert that string into single byte data and send this to the sensor. It is sent to the sensor as one chunk of data.

It is not sent as ascii, hex, decimal or the likes. that: 11000011 is converted into single byte data that the sensor can understand, based on rs232 protocol.

So the manual is correct in stating to send it as: 0x11+0x00+0x00+0x11 In my case when I sent it out like the manual stated, it would not work. my program had to convert it to single byte data for the sensor to read it.

So, I'm guessing it is the programmer's job to convert it. so I created in integer in the program to hold that.

I took the 11 and converted it, then the 00, then the 00, then the 11 and stored it in this integer.
That integer is what is sent out of the comport, not the 11 00 00 11.

It's the same when the data comes back I take all the data from the sensor and store it as an integer, then convert that integer into usable data for for us to see.
Maybe because its TTL that 11000011 should be pulsed as high low low high. Who knows ...

Regards - Paul

aratti
- 19th September 2010, 10:11
Paul

Tray in this way:

YourVariable VAR BYTE

YourVariable = %11000011

Since 11+00+00+11 is an 8 bits binary number.

Cheers

Al.