Author Topic: Programming Help  (Read 24361 times)

Will S

  • Guest
Programming Help
« on: January 14, 2003, 07:31:59 PM »
Since I dont have much programming experience, I am looking for some help to write a program.  
One of my customers has 8 wood lathes used to make spindles for stair railings.  He would like to automate the system.  Right now they have to manually set hydraulic sequence valves each time they want to change to a different spindle pattern.  The unit consists of an infeed to the knifes and a rotation motor for the spindle.
 I would like to set up an M-series plc to run both of these axis.  I would use a linear resistor to sense the position of the feed head.  At certain setpoints of the infeed cycle I would want to increase or decrease the feed speed.  I would also want this to be user configurable using a HMI-M input and display device.
  
Corresponding with the position of the feed head, I would also like to vary the speed of the spindle motor.
The system already had the required hydraulics to do the work, the only thing I would need are two hydraulic proportional valves.  
I would like to use the two analog outputs to run these devises, 0-5Vdc will work very well.  I know the output is only 8 bit which would mean that over the length of the travel of the feed head there would only be 255 discreate positions, but I am not worried about accuracy because cycle speed is more important.  The final finishing cut can use the mechanical stops to ensure accuracy of the finished product.  
So in a nutshell what I would need is the HMI to display current position of the feed head, a manual jog feed input, emergency stop input, analog input for the linear resistor, 2 analog outputs 0-5Vdc, and 2 digital outputs for spindle clamping cylinder solenoid valves.  I would need the HMI to display current position of the feed head and have input keys for setting the 3 setpoints required.
What I am looking for is someone to hold-my-hand, as it were, to get this program off the ground.  I am pretty good at figuring things out from there but I don't really know where to start on this one.  Any assistance would be appreciated.  All I would need is help with the programming as I have everything regarding the wiring and hydraulics.

Thanks Will
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: Programming Help
« Reply #1 on: January 15, 2003, 02:16:42 PM »
You can set up a basic ladder + BASIC loop as follow:

? Clk:0.1s ? ? ?           Fn_#10
|------||------------{dCusF}


Custom function #10 is a differentiated version, meaning that it executes only once every time the contact closes. In this case, we use a 0.1s clock pulse to trigger Fn_#10. That means that function #10 will be execute once every 0.1s.

You can then add TBASIC codes to Fn_#10. You can read the position of the feed head connected to ADC #1 using the statement:

 ? X = ADC(1)

Once you get the data, you can then perform computation on it and then make a decision on what to set on the DAC output by using the SETDAC command. That's it!

This should provide a starting point on your control. You can view many examples in the folder:

C:\TRiLOGI\TL5\usr\samples

There are also examples for programming the HMI in the folder: ?

C:\TRiLOGI\TL5\usr\samples\HMI

There is no short cut way of learning programming. But the built-in simulator in TRiLOGI should help you tremendously in your program learning since you don't have to connect the hardware in order to test the program. You can enter the ADC data in the simulator windows and observe the changes in the DAC output directly on your PC.

I hope this helps. If you need to hire a professional programmer to help you we can refer someone to call you. Just provide us your details to "support@tri-plc.com".
« Last Edit: December 31, 1969, 04:00:01 PM by -1 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Will S

  • Guest
Re: Programming Help
« Reply #2 on: January 15, 2003, 03:11:58 PM »
Thanks a lot, that should get me started.  If this works I will want to link the 8 machines to a central server for monitoring the data.  But that is a long way down the road from here.  I will keep you posted, as I will no doubt have other questions.

Thanks

Will
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

WSteed

  • Guest
Re: Programming Help
« Reply #3 on: January 19, 2003, 05:18:19 PM »
Okay, now that I have the data from the analog channel, how would I dispay this data continuously on the LCD.  I tried the SETLCD command, but I don't think I have it down properly.  Would it be:

X = ADC(1)
SETLCD 1,1, (X)

Thanks inadvance for your help.

Will Steed
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

WSteed

  • Guest
Re: Programming Help
« Reply #4 on: January 19, 2003, 05:54:40 PM »
I should have added this to my last post.  What I want to do is have 3 setpoints on the infeed ( one analog out channel ).  Will I be able to have the analog output vary depending on the value of the analog input.  If that is possible will it also be possible to have the setpoints user configurable via the HMI-M.  

I know these are pretty general questions, but I would like a bit more info before I get too deep into this project and then find out it is not possible.

Thanks,

Will Steed
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: Programming Help
« Reply #5 on: January 20, 2003, 03:23:16 PM »
If you have a periodically executed Custom function, and inside the function you put the following statement:

 ? SETDAC 1, ADC(1)/2

What will happen is that the analog output #1 will be set at 1/2 the value of the voltage received at ADC #1. Hence the analog output follows the analog input via according to a mathematical expression which is up to you to define. ?You can connect a potentiometer to ADC #1 to input value to the PLC.

Using the HMI, you can enter the value into the PLC via the keypad. Assuming that the entered value is 0-100% and is stored into variable X, then :

 ? ?SETDAC 1, X *4096/100

will set the output to x% of the full scale output. ?This is the basic proportion control loop. For more complex dynamics you can use PID functions to achieve zero offset error and better transient characteristics.

« Last Edit: December 31, 1969, 04:00:01 PM by -1 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

WSteed

  • Guest
Re: Programming Help
« Reply #6 on: January 20, 2003, 07:09:32 PM »
Thats a great help, I will try that out tonight.  But one more little thing, what is the command to display the value of X on the LCD, is it SETLCD and if so could you please show me an example.

Thanks again for all your help

Will Steed
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: Programming Help
« Reply #7 on: January 20, 2003, 08:37:57 PM »
Please read the programmer's reference manual for TBASIC for examples. There are also a lot of examples in the  ....\usr\samples folder that utilizes the SETLCD command. It is really easy to use.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

WSteed

  • Guest
Re: Programming Help
« Reply #8 on: January 21, 2003, 03:03:15 PM »
Thanks, I can take the hint.  Actually I figured my own question out last night.  I can't believe how easy it is to program complex processes with this plc.  Thanks for the help.

Will Steed
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: Programming Help
« Reply #9 on: January 21, 2003, 08:07:57 PM »
You are most welcome!  Thank you for your interest in exploring our PLCs.  Many of our users do find that M-series is far easier to program than they had initially thought.  I hope you will have an enjoyable time exploring all the features of this amazing controller.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Ken W Talley

  • Guest
Re: Programming Help
« Reply #10 on: January 22, 2003, 07:30:04 PM »
Will,

If you ever feel like asking a question from someone other than customer support and want to ask a question of an end user please email me.  I am very intrigued by the abilities and ease of programming that these things can do.  I have been down the same road and will continue to find uses for these products in my future needs.  I don't know very much but I would like to lend a hand.  Reason being that I think I have a lot more that I could learn as to the products applications.  I am a road construction guy that wanted to build a better product than what was available.  Anyway if you or any other users would like an outside view or help on an idea, I would be more than willing to try to help.  To me I am still in the new lawn mower stage. translated if you have to mow the lawn every weekend it sucks but if you just got a new lawn mower it is fun.  Anyway my email is Ken.Talley@chipseal.com.

These guys have a kick ass product and I am willing to help promote it to make sure that it stays around.  Don't want to see a years worth of developement (application was a pain in the ass) go by the wayside.  Not saying these guys need any help but would love to see it develope and all of us users benefit by their continuing success.

« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »