Recent Posts

Pages: 1 ... 8 9 [10]
91
Hi Gary,

It appears that the funny characters all appear in the TBASIC codes that you are showing in your post. Did you copy those directly off a custom function editor or were these exported to an external file and then copied from the external file?

I copied one of the fragment of codes you posted  that was showing funny characters and pasted inside a TL6 custom function. I removed the funny characters and replaced them with TABs,  then copy them back and paste them into this forum post as shown  below:


' Custom function to print 0..99 on serial device #2
'
' This is the text that will be sent to the serial device:
'
'   00 01 02 03 04 05 06 07 08 09
'   10 11 12 13 14 15 16 17 18 19
'   20 21 22 23 24 25 26 27 28 29
'   30 31 32 33 34 35 36 37 38 39
'   40 41 42 43 44 45 46 47 48 49
'   50 51 52 53 54 55 56 57 58 59
'   60 61 62 63 64 65 66 67 68 69
'   70 71 72 73 74 75 76 77 78 79
'   80 81 82 83 84 85 86 87 88 89
'   90 91 92 93 94 95 96 97 98 99
'
print #2 "First Version"      ' Debug Message
for i = 0 to 9         ' outer loop for the 1s digits
   for j = 0 to 9      '   inner loop for the 10s digits
   print  #2 i;j;" ";      '  print each number with 2 digits and a space
   next
   print #2            '  newline at the end of each group of 10 numbers
next

The funny characters are no longer there.
92
I see this with Microsoft Edge, 32-bit Internet Explorer and Firefox on Windows 10.  The problem also shows up with Safari on iPads and iPhones. The fact that the Unicode characters show up on very different operating systems computer hardware is very interesting.

These are a few threads that shows funny characters:

http://www.triplc.com/yabbse/index.php?board=1;action=display;threadid=2367

http://www.triplc.com/yabbse/index.php?board=1;action=display;threadid=2314

http://www.triplc.com/yabbse/index.php?board=1;action=display;threadid=2276

http://www.triplc.com/yabbse/index.php?board=1;action=display;threadid=2227

The bit of the thread that shows them has been copied from the I-TRILOGi CF editor and pasted into a reply. Some of these characters, also came from a copy/paste operation from an simple text editor.

Most of the goofy characters are where ASCII tab characters were in the original source. It is not possible to input ASCII tab characters using a keyboard as YaBBSE ignores them, but it is possible using a copy/paste operation.

The odd Unicode characters did not show up when the replys were posted. Only recently have the odd characters appeared.  They did appear in my very recent posts, but I went back and replaced them with ASCII spaces to make the posts a bit less annoying.

Gary d
93
Thank you for your feedback. Is there a specific forum thread that is showing the funny character that you mentioned? Did you try with a different browser and do all of them show the same funny characters?

We have not made any changes to the underlying PHP code for the forum. In fact we didn't upgrade the PHP because of the concern that it may break the code. But the browsers might have moved on and beginning to "not like" the code executed by the old PHP codes? We are not too sure.
94
The forum webpages are displaying odd Unicode characters in place of ASCII spaces or ASCII tabs.  These characters are showing up: ���

Is there some secret settings I need to make to my internet browser to fix these funny characters?

Best regards,

Gary D*ckinson
95
Technical support / Re:Trouble Reading FP Values
« Last post by garysdickinson on January 28, 2019, 01:13:20 AM »
Mark,

Your Modbus register address of 5000 may be correct.  If you are aceessing FP[1] via the Wientek HMI the correct answer will be 5001.

You have a 50:50 chance of getting them correct.

It depends on how the READMODBUS deals with the register address.  I don't use the READMODBUS and WRITEMODBUS functions/statements as they are too limiting for my usage, so I can't answer this question with 100% certainty.  But, I can give you enough info so you can figure it out.

OK, lets get to the problems with your code:


C# = READMODBUS (13,2,5000)  'READ Value from Aux 2

D# = READMODBUS (13,2,5001)  'READ Value from Aux 2


Problem #1 is that ReadModbus() returns a 16-bit integer and not a floating point value. so you can't assign it to a floating point variable such as C# or D# and expect to make much sense of it

Problem #2 is that you did save the 16-bit values returned by the calls to ReadMobus() so that you could build a 32-bit value that represents the correct bit pattern of the target FP[1] value.

