Vb to Slc

garryt1

Member
Join Date
Jun 2002
Location
n.ireland
Posts
128
Hi there,

I know a little !! about vb but i have quite a lot of experience with plc's,i am trying to write a small hmi application for alarms between a slc 5/04 and a vb gui.I know how to get the data into the vb but if i want to read individual bits i cannot get my head around this.I can use automatedsolutuions eth or dh+ active x down to bit control but the rslinx help file does not go into this detail.
I am using RsLinx Pro,can somebody please guide me on this topic.

thanks in advance.

Garry bloody frustrated T!
 
use some variable as integer (16 bit) and use them.
Alam_Int = Alarm_int or 1 ' sets bit 0 where is some alarm bit
Alam_Int = Alarm_int and 0 ' resets bit 0
Alarm_Bit_0_Bool = Alam_Int and 1 ' retrun True if true
Alarm_Bit_2_bool = Alam_Int and 4 ' retrun False if False
 
Sorry, mistake !!
Alam_Int = Alarm_int or 4 ' sets bit 2

Alam_Int = Alarm_int or 4 ' 1'st sets bit 2 (just in case)
Alam_Int = Alarm_int xor 4 ' 2'nd resets bit 2
 
'...if you intend to do a lot of programming with bits, then do it in hex.

Dim PLCword as long
Dim result as boolean

'....isolate individual bits
result = PLCword And &H0001 '....result contains bit 0
result = PLCword And &H0002 '....result contains bit 1
result = PLCword And &H0004 '....result contains bit 2
result = PLCword And &H0008 '....result contains bit 3
result = PLCword And &H0010 '....result contains bit 4
etc. etc.
result = PLCword And &H8000 '....result contains bit 15


'....test individual bits for truth
If result then '...test result for true
If PLCword and &H0001 then '...test the bit in the word directly

'....test individual bits for false
If Not result then '...test result for false
If Not (PLCword and &H0001) then '...test the bit in the word directly


'....setting bits within a word to 1
PLCword = PLCword Or &H0001 '....set bit 0 true
PLCword = PLCword Or &H0002 '....set bit 1 true
PLCword = PLCword Or &H0004 '....set bit 2 true
PLCword = PLCword Or &H0008 '....set bit 3 true
PLCword = PLCword Or &H0010 '....set bit 4 true
'...etc. etc.
PLCword = PLCword Or &H8000 '....set bit 15 true


'....reset (set to 0) a bit within a word by inverting the bits in the appropriate nibble
PLCword = PLCword AND &HFFFE '....reset bit 0 to false (1110b)
PLCword = PLCword AND &HFFFD '....reset bit 1 to false (1101b)
PLCword = PLCword AND &HFFFB '....reset bit 2 to false (1011b)
PLCword = PLCword AND &HFFF7 '....reset bit 3 to false (0111b)
PLCword = PLCword AND &HFFEF '....reset bit 4 to false (1110b)
'...etc. etc.
PLCword = PLCword AND &H7FFF '....reset bit 15 to false(0111)

Learn Hex nibbles and the inverse of same and you'll have it made.
 
Thanks guys!

this is great,

however what i mean is ,say i read a word O:4/0,L16(RsLogix500) into a text box txtBlock(0)or maybe an array ,what i see in the text box is the following 0||0||1||0||.... and so on,how do i individually reference these bits for reading as alarm bits???

thanks in advance
 
parse the DDE data

When using DDE you should start by learning as much as possible about the DDE's different operational modes. This being a Microsoft app
it is well documented. You should move all data into continous
files in the PLC. Say n7:1 to n7:100. Read them all at once.
Don't try to read different types of data and individual files. Do the same thing when you write the data into the PLC.
This improves the communication efficiencies. The DDE commands allow you to organize the data as CF_text with different format.
Select the number of columns and amount of white space that makes the
most sense for your app. Write a routine that parses the data from
the text box into a string array. Use above described techniques to
manipulate individual bits.
If you have plenty of horse power in your PLC you may wanna consider
using a whole N file just for one bit, this will make programming easier.
If you decide to use OPC you can specify boolean type and read
and write the bits directly. This is where OPC shines.
If you are a novice programmer DDE will be a lot easier to use.
 

Similar Topics

I’m attempting to send a temperature from a SLC-5/02 to an EZiMarquee display. The vendor said to use a MSG instruction to send the data to the...
Replies
1
Views
61
Hello all. I have a few SLCs in my plant and of late we've seen a weird issue: The system will be running normally and then randomly the outputs...
Replies
2
Views
75
I am working on setting up a Prosoft Datalogger model PLX51-DLplus-232. This unit will be collecting data from a SLC 5/05 on the DB9 port set to...
Replies
3
Views
95
I have a redundant ControlLogix being set up. This program reads a value from a remote site which happens to be SLC PLC. Rockwell mentions SLC...
Replies
2
Views
91
Hello, I have a ControlLogix redundant controller being set up. The program reads a value from a remote site which hosts a SLC PLC. Rockwell...
Replies
0
Views
75
Back
Top Bottom