DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DAC decimal to binary

Solved!
Go to solution

Hello,

 

I need to read in the status of 16 digital inputs over rs485 in HEX, convert to binary and extract the status of each DI to visualize and record.

My .atr file works fine. I can read in the status of the inputs and get the right dec values; Channel 1 + 2 (0-255)

 

Input
Set com6 TO=5000 EOL=\013
Write com6 "@01"
Set com6 TO=5000 EOL=OFF
Read com6 "%1c %2hnb %2hnb %c"
end

 

Now I need to convert the dec values to 2 binary values (8bit) and extract each bit.

I tried it that way (copied from the board) but it doesnt work... I think syntax, data type or something like that is wrong...

 

Sub SFD_ProcessChannel( ChannelNumberP, InputListV, ParamP, DataP, ErrorP )
  ' Diese Funktion muss für ein Skript zur Datenverarbeitung implementiert werden.
  ' Zu ergänzen : Geben Sie hier den Code für die Berechnung des gewünschten
  ' Ergebnisses ein.

  DataP = 0

  Dim tmp
  Dim n
 
    n = InputListV(0)
 
  tmp = Trim(Str(n Mod 2))
  n = n \ 2
 
  Do While n <> 0
    tmp = Trim(Str(n Mod 2)) & tmp
    n = n \ 2
  Loop
 
  DataP = tmp
 
End Sub

 

Can somebody help me plz?

thx Mike

0 Kudos
Message 1 of 2
(3,099 Views)
Solution
Accepted by topic author mleopold

Ok bitextract solved my problem!!

0 Kudos
Message 2 of 2
(3,069 Views)