Problem #3 is that you need to "cast" this 32-bit integer value so that you can store it a 32-bit float.

This is closer to what you need to do get read a 32-bit float:


' Read 2 sequential registers from target PLC and
' save as integers

c = READMODBUS (13,2,5000)     ' most signficant word
d = READMODBUS (13,2,5001)     ' least signficant word

' move msw pattern read from Modbus into msw of the variable "e"
'
e = c
e = e * &h00010000

' now add in the lsw bit pattern read from Modbus
'
e = e + (d & &h0000ffff)

' assign the 32-bit signed integer, "e", bit by bit to the C#.
'
' bits2float() acts as a cast. If bits2float were not used then
' TBASIC will attempt to create a floating point representation of the
' value of "e" and this is not what you want!
'
C# = bits2float(e)
[/color]

OK. I am going to give you a way to figure out if 5000,5001 are the right register addresses:

'InitFP - CF to intialize FP[1..32] with known values
'
' The pattern was picked to be easy to "see".
'
' FP[1] -> &H01020304
' FP[2] -> &H05060708
' FP[3] -> &H090A0B0C
'  .
'  .
'  .
' FP[32] -> &H7D7E7F80
'
n = 1      ' initial byte value pattern
for i = 1 to 32
  a = n              ' msb of 32-bit pattern
  a = a * 256     ' shift left 8 bits
  a = a + n + 1
  a = a * 256     ' shift left 8 bits
  a = a + n + 2
  a = a * 256     ' shift left 8 bits
  a = a + n + 3   ' lsb of 32-bit pattern

  FP = bits2float(a)    ' convert to float and store

  n = n + 4       ' next byte value pattern
next
[/color]

Initialize the target FP[] array using the test pattern generator.  Now run your ReadModbus test code under the online simulator and look at the values that you are getting back from Modbus for the MSW and LSW and you will be able to figure out where they are coming from. You will be able to adjust the Modbus register values if needed.

In the view window of the simulator, when looking at float variables you can either view them as IEEE (which is the hexadecimal 32-bit value) or "DEC" (which is the floating point value represented as a base 10 decimal value like "-3.141597"). Pick IEEE and look at the hex values.

Best regards,

Gary D*ckinson
96
Technical support / Trouble Reading FP Values
« Last post by Mark P. on January 27, 2019, 02:52:28 PM »
Hello

I am trying to Modbus Read some FP values from FX processor.
I am reading them from another FX processor.
Reading DM values works fine between the two.

Maybe the number system is off in the manual or these need something special ?

tIf looks like if I want to read FP[1]  the modbus values are held in 5000 and 5001

No matter what value I put in FP[1] greater then Zero I always get

in 5000 modbus location =16256 and  5001 =  Zero ?

Basic read code

C# = READMODBUS (13,2,5000)  'READ Value from Aux 2

D# = READMODBUS (13,2,5001)  'READ Value from Aux 2


This code works fine Reading DM values work fine with numbers like 1000, 1001 etc.
I have tried server variables to put the data in, no noticeable change

Am I looking in the wrong place for FP values ?


97
Technical support / Re:Stepper Stepping Bit ?
« Last post by garysdickinson on January 13, 2019, 11:31:16 PM »
Mark,

I think what you really what to know is when is the stepper controller busy and when the stepper controller has completed a move operation.

Please note that the argument "r" in the step move command allows you to specify an internal PLC RELAY to set when the STEPMOVE has issued "count" pulses to the stepper channel specified by "ch".

STEPMOVE ch, count, r

The STEPMOVE and STEPMOVEABS statements are "non-blocking".  These statements execute quickly and the TBASIC goes on to the next part of the program before any step pulses are issued. The actual movement of the stepper might take from a few milliseconds to a few millennia depending on number of steps in the "count" argument. You don't want the PLC hung up waiting for the stepper movement to complete.

For Stepper channel #1, I define a RELAY named Ch1CmdCmp and issue a stepper command like this:

StepMove 1,Ch1Arg1,Ch1CmdCmp

The RELAY named Ch1CmdCmp will be reset to 0 by the execution of the StepMove statement. The same RELAY will be set to 1 when the stepper motion has completed.  So when the CH1CmpCmp RELAY is 1 then you can issue a new StepMove or StepMoveAbs command. When the CH1CmpCmp RELAY is 0 the CH1 stepper controller is busy moving the stepper.

