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 ... 3 4 [5] 6 7 ... 34
61
Technical support / Re: Changing STEPSPEED
« on: October 13, 2019, 04:23:30 PM »
Thierry,

You will have to test this.  I have tested most of the stepper motor hardware and firmware, but have not attempted to change the PPS (step rate) of a running stepper. 

I do use the PWM outputs to generate variable frequency pulses.  The PWM outputs will change frequency while running. I have verified this with a digital oscilloscope and see that the output goes to the new frequency very "cleanly".  You could use a PWM OUPTUT to control a stepper motor and change the frequency, periodically.

The following code has been extracted from one of my products that is in production.  The code is called every 0.1 second (10 Hz rate) and changes the PWM frequency.  The code is used to simulate the output of a flow meter. The physical flow meter outputs a variable frequency signal that is proportional to the flow of fluid through the flow meter.

if (VFDCurrentHz < 5.00)
   ' Main Pump speed is too low to generate meaningful flow values
   '
   SimProductGPM = 0.0
   SetPWM 1, 0, 1         ' 0% duty cycle so output is "OFF"
else
   ' The main pump is running so we will calculate flows based on VFD frequency
   '
   SimProductGPM    = 0.0007 * VFDCurrentHz * VFDCurrentHz + 0.0194 * VFDCurrentHz + 0.7229

   ' Generate pulse output for flow.
   '
   SetPWM 1, 5000, SimProductGPM / 60.0 * ProductPPG
endif


Best regards,

Gary Dickinson

62
Technical support / Re:User written Modbus RTU example code
« on: June 19, 2019, 10:45:06 AM »
Thanks,

I try to periodically post PLC software that illustrates an approach to PLC programming that solves a complicated problem without a lot of programming.

As always, I invite people to use this or any other examples that I have posted.

Best regards,

Gary D*ckinson

63
Technical support / Documentation
« on: June 11, 2019, 05:32:47 PM »
This is the PDF version of the documentation.

64
Technical support / Slave PLC code for test
« on: June 11, 2019, 05:28:35 PM »
Variations of this Modbus RTU code is currently running 24/7 on over 40 PLCs.  Some of these installations date back 5 years.  This is why I am convinced that the code is reliable.

I extracted the Modbus RTU code out of running production code. I simplified this code for use as a demo.

I needed to test the demo code against a real Modbus RTU slave device. I decided to use a spare TRI PLC as the slave.  This choice solved my my need to test the code and provided an opportunity to explain how the low-level TRI handles Modbus RTU requests.

This posting is the PLC program that I am running on the slave PLC.  This code initializes the serial port on the slave and writes data patterns into DM[] and some of the PLC RELAYS.

The data patterns are used to help me verify that my code running on the master PLC is reading/writing the correct registers in the slave.

The slave PLC responds to the Modbus RTU requests using the TRI written firmware. My software on the slave PLC is NOT handling the Modbus requests.

Have fun,

Gary D*ckinson

65
Technical support / User written Modbus RTU example code
« on: June 11, 2019, 05:22:29 PM »
I am presenting the code that I have been using for the last 5 years as an alternative to the TBASIC ReadModbus, ReadMB2, WriteModbus and WriteMB2.

This code is supports all possible Modbus function codes.

This code is non-blocking. The PLC does not lock up waiting for a response from the slave device.

This code is an example of a user written communication protocol

This code allows you to see both the Modbus response packet and every byte received from the Modbus slave.  This allows you tremendous debug capability that is not available with the TBASIC Modbus support.

I will post the PLC code and the documentation in pieces to keep them under 200KB

Regards

Gary Dickinson

66
Technical support / Re:FX2424 Modbus RTU
« on: May 26, 2019, 11:35:36 AM »
I am not answering the question that you asked. You cannot get 4 values from the READMODBUS function, just one.

Your code:

Z = READMODBUS (13,1,3104)

The READMODBUS function returns a single 16-bit value. You assigned this value to the 32-bit variable Z.  Where are the other 3 values that you said that you were getting?

