Hi. Could you help me to convert a simple ladder diagram into Pascal, C,or Basic code

Boyko Boykoff

Member
Join Date
Mar 2003
Posts
4
I am trying to convert this simple ladder diagram (for Omron Symatic 200) into Pascal, C or Basic. I want to use a PICmicro instead of PLC, but I can't convert the LAD into PICBASIC PRO. Could you help me please.
Thanx.
P.S. The LAD program is in attached gif file.

ladder.gif
 
Sorry I don't know how to do a timer in BASIC. It is not equivalent to a DELAY, PAUSE, WAIT, etc.

IF v1 AND NOT v2 then [TIM0]
IF v1 AND NOT v25 THEN OUT v24
IF t0 AND NOT T1 AND NOT v0 AND NOT v3 AND NOT v5 THEN OUT v25
IF v25 AND NOT v4 THEN [TIM1]
 
Not quite.

IF v1 AND NOT v2 THEN TIMER(T0,100,1) ELSE TIMER(T0,100,0)
IF v1 AND NOT v25 THEN v24=1 ELSE v24=0
IF t0 AND NOT T1 AND NOT v0 AND NOT v3 AND NOT v5 THEN v25=1 ELSE v25=0
IF v25 AND NOT v4 THEN TIMER(T1,10,1) ELSE TIMER(T1,10,0)[/

-----

The Timer function {TIMER(Done bit,Preset,Enabled)} is fairly complex. It uses at least 3 integer registers, one to store the preset, one to track the accumulated value, and one to track against the system clock (RTC), as well as other internal bits.
Code:
If Enabled = 1 AND Internal_Enabled = 1, then 
    If (RTC - System Clock Track) > 1 sec (assuming your timer is on a 1 second time base) 
    Then System Clock Track = System Clock Track - 1;
         Accumulated Value = Accumulated Value + 1
    
    If Accumulated Value > Preset Value 
    Then Done Bit = 1
    Else Done Bit = 0

If Enabled = 1 AND Internal_Enabled = 0 
then system clock track = system clock.
Internal_Enabled = 1


If Enabled = 0 Then Done bit = 0;
                    Accumulated Value = 0
                    Internal_Enabled = 0

Or something like that.

But one of the big keys about PLC coils is the fact that if the instruction is false, the PLC resets the bit.
 
Last edited:
"But one of the big keys about PLC coils is the fact that if the instruction is false, the PLC resets the bit."

Cheers Allen, of course... I wasn't thinking back to my old BASIC days - If one sets a value, it stays that way until modified. DOH!
 

Similar Topics

i hope you could help me to convert the network Stl to lad it's apart from program of machine and i try to find solution for the reason of error...
Replies
10
Views
1,851
Hello everyone, I am migrating a program from STL to SCL via S7-1200 portal, I would like you to help me by converting these lines of code...
Replies
4
Views
1,607
Hi All i was wondering if any one would be able to help me. My version of studio5000 only allows ladder and FB. i have an AOI written in structure...
Replies
2
Views
1,523
Can someone please help me out and print this entire program to a PDF. Tried to zip and upload but too big so Google drive Link below to the adc...
Replies
2
Views
1,242
Hello, I am trying to figure out how to create / write / delete a .csv file on the SD card of an Allen Bradley PLC. There is a sample project...
Replies
1
Views
1,414
Back
Top Bottom