There is a small issue with the StepMove and StepMoveAbs, and this is that if the count argument would result in no stepper pulses being issued (no motion) then the RELAY, "r", will be cleared but will not be set to 1.  This is how I make the behavior of the RELAY consistent:


       ' The StepMove statement will not set the Ch1CmdCmp RELAY if the
       ' the statement will result in no physical motion of the stepper motor
       '
       ' The fix is to execute the StepMove statement and then
       ' set the Ch1CmdCmp RELAY
       '
       StepMove 1,Ch1Arg1,Ch1CmdCmp
       if (Ch1Arg1 = 0)
              SetIO Ch1CmdCmp       ' set the command completion RELAY
       endif



       ' The StepMoveAbs statement will not set the Ch1CmdCmp RELAY if the
       ' statement will result in no stepper motion
       '
       ' The fix is to test if the current absolute position is the same
       ' and the position specified in the argument to StepMoveAbs and after
       ' the StepMoveAbs statement is executed, set the Ch1CmdCmp RELAY to indicate
       ' that the statement completed
       '
       s = StepCountAbs(1) - Ch1Arg1       ' s is the distance to the new position
       StepMoveAbs 1,Ch1Arg1,Ch1CmdCmp       ' issue the stepper command
       if (s = 0)
              SetIO Ch1CmdCmp       ' the Ch1CmdCmp Relay will not be set, so force it.
       endif



I have posted a full up stepper motor test system on this forum.  I have included documentation, PLC firmware as a .pc6 and firmware to support a the MT8050iE HMI that TRI offers on their website.

This code provides a full stepper test system for a single stepper.  The PLC code is very small and very fast and uses all of the stepper commands.  The code can be run without hardware with the simulator and if you have no HMI, you can run the code on real hardware using On-line monitoring.  I think that I put hints in the documentation on these things.

Look for the topic: "Stepper Motor Demo Code".
The posting date was May 02, 2018, 03:10:38 PM.
http://www.triplc.com/yabbse/index.php?board=1;action=display;threadid=2347

Best regards,

Gary D*ckinson

[Forum Editor's Note]: Have edited this post and removed the funny characters that were present in the original post.
98
Technical support / Re:Mobus Writes Blocking PLC inputs
« Last post by garysdickinson on January 13, 2019, 04:53:04 PM »
Mark,

Your approach would work.  However, this requires that the CF be called on every scan.

I'd suggest something a bit different, use the dCust function and trigger it off the 0.1sec clock.  Change your CF to make a decision on each count value.

I would suggest that you NOT use one of the a..z variables as a counter as you need to preserve this value between calls to this CF.  I prefer using the #Define mechanism to "create" a variable out of the DM32[] array.  You could define MBCounter as being DM32[100].  So your code would look like this:

If MBCounter = 0
    Writemodbus ...
elif MBCounter = 1
    Writemodbus ...
endif

MBCounter = (MBCounter + 1) mod 2   'Increment and keep bounded

Best regards,

Gary D*ickinson
99
Technical support / Stepper Stepping Bit ?
« Last post by Mark P. on January 13, 2019, 03:52:24 PM »
Hello

I have an application where I am useing several stepper functions.

All work well but I am in need of some way to know if the stepper output is putting
out pluses in the logic.

The really available on the STEPMOVE or STEPMOVEABS are very unreliable.

I have tried to look at the output that is stepping in the logic but at least a rung level it shows
nothing while stepping.

Any thoughts ?

If output pluses are being put out of output would like to know.
And turn this into a bit (stepper stepping)

Possibility there is some memory location behind the scenes I could look at ?

Thank you

Mark
100
Technical support / Re:Mobus Writes Blocking PLC inputs
« Last post by Mark P. on January 13, 2019, 03:45:39 PM »
Thank you !

Glad at least there's a logical answer.

To accomplish some of your suggestions

#2 Perform only a single Modbus operation per ladder logic scan.

#3 Ensure that between Modbus operations that the ladder logic is allowed at least one scan of the ladder logic.

Can I do something like :

inside of Dfuction block.  

x=x+1

if x=2 then
writemodbus ***
endif

If x=4 then
writemodbus ***
endif

etc...  etc..

If x >10 then
x=0
endif

I am assuming every scan it will increase x by 1.

Thank you again

Mark

Pages: 1 ... 8 9 [10]