Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - garysdickinson

Pages: 1 ... 26 27 [28] 29 30 ... 34
406
Technical support / Re:Actual [UpCtr] Counter value
« on: March 06, 2012, 11:11:59 AM »
Glad to help.

Please remember that the use of the ladder logic COUNTERS do come with some limitations:
  • The COUNTER resets to an special value of "-1".  This happens as a result of PLC reset, PLC power up and the use of the [RSCtr] Special function.
  • The maximum value that the counter can reach is determined by the Set Value in the I/O table.
  • The maximum Set Value is 9999 decimal.
  • The COUNTER will down count from 0 to the Set Value.  There are no negative numbers other than the special "-1" value.
  • The contact associated with the COUNTER has some interesting behaviors in regards to when the contact is active.
You may find that using custom functions to increment, decrement and reset a simple variable may give you more flexibility than using one of the ladder logic counters.

Gary D

407
Technical support / Re:Actual [UpCtr] Counter value
« on: March 05, 2012, 03:31:37 PM »
I'd suggest that you call a Custom function to load a value of 0 into a COUNTER.  

You will find that the Function [RSCtr], Reset Counter will set the counter to a special value of "-1" and the contact that is associated with the counter.

I assume that you are not using the contact that is associated with the counter and are only interested in the Present Value of the counter.

In the following ladder logic code there are two special functions, ZeroCnt and DispCnt.  

Custom Function named "ZeroCnt":

ctrPV[1] = 0

Custom Function named "DispCnt:

SETLCD 1,1,STR$(ctrPV[1])+"          "


Good luck,

Gary D.


408
Technical support / Re:Pump Seq
« on: February 28, 2012, 12:47:10 PM »
I, too,  worry about the need to change the TIMER SV often.  My concern is with how the SV are stored in the PLC.  I am worried that these are stored in an EEPROM and there is a danger that you may wear out the EEPROM by rewriting these values over and over.

Another alternative is to not use the ladder logic TIMER mechanism and do the work with custom functions.

The following shows how you can get the same basic behavior without the use of the ladder logic TIMER mechanism.  This approach may fit better with your HMI and it skirts around my concern with EEPROM, for the most part.

The following custom function, InitPumpCycle is invoked once with the 1st. Scan contact. This function sets up the initial values that define the pump ON/OFF times in 0.5 second units.

' InitPumpCycle - Set up Initial values for variable duty pump mechanism
'

' The next 2 varaibles hold the On/Off SetValues to be used to load
'  the CycleCntr variable.  
'
' The OnTimeSV and OffTimeSV variables are initialized on power up. These
' varaibles can be changed by your HMI code and the changed variables will
' be loaded into CycleCntr by the CheckPump function at the correct time
'
OnTimeSV = 10
OffTimeSV = 5???????????????'
??????????????????
' This variable is used as a down counter for the current phase of the pump
'
CycleCntr = 0

[/color]

This custom function, CheckPump is run every 0.5 seconds using "Clk:0.5s" special contact. RUN is an INPUT that is used to determine when the PUMP is to be cycled ON/OFF or just left off.  You will notice that only a single variable, CycleCntr is used for both the ON and OFF timing.  


' CheckPump - Custom function to handle variable duty cyle PUMP OUTPUT
'
IF TestIO(RUN) = 1
 ???' Pump is to be cycled
???'
???CycleCntr = CycleCntr-1?????????' Decrement
???IF (CycleCntr <= 0)????????????'  and check counter

??????' CycleCntr has hit 0
??????'   Change ouput state and
??????'   reload CycleCntr with the correct value
??????'
??????ToggleIO PUMP

??????IF (TestIO (PUMP) = 1)
?????????CycleCntr = OnTimeSV
??????ELSE
?????????CycleCntr = OffTimeSV
??????ENDIF
???ENDIF
ELSE
???' Pump is to be stopped
???'
???CycleCntr = 0???
???CLRIO PUMP
ENDIF
[/color]

Please note that the example takes advantage of the #Define to assign a locations in the DM[] array to the variables named OnTimeSV, OffTimeSV and CycleCntr.

#???#Define Name???Value
1???OnTimeSV???DM[1]
2???OffTimeSV???DM[2]
3???CycleCntr???DM[3]
[/color]

If you'd like a runnable version of this test code, just email me. In my user profile is my email address.  I can't put my email address in the body of this post because the YaBB software considers my email address to be obscene.

Gary D.

409
Technical support / Re:Pump Seq
« on: February 27, 2012, 09:21:30 AM »
Ok,

This is a snippet of ladder logic that I have used for a similar application.  It uses 2 TIMERS, one determines the ON time the other determines OFF time.  The RUN input starts/stops the whole oscillator.

You should have no problem achieving a timing accuracy of 5+/- 0.5 seconds with the the T100MD.