The 3rd argument to READMODBUS should have been &h3104 (hexadecimal not 3104 (decimal).  It is a good bet that your Modbus device rejected this modbus query. Your Modbus device probably returned an error status and not the value of some register.

You must check the value from Status(2) to determine if the READMODBUS function completed without error and the value that was returned has any meaning.  

Your test code uses the Modbus function code of 4.  The READMODBUS function uses the Modbus function code of 3.  These two function codes are different and your Modbus may return values from different registers based on the function code that you  used.

You can force READMODBUS to use the function code 4 instead of 3 with this statement:

   Setsystem 6,4



Gary D*ckinson

67
Technical support / Re:Pulsewidth measurement
« on: March 18, 2019, 12:16:19 PM »
Dave,

I have been working with TRI's PLCs for over 15 years.  Their products have evolved and they have added significant new hardware and software features.  However their current documentation tends to be re-edits 20+ years old info.  

The 1..10Kz measurement system limits dates back to the generation of hardware that was new in about 2001.  The measurement system buried in the ASIC used for the Tile/Fx based PLCs is hardware based and uses a 10 MHz time base.  If your use the PulsePeriod() function the hardware zeros out a 32-bit hardware register on the rising edge of your input signal and then increments the register every 1 or 0.1 us until the next rising edge of your signal.  PulsePeriod returns the accumulated count.  I know this stuff because I broke the firmware in these PLCs and worked with their designers to fix it.

I suggest that you write tiny test PLC programs to figure out the details.  I'd estimate that 80% of my PLC programming is test code.

I, also, suggest that you call/email TRI's customer support.  They actually know the details of their products and have been very helpful.  

You are always welcome to pick my brain on this stuff.  My email address is in my user profile.

Gary d

68
Technical support / Re:Pulsewidth measurement
« on: March 16, 2019, 11:58:39 AM »
Dave,

I suspect that the data sheet is incorrect.  The default resolution of the pulse measurement system is 1.0us.  You can program the some of PM channels to work with a resolution of 0.1 us.  

This is the text from the Fx2424 user's manual:

1) To use the PM input to measure pulse width or frequency, execute the PMON statement ONCE to configure the relevant input to become a pulse measurement input. You usually put the PMON statement in the init custom function and execute it with a “1st.Scan” pulse.
2) Thereafter the pulse width (in s) or the pulse frequency (in Hz) can be easily obtained from the PULSEWIDTH(n) or PULSEFREQUENCY(n) functions. You can also obtain the pulse period (inverse of frequency) using the PULSEPERIOD function.
E.g. A = PULSEWIDTH(1) B = PULSEPERIOD(1)
C = PULSEFREQUNCY(1)
3) All PM inputs by default return the measured pulse width and pulse period in unit of microsecond. However, for those who desire better resolution, you can define PM #1 to #4 to return the measured pulse width and pulse period in 0.1 microsecond resolution by executing the following command once only during initialization:
SETSYSTEM 20, 1
Once the above statement is executed, if PUSLEWIDTH(1) - PULSEWIDTH(4) returns the value 1234 it means the measured pulse width is 123.4 s. However, PULSEWIDTH(5) and PULSEWIDTH(6) would still only return the measured width in microsecond.
A sample program can also be found on your i-TRiLOGI installation folder at: C:\TRiLOGI\TL6\usr\samples\PulseMeasurement.PC6


I'd suggest that you use the pulseperiod() function so that you measure a full cycle of the input pulse train.

Gary D*ckinson

69
Technical support / Re:Jog Moves with Step / Dir
« on: March 11, 2019, 06:51:29 PM »
Mark the number of steps before the stepper quits moving is about 2 billion.

If the step rate was 800 pulse/sec with the maximum step count your fan would run for about 31 days before it stops.

What is the expected max time that the fan needs to run? 1 day, 1 week or one month?  2 billion steps will handle it.

If your max run time is measured in minutes or hours, just program it for the max step count of &h7ffffff every time you run the fan.

If you are looking for variable speed to meet your air flow requirements, then the use of steppers system is not ideal.  I think that you will have to abort the current stepmove command and physically stop the stepper before changing the speed. This may be audibly annoying.

Gary D

70
Technical support / Re:Jog Moves with Step / Dir
« on: March 08, 2019, 07:36:19 PM »
Mark,

The PLC supports some number of PWM (pulse width modulation) channels. You could use one of these channels as the source of pulses for your stepper driven fan.  You can control the pulse (step rate) via the SetPWM statement in TBASIC.

SetPWM allows you to control the pulse rate and the duty cycle. For your application you need only 2 duty cycles, 50% and 0%.  The 0% value stops the pulses.

I have used the PWM mechanism to control fan speed.  My customer used a DC fan that accepted a PWM signal to control fan RPM.

Stepper motors are not, typically, used for fans for a lot of good reasons.

Fans used to cool CPU chips and mother boards are variable speed.  The fans with 4 wires use a 0..5 VDC PWM signal to control fab speed. These fans are cheap and plentiful.  

The PLC's PWM system will work with the 4 wire fans if you limit the signal to 0..5 V.

Best regards,

Gary D*ckinson

71
Technical support / Re:Perplexed by puzzling parentheses pecualiarity
« on: March 07, 2019, 11:19:21 AM »
Neal,

I am glad that you were able to get the PLC firmware sorted out for your client.

Please feel free to contact me if you have questions with how to get the most out of these PLCs.  My email address is in my profile on the forum.

Thanks,

Gary D*ckinson

72
Technical support / Re:Perplexed by puzzling parentheses pecualiarity
« on: February 20, 2019, 11:01:04 AM »
Neal,

I suggest that you try this equation to convert from C to F:

     F = (C * 9) / 5 + 32

That equation just forces the multiply before the division operation.  It gets you more accurate results when you are limited to integer math.

This is my spreadsheet results comparing doing the conversion with floating point vs. integer math:

C   F Float   F Integer   Error %
0   32.0           32           0.000
1   33.8           33           2.424
2   35.6           35           1.714
3   37.4           37           1.081
4   39.2           39           0.513
5   41.0           41           0.000
6   42.8           42           1.905
7   44.6           44           1.364
8   46.4           46           0.870
9   48.2           48           0.417
10 50.0           50           0.000

If you can tolerate the size of the errors then your are good to go!

Best regards,

Gary D* ckinson

73
Technical support / Re:Perplexed by puzzling parentheses pecualiarity
« on: February 19, 2019, 04:36:25 AM »
Integer math and operator precedence is the answer to your perplexity.

9 divided by 5 is 1 with integer math.

Your spreadsheet and your calculator are doing floating point math. 9 divided by 5 is 1.8 with floating point math.  That is why the results are different then when you use a spreadsheet or a calculator.

Operator precedence.  The parenthesis in your expression:

     F = (C * (9/5)) +32

Forces TBASIC to perform the 9/5 division first.  Remember that 9/5 is 1.  The next thing TBASIC does is multiply the value of C by 1. Then TBASIC adds 32 and finally will assign the results of the arithmetic expression to the variable F.

I do not know how smart TBASIC's expression parser is.  If it was really smart it would, at compile time, precompute that the division of the constant subexpression 9/5 to be 1 and not actually do a division at run time. If may, also, recognize that the multiplication of the variable C by 1 is always the value of C.  TBASIC could simplify your expression to this because this is exactly what you wrote:

  F = C +32
Rule #1 for integer math is to do all your additions and multiplications first.  Do your division last to preserve accuracy.

You might want to rethink how you are converting an ADC value to temperature in F.  if you need F go from ADC units directly to F.

I would used scaled integer values.

I would, also, oversample the ADC so that I are working with a 14 bit ADC value rather than the advertised 12 bit value.

Gary D*ckinson

74
In most cases I have copied directly from the CF editor.  Sometimes
I have copied to the application, Notepad++, from the CF editor and made some changes and then copied from Notepad++ into the forum.

Today, I cannot create the issue by copying into the forum message editor from either the CF editor or from Notepad++.

What I can do is to replace the tabs with spaces using Notepad++ and this will allow me to retain a hint of the formatting that use for writing TBASIC CFs.

I won't worry this odd behavior any more.  It just was unusual that old posts started coming up with odd characters days of years after they were created.

Tanks for giving it a look.

Best regards,

Gary D*ckinson

75
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

Pages: 1 ... 3 4 [5] 6 7 ... 34