ST (structured text) best way to toggle bit

These special functions are confusing.
I do like this:

Code:
up_edge_imp := input_bit AND NOT input_bit_mem ;
down_edge_imp := NOT input_bit AND input_bit_mem ;
dual_edge_imp := (input_bit AND NOT input_bit_mem) OR (NOT input_bit AND input_bit_mem) ;
input_bit_mem := input_bit ;

(*
Then use the edge bits as needed.
The code that uses the edge bitsdoes not have to between 
the edge detection and the line to update the memory bit
*)
 
Hello guys,

I am running an application for packaging measurement using a sick DFS60B incremental encoder (programmable from 1 to 10000 PPR). In more detail, it passes packaging on a conveyor belt and we have created an inspection station and an expulsion station (defective packaging), so we use the encoder to check at specific points of the packaging for defects (we use special sensors to check defects). ) (there are four in total). However, the problem we are having is the following: When reading the encoder in the PLC, the same means that performs "jumps" and does not enter the windows (GRT and LES) created on the ladder, ie, as if it were not continuous. .

I understand that because the VHSC24 card works at 1 MHz in counter mode, this type of problem should not occur according to our application is not even 100 KHz. For example, our case: Using 1000 PPR and the motor speed (coupling output) is 3600 RPM (in practice it is around 1750 RPM) the frequency is calculated as follows: F = (PPR X RPM) / 60. : F = (1000x3600) / 60 = 60 KHz, ie 60 KHz is much less than 1 MHz, I think this kind of problem does not occur.

Application Info:

. Studio 5000 V31
. PLC Model: Rockwell 1769 - L19ER-BB1B CompactLogix 5370
. Encoder Card: 1734-VHSC24 / C
. Incremental Encoder: Sick, DFS60 up to 10,000 PPR and HTL Electrical Interface. Using a 200 mm circumference / perimeter wheel.
. Motor Nameplate Data: 1670 RPM, 0.37 kW / 0.5 HP, 60 Hz
. Inverter: Weg CFW500, Output Frequency 62 Hz.

Card Settings we use
RPI: 2 ms
Type: Counter, but we already use it as Encoder X1
Store Count Mode: Disabled
Filter: No Filter, but we use 50 KHz and 5 Khz filters in our tests.
Counter Attenuator: 1

Wiring Diagram VHSC24
We turn on encoder A at input 0 and encoder Aret at input 1

In logic
(Structured Text) Using the PMUL instruction to convert encoder (Pulse) data to mm scale.
(Ladder) The window comparisons part (GRT and Les) and other part of the process. We emphasize that we performed the tests also only with the reading and comparison part of the data, excluding the other parts, precisely to verify the issue of Scan, but the problem persisted.

If anyone here in the forum has some information that can help us, I would appreciate it.
 
my typical ST toggle:
Code:
if ( conditions & NOT OneShot ) then
   BitToSet := NOT BitToSet;   // bool version
   Byte := Byte XOR 1;         // if you prefer operating on bytes, words, so on
end_if;
OneShot := conditions;
 
Last edited:

Similar Topics

I´ve being trying wrap head around FOR loops.. When and what can this be used for? I´ve mostly seen it move data, resettting arrays etc. I made a...
Replies
12
Views
271
Hi! When is CASE preffered? CASE uses a numreric variable for the cases and doesnt handle BOOL, but this can be done with numreric and bool using...
Replies
4
Views
163
Hello, doing switch from FBD to ST. First task is converting my old work. How do you sum variables? For example, Interlock1, interlocl2 and...
Replies
5
Views
211
Hello, I am using studio 5000 pro and am trying to figure out the structured text. Here's my scenario: An operator scans a barcode, the barcode...
Replies
15
Views
376
I have an expression in a structured text routine of a Logix controller that looks more or less like the following: ResultInteger := Integer1 *...
Replies
13
Views
455
Back
Top Bottom