LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read a puls on rs-232

Hi

I'm rather new to LV. I have tried to read a pulse from the rs-232 (com port). But doesn’t succeed.

The pulse is generated from an electricity meter.

Today i have a program (made by others non LV i think) that works it reads the puls and everything is OK.

But now since i need some practicing  (in LV) i would like to make a program by my own.

I started but it doesn’t work.(see atached file) I use LV 9 or 10. The only command i find is the "VISA read".

The other program uses the settings 110,N,8,1 (binary/raw mode). I have tried this not the binary/raw mode (because i don’t quite follow that)

The pulse is 50 ms and should be read as a ASCII code 0xE0 or 0xF0.

 

The connection to the rs-232/comport is really easy se link below. And it works nice with their program but i don’t get any reading of anything, not a byte

http://www.techtrade.se/pictures/EMC-102.gif

 

This is probably me being stupid Smiley Tongue as usually (to low knowledge)

Any one done this or seen anything. I have goggled and search the ni forum without result. Found some small ideas they uses some other serial read

0 Kudos
Message 1 of 18
(6,335 Views)

The RS-232 protocol was not designed to be used like that. It's designed to transmit bytes, not be a digital I/O device. It never ceases to amaze me how many times I see people try to do that. As far as your code is concerned, at a minimum you have to turn off the termination character enable. With that on VISA Read will wait until it see the termination character to stop reading (or if it hits the timeout). Inside the loop you'd want to use the VISA Bytes at Serial Port to drive the number of bytes to read for VISA Read. If there's no bytes available, what's the point in reading?

 

Also, if you just want to display the number you don't need to go through all those gymnastics. Since you are reading only 1 byte (presumably), then you can typecast the string directly to an integer and set the numeric indicator to hex display mode.

 

You said you have a "program made by others that works". Do you have this code? Are they actually trying to read bytes, or are they doing some really low-level operation like going directly to the operating system's serial port driver, or something like that?

Message 2 of 18
(6,319 Views)

Hi

Thanks for the easy convert.

Diden't know that funksion. I'm a n00b to LV . somthing learned Smiley Happy

Tested VISA Bytes at Serial Port diden't show and turn off  termination character.

I don't have the source code Smiley Sad

The only tip on the side was  110,N,8,1 (binary/raw mode), 50 ms puls and that it was possible to make your own in  Windows or unix/linux

Tried the "hyper terminal" and nothing shows there either? But the original program works nice.....

0 Kudos
Message 3 of 18
(6,307 Views)

Hi again

Read some more http://en.wikipedia.org/wiki/Data_Terminal_Ready

This one is used as power driver. I supose i have to activate this to get a signal in.

How can i activate the DTR from LV? Shouldent it be activated when "visa configure serial port" runs????

 

from wiki

Used as a power pin

On some hardware the DTR line (along with RTS) is typically used to provide power. The most notable example of this is a serial mouse. The DE-9 serial port on the PC does not provide any power pins. The mouse driver holds the DTR and RTS lines high at all times so that the mouse may steal power for its own use.

Another category of devices commonly powered by the DTR line includes converters between RS-232 and other serial standards such as RS-422 and RS-485

.

0 Kudos
Message 4 of 18
(6,306 Views)

The whole concept seams somewhat dodgy to me. But I guess your problem is related to the setting of the DRT data line. As I think it is used to power the device. Then you use the EMC software the DTR line is set so it give out a positive voltage. At least according to your schematic in the figure. So the DTR line must be asserted. You should also turn the terminal char option OFF.  I guess you then by counting the numbers of received 0x0e or 0x0f in some time period you can calculate the KWh number.

Se my example. At least now the settings should be correct but I can not say anything about how well it will work.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 5 of 18
(6,299 Views)

Hi

Thanks for the VI with the set DTR state.

Tested  but diden't work.

 

 

Tested to read DTR state ?

It shows even if i first set DTR state to "Asserted" it ends up to be  "unasserted" ?

Why?

 

Measured at the sensor. When the original program runs it has power on DTR pin 4. But when LV runs ther is no power even if DTR is set (but as mentioned before LV don't set DTR??)

So the key must be to set DTR

0 Kudos
Message 6 of 18
(6,278 Views)

Please do not post a screen shoot only showing some part of your code. We can not debug a picture! Post your VI instead



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 7 of 18
(6,269 Views)

Sorry Smiley Sad

Here it is

Tested to set RTS instead also

 

0 Kudos
Message 8 of 18
(6,268 Views)

 


znutt wrote: 

Measured at the sensor. When the original program runs it has power on DTR pin 4. But when LV runs ther is no power even if DTR is set (but as mentioned before LV don't set DTR??)

So the key must be to set DTR


 

No, LabVIEW does not "automatically" set DTR unless you set the flow control to use DTR. With flow control set to "none" you can control those lines manually.

 

I am able to change the state just fine with the serial port that's built into my computer. At least as far as the reported state. I don't have access to a DMM right now to actually measure the voltage at the DTR pin with respect to pin 5 (ground). Don't think this should matter, but do you have an actual serial port, or are you using an adapter, such as a USB <--> Serial adapter? Have you checked the documentation to see if it actually supports controlling that line manually?

0 Kudos
Message 9 of 18
(6,257 Views)

@znutt wrote:

Sorry Smiley Sad

Here it is

Tested to set RTS instead also

 


Nothing to worry about. Before I wrote the last post I checked with a DMM. And by setting the DTR pin asserted it will give out a posetive voltage. But can you check out the voltage level on pin 4 (DTR) then running the EMC software. Have you also the pin numbers right. This is the correct numbering for a 9 pin RS232 port



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 10 of 18
(6,241 Views)