Try this code.  If you are still having problems, I'll ask more questions.

Gary D.

410
Technical support / Re:Pump Seq
« on: February 26, 2012, 06:06:50 PM »
Hi,

I've have a couple of questions.

When you say that the "output does not cycle on and off in a precise manner", how big an error in cycle time are you seeing?

How much of an error in cycle time can your application tolerate?

Can you give me a hint of the code that your are using?  

I'm a little concerned about your reference to "PV" or present value.  

If you are using timers, you may really want to be changing the "SV" or set value.  The SV is the value that the TIMER is loaded with when it is made active. If you change a TIMER's PV this may change the time period for the current cycle, but the TIMER will reload with the SV on the next usage.  

Look at the SetTimerSV and the GetTimerSV (n) statements change or examine the SV for a given timer.

I have more questions, but this should get the dialogue going.


Gary D.

411
Technical support / Re:PAUSE Statement iTRiLOGI V6.43
« on: December 19, 2011, 12:53:43 PM »
Thanks,

I was  using the simulator to debug a crc routine and was a bit worried about how TBASIC would handle bit-wise operations and the rshift /  lshift behavior.  

Gary d

412
Technical support / Re:CRC problems
« on: December 18, 2011, 09:53:48 PM »
Your in luck.  I was bored and wrote you a brute force CRC16-CCITT algorithm in TBASIC.  

You can copy and and paste this algorithm into your test code.

Here is the guts of the algorithm, "CRC16_CCITT":

// CRC16_CCITT - custom function to compute CRC16-CCITT CRC
//
// This is a brute force bit at a time algorithm.
//
// On input: Byte8 holds the 8 bit data to be accumulated into the CRC
//           CRC is the 16 bit CRC
//
// On exit: CRC is updated
//          Byte8 is all cleared


Byte8 = Byte8 * 256??????// shift incoming data 8 bits to the left
??????????????????// this aligns the most significant bit of the
??????????????????// incoming data with the 16-bit CRC value to
??????????????????// slightly simplify the algrorithm.

FOR i = 1 to 8
???j = Byte8 ^ CRC & &H8000???// check to see if feedback multiplier will be needed
???LSHIFT CRC,1????????????

???if (j)
??????CRC = CRC ^ &H1021???// feedback multiplier for CRC16-CCIT
???ENDIF
???LSHIFT Byte8,1
NEXT


Here is the test harness:


// TestString - test CRC16-CCIT algorithm
//

CRC = &Hffff???// Initialze CRC accumulator to all ones

Byte8 = &h03???: CALL CRC16_CCITT
Byte8 = &h0a ???: CALL CRC16_CCITT
Byte8 = &h81 ???: CALL CRC16_CCITT
Byte8 = &h00 ???: CALL CRC16_CCITT
Byte8 = &h00 ???: CALL CRC16_CCITT
Byte8 = &h00 ???: CALL CRC16_CCITT
Byte8 = &hff ???: CALL CRC16_CCITT
Byte8 = &hff ???: CALL CRC16_CCITT

// 03 0A 81 00 00 00 FF FF  Expected CRC 86 8A


A couple of notes: the variables CRC and Byte8 are actually DM[1] and DM[2] respectively.  I am using the #Define feature that is available in iTRiLOGI 6.43 to create code that is marginally readable.

Good luck,

Gary D

413
Technical support / PAUSE Statement iTRiLOGI V6.43
« on: December 18, 2011, 10:18:04 AM »
I was attempting to work on the CRC issue raised on the forum, and find that I am very confused about the TBASIC PAUSE statement.

I am attempting to use PAUSE as a debug tool.  I have the following custom function that is run on the first scan:


setlcd 1,1,"Program Started"
pause
setlcd 2,1,"Program Continued"


I expected to observe:
  • "Program Started" message on the LCD
  • "Pause Executed in Fn #1" window
  • Click on PAUSE menu button to continue
  • "Program Continued"  message on the LCD

This is what I observed:
  • "Program Started" message on the LCD
  • "Pause Executed in Fn #1" window
  • Click on PAUSE menu button to continue
  • Simulation continues on next rung of ladder logic

PAUSE seems to be interpreted as a special version of the TBASIC "Return" statement.

Is this the design intent of PAUSE?

Gary d


414
Technical support / Re:Modbus Stepper Control
« on: November 05, 2011, 09:19:52 PM »
I'd suggest that you use two or more DM[] locations for each stepper  channel.

As an example use:
DM[1] for control for stepper #1
DM[2] for position for stepper #1
DM[3] for control for stepper #2
DM[4] for position for stepper #2
   .
   .
   .
DM[13] for control for stepper #7
DM[14] for position for stepper #7

The master Plc updates the position info DM[2], first, then writes a non-zero command to the control register, DM[1].

