Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Serial Communications Failing (COM Port)


apoerschke Apr 26, 2012 06:05 PM

I have a CS1000 logger which I am using to poll a basic CO2 meter using one of the COM ports. So far I have found a lot of help in this forum getting the data logger to send out a command, and receive a response using TTL levels. The logger sends 7 bytes (including a null character), and receives 5-6 bytes containing the data (using SerialinBlock). I have successful been able to convert this string to ASCII values, and ultimately the sensor reading (Temp, R/H, and CO2).

My problem arises as I am attempting to incorporate this program into another program which monitors 3 flow meters, and a number of thermocouples. When I combine the code for both, the serial I/O no longer works. I have troubleshot the program to the point that I discovered simply adding the variable definitions for the second program into the CO2 meter's program halts serial I/O. Remove the definitions and things work fine. All totalled, there are less than 100 variables (including separate values in arrays).

Is there a known issue with increasing the number of variables beyond a point that causes serial I/O to not work? Any light that someone could shed on the issue would be appreciated! Let me know if posting code would help!


aps Apr 27, 2012 10:02 AM

Can you please post your program here as what you are saying should not happen and you should not be hitting any limit of the logger with the number or sensors/variables mentioned.


apoerschke Apr 27, 2012 02:00 PM

Here is my program as it runs and receives data from the sensor. This is the program I am adding to, and when adding a few variables, the serial in communications seem to fail. The program is at least attempting to send the stream as the 'I' counter changes from 8 to 9. Also to note, I send each command twice as the sensor's listening port seems to fall asleep otherwise.

Thank you for the help. So far I've been able to figure everything out from other posts, but now I've hit a wall!

SequentialMode


'Declare Variables and Units
Public BattV
Public Returned
'Public command As String
Public I
Public SAMP(8) As Long ={&hFE000000, &h41000000, &h00000000, &h60000000, &h01000000, &h35000000, &hE8000000, &h53000000}
Public TXC(7) As Long = {&hFE000000, &h44000000, &h00000000, &h08000000, &h02000000, &h9f000000, &h25000000}
Public TXT(7) As Long = {&hFE000000, &h44000000, &h00000000, &h12000000, &h02000000, &h94000000, &h45000000}
Public TXH(7) As Long = {&hFE000000, &h44000000, &h00000000, &h14000000, &h02000000, &h97000000, &hE5000000}
Public RXC As String * 20, RXT As String *10, RXH As String *10, RX As String *20
Public Bytes(7) As Long
Public Temp,RH,CO2

'Main Program
BeginProg

SerialOpen(COM2,9600,16,0,1000)

Scan(30,Sec,3,0)
'Default Datalogger Battery Voltage measurement BattV


'Read Temp Data_________________________________________________
SerialFlush(COM2)


For I = 1 To ArrayLength (TXT())
SerialOutBlock (COM2,TXT(I),1)
Next I

Delay(0,900,msec)

For I = 1 To ArrayLength (TXT())
SerialOutBlock (COM2,TXT(I),1)
Next I

Delay(0,60,msec)
'SerialInRecord(COM2,RX,0,7,0,Returned,01)
SerialInBlock(COM2,RXT,7)

'Convert string to bytes
Bytes(1) = ASCII(RXT(1,1,1))
Bytes(2) = ASCII(RXT(1,1,2))
Bytes(3) = ASCII(RXT(1,1,3))
Bytes(4) = ASCII(RXT(1,1,4))
Bytes(5) = ASCII(RXT(1,1,5))
Bytes(6) = ASCII(RXT(1,1,6))
Bytes(7) = ASCII(RXT(1,1,7))
'Convert RX to numeric
Temp = (Bytes(3)*256 + Bytes(4))/100

'Read Relative Humidity Data_________________________________________________
SerialFlush(COM2)


For I = 1 To ArrayLength (TXH())
SerialOutBlock (COM2,TXH(I),1)
Next I

Delay(0,200,msec)

For I = 1 To ArrayLength (TXH())
SerialOutBlock (COM2,TXH(I),1)
Next I

Delay(0,60,msec)
'SerialInRecord(COM2,RX,0,7,0,Returned,01)
SerialInBlock(COM2,RXH,7)

'Convert string to bytes
Bytes(1) = ASCII(RXH(1,1,1))
Bytes(2) = ASCII(RXH(1,1,2))
Bytes(3) = ASCII(RXH(1,1,3))
Bytes(4) = ASCII(RXH(1,1,4))
Bytes(5) = ASCII(RXH(1,1,5))
Bytes(6) = ASCII(RXH(1,1,6))
Bytes(7) = ASCII(RXH(1,1,7))
'Convert RX to numeric
RH = (Bytes(3)*256 + Bytes(4))/100

'Read CO2 Data_________________________________________________
SerialFlush(COM2)


For I = 1 To ArrayLength (TXC())
SerialOutBlock (COM2,TXC(I),1)
Next I

Delay(0,900,msec)

For I = 1 To ArrayLength (TXC())
SerialOutBlock (COM2,TXC(I),1)
Next I

Delay(0,60,msec)
'SerialInRecord(COM2,RX,0,7,0,Returned,01)
SerialInBlock(COM2,RXC,7)

'Convert string to bytes
Bytes(1) = ASCII(RXC(1,1,1))
Bytes(2) = ASCII(RXC(1,1,2))
Bytes(3) = ASCII(RXC(1,1,3))
Bytes(4) = ASCII(RXC(1,1,4))
Bytes(5) = ASCII(RXC(1,1,5))
Bytes(6) = ASCII(RXC(1,1,6))
Bytes(7) = ASCII(RXC(1,1,7))
'Convert RX to numeric
CO2 = (Bytes(3)*256 + Bytes(4))

'Write Sample Command Sequence_________________________________________________
SerialFlush(COM2)


For I = 1 To ArrayLength (SAMP())
SerialOutBlock (COM2,SAMP(I),1)
Next I

Delay(0,900,msec)

For I = 1 To ArrayLength (SAMP())
SerialOutBlock (COM2,SAMP(I),1)
Next I

Delay(0,60,msec)
'SerialInRecord(COM2,RX,0,7,0,Returned,01)
SerialInBlock(COM2,RX,7)

'Convert string to bytes
Bytes(1) = ASCII(RX(1,1,1))
Bytes(2) = ASCII(RX(1,1,2))
Bytes(3) = ASCII(RX(1,1,3))
Bytes(4) = ASCII(RX(1,1,4))
Bytes(5) = ASCII(RX(1,1,5))
Bytes(6) = ASCII(RX(1,1,6))
Bytes(7) = ASCII(RX(1,1,7))
'Convert RX to numeric

SerialFlush(COM2)
NextScan

EndProg


aps Apr 27, 2012 03:41 PM

Can you show us what you added and where that causes it to break, please.


apoerschke Apr 27, 2012 03:51 PM

I pasted these additional variables directly below the sequential mode command, and above the previously defined variables.


Public PTemp_C
Public Temp_F(6)
Public Temp_C(6)
Public Zone_C(8)
Public Spec(3)
Public Rho(3)
Public Pulse(3)
Public GPM(3)

Adding just one or two variables doesn't seem to have an effect. Adding all of these caused the program to get no response from the serial device. As a note, there did seem to be a grey area, where adding say 4 variables caused one of the serial responses to fail, but the others to work. I monitor this by watching the 7 "bytes()" variables change, and also watching the converted "Temp", "RH", and "CO2" values. Again, while the program is running, the output control variable "I" does change(8 to 9), indicating the output is at least attempting to run.


aps Apr 30, 2012 10:44 AM

I did some quick tests of this and could not reproduce any problem. What version of logger operating system are you running? Can you try the latest if you are not using it, downloadable from this website (under support, downloads).


apoerschke May 9, 2012 02:05 PM

I am using the latest OS (v24). Upgrading to this OS was one of the things I did in troubleshooting. I am going to experiment with this some more and see if I can better narrow down the exact cause of the COM failure.


apoerschke May 10, 2012 06:39 PM

I am using version 24 of the operating system. This was one of the things I checked (and upgraded from version 23). I am doing some more testing, and getting inconsistent results, which leads me to believe the issues I am seeing, are a result of the sensor. Sometimes I get a response, sometimes not. Right now I am going to fiddle with the timing and see if I can get a consistent response.

Log in or register to post/reply in the forum.