Serial Port

ceaser

Active Member
Licensed User
Hi

I wonder if somebody can tell me what is wrong with the following code::sign0085:

Sub Button2_Click
If Button2.Text="Read" Then
Label70.Left=3
DoEvents
If Main.PortOpen=0 Then
OpenPort
End If
If Main.PortOpen=1 Then
Button2.Text="Stop"
ReadStation("u")
End If
Else
Label70.Left=300
Button2.Text="Read"
End If
End Sub

Sub Button1_Click
Label70.Left=300
PolarFix.Close
End Sub

#End Region

#Region *********************************** Read Total Stations

Sub OpenPort
WaitCursor(True)
EndLine=Chr(13) & Chr(10)
su(1)="t" :su(2)="u" :su(3)="c" :su(4)=""
Serial1.New1
If Main.DF(3)=1 Then
'Leica
ErrorLabel(ConnectGPS_Err)
If Main.DF(4)<9 Then
Serial1.New2(Main.DF(32),2400,"E",7,2)
Else
Serial1.New2(Main.DF(32),2400,"E",7,1)
End If
End If
Serial1.PortOpen = True
Main.PortOpen=1
IntPort
Return
ConnectGPS_Err:
WaitCursor(False)
Msgbox("Error Opening Port: " & Main.DF(32),"Port Error",cMsgboxOK,cMsgboxHand)
Main.PortOpen=0
Label70.Left=300
End Sub

Sub IntPort
If Main.DF(3)=1 Then
'Leica Total Station
Serial1.Output("a" & EndLine)
Serial1.Output("?" & EndLine)
Serial1.Output("DSP/0/0/$METERS" & EndLine)
Serial1.Output("SET/476/2" & EndLine)
Serial1.Output("DSP/0/0/$SERIAL" & EndLine)
End If
WaitCursor(False)
End Sub

Sub ReadStation(R)
Dim Stcm

If Main.DF(3)=1 Then
'Leica Total Station
If Main.DF(4)>=3 Then ' t500,t1010,t1610
If R="u" Then
stcm="GET/M/WI11/WI21/WI22/WI31"
Else If R="t" Then
stcm="GET//WI11/WI21/WI22"
If Main.DF(4)=3 OR Main.DF(4)=9 Then
Serial1.Output("SET/160/0" & EndLine)
End If
End If
Serial1.Output(stcm & EndLine)
Else
Serial1.Output(R & EndLine)
End If
End If
End Sub

These are codes that I am trying to send to a Total Station (Survey Equipment) to read the angles and distance to a prism. I use the same code on a Workabout (from Psion) and it works! But on my Recon it does nothing! It does not even turn the total station on:sign0148:

Regards
Michael
 

agraham

Expert
Licensed User
Longtime User
Looks OK at first sight to me. Does the Total Station need DTR and/or RTS asserted?

Serial1.DTREnable = True
Serial1.RTSEnable = True

I assume that Main.DF(32) contains an integer like "3" and not something like "COM3" and that you have checked the pinouts match of the Recon and the Total Station.

By the way "Serial.New1" is superflous (EDIT:- or maybe not - I can't immediately see without indentation!) and "Endline" is the same as the Basic4ppc constant "CRLF"
 
Last edited:

ceaser

Active Member
Licensed User
Hi Agraham

You are right "Main.DF(32)" is the port that I selected under the "Parameter Setup" in the main module. On my Recon I have 2 ports, Com 0 which is my RS232 port and to which my cable to the Total Station is connected and then I have a USB port which is Com 1. I have checked with a "Msgbox", "Main.DF(32) shows "0", ie my RS232 port.

What I cannot understand is that it does not even switch the Total Station on. I have used the same cable on the Workabout with my older program and it works. So it cannot be the cable.

Any ideas?:sign0085::sign0085:

Regards
Michael
 

agraham

Expert
Licensed User
Longtime User
What I cannot understand is that it does not even switch the Total Station on.
If it is turned off is activity on the Serial Port of your Total Station supposed to automatically turn it on or is it not actually off but in a standby mode?

You didn't answer my original question :( so here it is again. Have you checked that it doesn't need DTR and RTS enabled, their presence might concievably turn it on? Does it need any form of flow control for its serial port to work?

I have used the same cable on the Workabout with my older program and it works. So it cannot be the cable
Not necessarily. You also didn't answer this question :( so here it is again. Have you checked that the pinout of the Recon is the same as that of the Psion. Serial cables come in straight through and cross-over flavours.

Does the Serial Port of your Recon work OK with other kit? Have you tried a loopback (connect pins 2 and 3) test in Basic4ppc to check that you are actually driving the port OK?
 

ceaser

Active Member
Licensed User
Any activity at the serial port on the Total Station, will switch the Total Station on. This is not true for all makes of Total Stations.ie the Total Stations from China do not do it.

I have included "DTR" and "RTS" in my program, but still no reaction.

I will contact Trimble tomorrow regarding the pins on the RS232 port.

Regards
Michael
 

ceaser

Active Member
Licensed User
Problem Solved!!:sign0060::sign0060:

In my main module under "System Parameters" where I display all the ports available, I use a combobox to list them all. By selecting the first item in the combobox, it returns "0". In my "Field" module the program then tried to open and use "Com0" and it should be "Com1".

My Total Stations sing like caneries now!

Thanks
Michael
 

Zenerdiode

Active Member
Licensed User
Ah, you beat me to it. I was about to tell you that I have a TDS Recon and assure you that the Serial Port is COM1...
 
Top