Avice Posted September 14, 2012 Share Posted September 14, 2012 Hi, I'm trying to create a device by reading the serial guide tutorial, kind of lost. I dont know where to start. Not a programmer really. My device is a Protek B940 Multimeter using rs232 and connected to pc via a Systembase SerialMultiport to USB. Here's the data from my monitor watch Rx (23:17:26.155): \128\008\007\002\002\138\134\128\132\013\010 \128\008\007\002\002\138\134\128\132\013\010 \128\008\007\002\002\138\134\128\132\013\010 \128\008\007\002\002\138\134\128\132\013\010 \128\005\007\002\002\138\134\128\132\013\010 \128\005\007\002\002\138\134\128\132\013\010 \128\008\007\002\002\138\134\128\132\013\010 \128\008\007\002\002\138\134\128\132\013\010 \128\005\006\002\002\138\134\128\132\013\010 \128\005\006\002\002\138\134\128\132\013\010 \128\000\009\007\001\138\134\128\132\013\010 \128\000\009\007\001\138\134\128\132\013\010 \128\007\006\002\002\138\134\128\132\013\010 \128\007\006\002\002\138\134\128\132\013\010 \128\006\007\002\002\138\134\128\132\013\010 \128\006\007\002\002\138\134\128\132\013\010 \128\000\008\002\002\138\134\128\132\013\010 \128\000\008\002\002\138\134\128\132\013\010 \128\007\007\002\002\138\134\128\132\013\010 \128\007\007\002\002\138\134\128\132\013\010 \128\009\006\002\002\138\134\128\132\013\010 \128\009\006\002\002\138\134\128\132\013\010 \128\008\006\002\002\138\134\128\132\013\010 \128\008\006\002\002\138\134\128\132\013\010 \128\001\007\002\002\138\134\128\132\013\010 \128\001\007\002\002\138\134\128\132\013\010 \128\007\007\002\002\138\134\128\132\013\010 \128\007\007\002\002\138\134\128\132\013\010 \128\001\009\007\001\138\134\128\132\013\010 \128\001\009\007\001\138\134\128\132\013\010 Rx (23:17:27.817): \128\008\007\002\002\138\134\128\132\013\010 \128\008\007\002\002\138\134\128\132\013\010 \128\006\007\002\002\138\134\128\132\013\010 \128\006\007\002\002\138\134\128\132\013\010 \128\009\007\002\002\138\134\128\132\013\010 \128\009\007\002\002\138\134\128\132\013\010 \128\000\008\002\002\138\134\128\132\013\010 \128\000\008\002\002\138\134\128\132\013\010 \128\001\009\007\001\138\134\128\132\013\010 \128\001\009\007\001\138\134\128\132\013\010 thanks in advance Link to comment Share on other sites More sharing options...
AzeoTech Posted September 14, 2012 Share Posted September 14, 2012 There are a number of examples in this forum that you should follow instead of creating a fresh protocol. Just create a sequence to do the work. It looks like you have a protocol that ends in CRLF, so you can use the ReadUntil(10) function to get the line. Something like: device.myDevice.purge()private string datainwhile(1) try datain = device.myDevice.readUntil(10) // parse input catch() delay(0.1) ? strLastError endcatch endwhile[/CODE]That's the general template for devices that stream data over serial and use CRLF as the line delimiter. As for the "parse input" part, that really depends on the protocol and I can't tell just from looking at the data you posted what you need to do. It would help to have that capture with a couple different input readings and telling me what they are. Then I might be able to figure out the protocol. Of course, documentation from the manufacturer would be even better! Link to comment Share on other sites More sharing options...
Avice Posted September 15, 2012 Author Share Posted September 15, 2012 Thank you, attached here's the data from the manufacture manual page. Link to comment Share on other sites More sharing options...
AzeoTech Posted September 15, 2012 Share Posted September 15, 2012 Yeah, that doesn't match what you posted at all. For one thing, the protocol in the docs is pure ASCII. The serial stream you posted is almost entirely binary, except the CR/LF at the end. Second, the docs say there should only be a CR at the end, not an LF. This could be a typo on their part, a common one for sure. But there are two other inconsistancies: 1) the docs say each packet is 14 bytes, but I only see 11 (including the LF), 2) the docs say that the packet is output only when you send it a character, not continuously. So, either the CRLF at the end is coincidence and you actually just have garbage on the line, or you have baud/parity set wrong, or most likely you have the unit in some sort of streaming mode that is described in a different part of your documentation. Link to comment Share on other sites More sharing options...
Avice Posted September 15, 2012 Author Share Posted September 15, 2012 thanks again for the explanation. I can confirm the data receive is not streaming continuously. For your reference here's what I did to add the device. Add new Serial232 device Create new protocol with the following code trigger on Receive if (strIn == Chr(10)) private string dataIn = ReadUntil(10) private string streamData = Mid(dataIn,4,6) Channel.AddValue(strDevice, 0, "Input", 0, Asca(streamData)) Endif I can receive some value with the above code but its not right. from channel table monitor Link to comment Share on other sites More sharing options...
SteveMyres Posted September 18, 2012 Share Posted September 18, 2012 Must be at least a port setting problem and/or the manual is junk. The manual says it's 7-N-2 (consistent with ASCII mode), but there's numbers in there over 127, so either they're being misinterpreted on the PC end for some reason, possibly due to wrong settings (say 8-N-1 and it's using one of the stop bits as a data bit) or the manual is incorrect. Link to comment Share on other sites More sharing options...
AzeoTech Posted September 20, 2012 Share Posted September 20, 2012 Steve and I are saying the same thing. Your manual is totally off. I doubt its a port problem since there is a consistent CRLF at the end of each frame. Do the numbers in the monitor change as you change the sensor? I wouldn't try any script until you can look at the monitor and see the numbers change with the sensor reading. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.