Author Topic: Robot control  (Read 7414 times)

scottsaunders

  • Guest
Robot control
« on: December 04, 2002, 03:17:47 AM »
???I have a robot with a gyroscopic sensor on board so when the robot moves anti-clockwise the sensor gives out a negative signal, and vice versa. the sensor is connected to the analogue input of my PLC and I would like it so the PLC monitors the robot in order to stop it rotating. I'm assuming I can use PID control but I am unsure how to program this. i looked at the user maual but that didn't help me much. I do have some experience of PID control so I know and understand the proportional, integral and differential equations.

Any help would be greatly appreciated ;D
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re: Robot control
« Reply #1 on: December 04, 2002, 05:05:02 AM »
What is the output that is used to control the movement of the robot (digital output, PWM or analog output)? If the robot is simply controlled by an on/off digital output then PID probably doesn't make much sense here since the output is either fully ON or fully OFF and cannot be controlled proportionally.

If you use PWM or analog output for the robot movement control then the PIDcompute function will compute the amount of output to be applied based on the error (E = Setting - Feedback) and the P, I and D parameters defined.  Check out some discussions regarding PLC's PID functions in this forum. One of the link is as follow:

http://www.tri-plc.com/cgi-local/yabb/YaBB.pl?board=Support;action=display;num=1034389389
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

scottsaunders

  • Guest
Re: Robot control
« Reply #2 on: December 04, 2002, 06:22:34 AM »
I know how a PID control system works but I'm having problems writing the programme for it. Is there any other examples which are not shown on this forum as I searched for "PID" but the other posts didn't help
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re: Robot control
« Reply #3 on: December 04, 2002, 06:02:46 PM »
Please check Chapter 5, Example 9 of the TBASIC Programmer's Reference for a sample PID program. It may looks deceptively simple, what with only two ladder rungs and two custom functions but it encapsulates most of what you need to do for PID control. Please study it in greater details and you will be able to modify it to suit your own needs.
« Last Edit: December 31, 1969, 04:00:12 PM by -1 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Ken

  • Newbie
  • Posts: 16
    • View Profile
Re: Robot control
« Reply #4 on: December 05, 2002, 07:07:55 AM »
Below is the code that I actually used for my application.  DM[102] is the setpoint or desired gallons per minute.  D is the actual gallons per minute.  819 scales the value.  I had to divide by 100 to scale result down.  V is the actual DAC value which is sent out to a slave.  The if statement is so that I do not develope an error when I am asking for no flow.


IF DM[102] > 0
E = (DM[102]-D)*819
A = PIDcompute(1,E)/100
V = A + 204800
ENDIF

Hope this helps.

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

scottsaunders

  • Guest
Re: Robot control
« Reply #5 on: December 10, 2002, 06:07:34 AM »
I have typed in the following  in PIDdef:

ch=1
lmt=4096
p=5
i=0.7
d=2

and for my PIDcompute i've typed in:

E=40960-ADC(1)*10
A=PIDcompute(1,E)
set PWM 4, (A + 8000)/100

when I try to download the prgram to the PLC it highlights "ch" in PIDdef and says "error: unknown keyword" what have I done wrong?
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

scottsaunders

  • Guest
Re: Robot control
« Reply #6 on: December 10, 2002, 06:14:45 AM »
sorry I'v just realised that you type it
PIDdef 1, 4096, 5, 1, 2

I'm still stuck on the compute part though it says I'm missing a comma (',')
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re: Robot control
« Reply #7 on: December 10, 2002, 07:15:31 PM »
The variable name in TBASIC are fixed: A , B, ....Z,
DM[1] to DM[4000], A$ to Z$. You can't define your own variable name such as "ch = 1" or "lmt = 4096".  These terms "ch", "lmt" are used in the documentation syntax to illustrate their purpose. You can either put in constant directly into PIDdef or use the predefined variable name to contain the value.

You can't just put PIDCompute (1, E) as a standalone statement since PIDcompute is a function. i.e. PIDcompute must return a value and either to be assigned to a variable or used in an expression like what Ken did.



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

scottsaunders

  • Guest
Re: Robot control
« Reply #8 on: December 11, 2002, 07:15:29 AM »
ok thanks
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »