Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16f628A with URM37 V3.2 - PLEASE HELP!

Status
Not open for further replies.

SwingeyP

Member
Can anyone understand how this thing works or give me any pointers please?

I have tried sending the data to the unit as just sum, I have sent the individual parts of the string and I still can't get any joy.

Ultimately I want to read distance with it but for now just to get it going I am trying to read temperature (as that seemed easiest).

I am using a RA3 to TX to the unit, RA4 to RX from the unit, and RA5 will be a toggle for the PWR pin when needed.

I have attached some simple code which sends a command reads the reply and displays the data on an LCD and the datasheet for the URM37.

I am pulling my hair out with this can anyone help me please?
 

Attachments

  • test1.pdf
    7.3 KB · Views: 285
  • URM3.2%20Mannual.pdf
    390.3 KB · Views: 303
Last edited:
Hi. Yes im still having trouble. I can get the unit to work with software on the PC so I know its working ok.

I have asked a few questions in other forums and here's a reply from someone who has been very helpful.

"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."


Im not really sure what im supposed to send to the unit.
I am using a pic16f648a and using pins:

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

I then use the OSHON picbasic to serin and serout. Can it be done this way? DO I need a max232 in line first?

This has been driving me nuts. I guess my lack of electronics know-how is a major contributor to this problem.

Regards - Paul
 
Last edited:
Aha! - This seems to answer a few questions..

maybe I need to set the URM37 to TTL. Apparently connecting one to the other is a definate no no.
 
Yes, if the URM37 pins are connected directly to the PIC pins, it needs to be set for TTL. The good news is that the URM37 should be fine. The PIC on the other hand may be mortally wounded.

There are 2 problems when connecting RS-232 levels to TTL levels. TTL is 0 volts for "low" and 5 volts for "high." RS-232 is 12 volts for "low" and -12 volts for "high"! The +/- 12 volt levels are enough to make a PIC very very dead, but even if that wasn't the case, the signals are "upside-down" so they couldn't possibility be understood correctly.

Some languages, like PIC BASIC PRO, have a "debug" mode to invert signals to fix the upside-down problem, but this only works for a software UART. The PIC hardware UART doesn't support this.
 
sigh. a few days on and im no futher forward at all really. I now have the URM37 wired as before with the jumpers set to TTL and the attached code.

I just cant fathom what im supposed to be sending to the unit. Temperature = 11+00+00+11 (command +high bit + Low bit + sum) according to the manual. (see earlier post for the manual)

What does this actually mean? Do I Send 11 or 0x11 or #11 or what?

If anyone can please solve this mystery I would be very grateful.

Regards - Paul
 

Attachments

  • PIC Simulator IDE.pdf
    7.2 KB · Views: 394
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 08.01.2012 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
Include "modedefs.bas"
DEFINE HSER_BAUD 9600
DEFINE HSER_ CLROERR 1
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
'---------------------------
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 2
DEFINE LCD_LINES 2
DEFINE LCD_BITS 4

TRISB=%00000010
TRISA=%00010000
pause 100




SI var PORTB.0
SII var PORTB.1 ' Serin giriş portu
B0 Var byte
B1 Var byte
B2 Var byte
B3 Var byte
B4 Var byte
sure var word 'Bilginin atanacağı yer


ERCAN:
IF PORTA.4=1 THEN

SEROUT SI,T9600,[34]
SEROUT SI,T9600,[0]
SEROUT SI,T9600,[0]
SEROUT SI,T9600,[34]

Serin SII,T9600,B0

Serin SII,T9600,B1

Serin SII,T9600,B2

Serin SII,T9600,B3
sure.lowbyte=B2
sure.HighByte=B1

pAUSEUS 10
LCDOUT $FE,1
pause 200
LCDOUT dec sure

endif
GOTO ERCAN


pic 16f628A

Sensor setiing TTL Level.
If you press Button, the sensor will recive distance data.
If you want to see temperature data, you must send " 17 0 0 17 " datas.
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top