From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

rs 232 diadem 10

Hi,
 
I want to read data from a dewetron PAD DI8 modul via rs 232.
It has 8 digital input canals.
I wrote a ".atr" data file to use it in a "Extern Input" Block in diadem.
 
the data is available as following:
 
command: $(Add)6\r
 
response:!(inputdata)\r
the inputdata is 3 bytes long, where only the first byte is used. 2nd and 3rd are: oo oo
 
example:
command: $316\r
'//Add=31
response:!0F0000\r
'//input: 0F=00001111 => first 4 chanals of the digital input are 1 rest is 0.
 
the communication works on a com1 terminal properly. the problem is to convert the hex input value into a
8 chanel digital signal in diadem.
 
my .atr file is:
 
init
Set COM1 TO=500 EOL=\013
end
Input
 write COM1 "$$316"
 read  COM1 "%C %BNB %C %C"
 pause 2
End
 
The error is: (translated from german) 
"Invalid portnumber on input- or output"
 
Thanks for your help
daniel
0 Kudos
Message 1 of 3
(3,504 Views)
Hi Daniel,

as fas as I have seen from your example, the module returns the data as hex values. Thus you should read the value as a hex format. I have listed the corrected *.ATR file below.

init
  Set COM1 TO=500 EOL=\013
end
Input
  write COM1 "$$316"
  read  COM1 "%C %2HNB"
  pause 2
End

The read statement can be interpreted as follows: ignore one character (%c), take the next two characters and interprete them as a byte in hex format (%2HNB") and then forget the rest of the line (thus you do not need to put a %4c statement at the end of the line).

But that is not the reason for the error message you have seen. I guess your intention is to read every single bit of the return value as a seperate channel in DIAdem. Therefore you have defined an input block with 8 channels. The *.ATR file however defines just one channel, resulting in the error message you have seen. To acquire one channel per bit, define an input block with just one channel and then add a block for bit extration to it. This block will split up the byte value returned from the external input block into one channel for each bit. See attached DAC scheme for an example.


Rainer


Message 2 of 3
(3,481 Views)

Hi Rainer,

I've already found a solution on Friday. But with your advice it would have been a lot less trial and error 😞

Thanks

Daniel

0 Kudos
Message 3 of 3
(3,467 Views)