The slave Plc detects the non-zero value and executes the appropriate stepper command.  When the command completes, the slave Plc clears the control value (sets it to 0).

The master Plc polls the control register in the slave Plc and must not change values until it "sees" that the slave is ready to accept the next command for that stepper channel.

You will need to use modbus commands to read and write to slave Plc DM registers.

Gary d


415
Technical support / Re:F1616BA Run Error
« on: October 10, 2011, 12:00:46 PM »
It sounds like you have introduced a bug into custom function#12.

There are a class of programming problems that cannot be detected until the program runs.  Examples of this type of run time issue include:
  • Divide by zero
  • Subroutine stack overflow/underflow

You will need to do some detective work to figure out why your program is failing.

If your program can be run under simulation (no real hardware) you may be able to debug your code fairly easily.  If your PLC program cannot function without being loaded onto real hardware then your debugging will be a bit more difficult.

I suggest that you look at the custom function that is being reported as a runtime error.  I would suggest that you "instrument" this custom function so that you can examine what it is doing.  Look at the  TBASIC PAUSE statement for a method to temporarily suspend the PLC program so that you can poke at the PLC internals.  

The use of PAUSE statements may help you isolate the offending bits of programming.  There are many more "tools" that you can use to hunt down the problems.

Good luck,

Gary d

416
Technical support / Re:Initial Value during Programming
« on: August 29, 2011, 07:49:22 PM »
The F1616BA has a chunk of non-volatile FRAM.  You can initialize this non-volatile memory using the EEPROM manager that is part of the I-Trilogi program.

On the first scan you can copy the non-volatile values into the DM[]. Look up the load_eep and save_eep tbasic functions to see how to access this true non-volatile memory.

I have used this on several of my projects. It allows me to customize a system without having to modify the PLC program.  I can change some of the tuning constants in the non-volatile memory and then reboot the PLC so that it can use the new values.  This is a very useful technique for storing user data.


Gary d

417
Technical support / Re:Motor Speed control
« on: August 02, 2011, 06:21:06 PM »
Can,

This schematic is typical for a divide by 4 circuit using a CD4013 (dual d f/f).

The CD4013 works well with voltages from 5 to 15 VDC.  The diagram shows 12VDC.

A typical optical isolator is used for interfacing your encoder to the CD4013.  If you encoder can operate on the same supply voltage as the CD4013 you can probably eliminate this circuitry.  If the output from the optical isolator is "noisy" or slow to rise, you may need to add additional circuitry between the optical isolator and the CD4013.

I show a single section of a ULN2003 to interface to the PLC logic. Even if your PLC were running at the same voltage (12V) as the CD4013, you will still need something like the ULN2003. The CD4013 cannot sink enough current to wiggle the PLC inputs.

If you only need to divide by 2 then connect the ULN2003 input to the directly to CD4013 pin #1. Connect CD413 pin #11 to GND.

Not shown on this diagram are supply bypass capacitors.  These are typically used to ensure that electrical noise from external sources is suppressed and will not disturb this logic and to avoid any noise generated by the CD4013 (not a real big issue with CD4XXX devices...) from causing issues with other circuitry.

Good Luck,

Gary D

   

418
Technical support / Re:Data entry from keypad
« on: July 19, 2011, 07:15:27 PM »
OK

1. The code you posted is not the code that fails.

2. Your code has been modified to look like the following to allow a 20 character string and does not work:

If z < 10 and Len(z$) < 20
  Z$ = z$+str$(z)
Endif

3. Your code still has bugs the crash the simulator.

Lacking ESP, I don't have a clue how to help.  

Best of luck,

Gary d





419
Technical support / Re:Data entry from keypad
« on: July 19, 2011, 12:39:58 PM »
I used the custom function that you included in the post (without the rest of the code) and played with in in simulation.  

I do not get the error (some absurd number).  I don't see the error so I can't help.  The error is not coming from this code section.  Somewhere else you have code that annoys the simulator. The simulator will catch many runtime errors. The types of errors that the simulator can catch are pretty grievous (divide by zero, call stack overflow/underflow...).

On the issue of only accepting 10 digits, that I can help. The following IF statement limits the input to 10 digits:

IF Z < 10 AND LEN(Z$) < 10  ' not more than 10 digits
        Z$ = Z$+STR$(Z)
      ENDIF

If you want to input a string longer than 10 you will need to change the the value of the constant from 10 to what you require.  Remember that there is a maximum string length that TBASIC can handle.  I think that the max is 70.

Gary D

420
Technical support / Re:Timer present value setting
« on: July 08, 2011, 10:01:52 AM »
TIMER present values can be directly accessed using the following notation:

timerPV[n] = 10       ' n is the timer number 1..255
                             ' set timer n to the value 10

A = timerPV[n]        ' read current value of timer n into variable A

gary d

Pages: 1 ... 26 27 [28] 29 30 ... 34