how to get the status of motor (tmcl-140-42-232)

how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 27 May 2011, 05:21

dear sir:
here a few codes list below to make motor ( drived by tmcl-140-42-232) turn left when the general input 0 is high level and turn right when the

general input 1 is high level (a left limit switch and a right switch are added,).
SGP 77, 0, 1
SAP 4, 0, 1000 //set maximum positioning speed
SAP 5, 0, 500 //set maximum acceleration speed
SAP 6, 0, 100 //set absolute maximum current
SAP 7, 0, 20 //set standby current
SAP 12, 0, 0 //right limit switch enable
SAP 13, 0, 0 //left limit switch enable
SAP 140, 0, 5 //set microstep resolution ,32 microsteps
SAP 153, 0, 7 //set ramp divisor ,2 exp 7
SAP 154, 0, 3 //set pulse divisor ,2 exp 3

SAP 195, 0, 4 //set home speed
SAP 193, 0, 3 //3,first search right ref switch


ROR 0, 1000 //speed 1000
WAIT LIMSW, 0, 0 //until limit switch is hit
//JC ETO, RefErr

MST 0 // stop motor 0
SAP 1, 0, 0 // set current position(actual position) 0
MVP REL, 0, -1500
WAIT POS, 0, 0
MST 0
SAP 1, 0, 0

//main program
LOOP1://first stop the motor
MST 0
GIO 0, 0 //get status of digital inputs 0 ,port number 0, bank number 0
COMP 1 //compare with 1
JC EQ, LEFTRUN //if status is 1,jump to leftrun,left move
GIO 1, 0 //get status of digital inputs 1
COMP 1 //compare with 1
JC EQ, RIGHTRUN //if status is 1,jump to rightrun,right move

JA LOOP1

LEFTRUN: GIO 0, 0 //leftrun subprogram
COMP 1 //compare with 1
JC NE, LOOP1 // if status is 0,jump to loop1
MVP ABS, 0, 0
WAIT POS, 0, 0
JA LEFTRUN

RIGHTRUN: GIO 1, 0 //right run subprogram
COMP 1 //compare with 1
JC NE, LOOP1
MVP ABS, 0, -10000
WAIT POS, 0, 0
JA RIGHTRUN
STOP

now if the upper pc want to know the current status of motor(send query instruction to general input 0 and 1,and output from general output 0 and

output 1 ),such as currently the motor is stopped right direction or stopped left direction when motor stopped(when the motor is stopped right direction ,sio 0 ,2 ,0;when the motor is stopped left direction ,sio 1,2 ,0).

what the program code like? thanks a lot!
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 27 May 2011, 07:28

by the way ,the step-motor has no encoder.should we use " sap 1,0,0" or use accu parameter to fulfill the function?
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby Olav Kahlbaum (TRINAMIC) » 27 May 2011, 07:44

The host PC can query any parameter at any time - also while a TMCL program is running on the motor. So the PC only has to send e.g. a GAP 3, 0 command to get the actual motor velocity and will get the answer. This will not disturb the TMCL program running on the module (as commands given in direct mode do not modify the accu or the flags).

When there is no encoder, SAP 1, 0, 0 is correct to set the actual position to zero (always do a MST 0 command before changing the actual position).
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3363
Joined: 11 Aug 2006, 08:02

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 27 May 2011, 08:17

thanks a lot.
but the host pc is not connected with tmcl-140-42-232 through rs232.the host pc only communicate with tmcl-140-42-232 by general input 0 and 1. the motor is controlled by code writed in tmcl-140-42-232 and then auto start. so what can i do to fulfill the task list above(feedback the motor stop status to pc through general output 0 and 1)?
another question is that how to restart the program writed in tmcl-140-42-232 ?we know one method is turn off the power supply and turn on it.can the program be restarted through general input 0 and 1?we say if the host pc send a high or low level to tmcl140-42-232 through general input 0 or 1 ,the program writed in tmcl-140-42-232 then auto restarted.
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 27 May 2011, 09:16

does the code like list below :

SGP 0, 2, 0 //set 0 register to value 0
GAP 1, 0//get ctual position
AGP 0, 2 //put current value to register 0
//CALC ADD, 1 //the result is written back to the accumulator
GGP 0,2 // get current value from register 0
COMP 10000 //is 10000,the motor is stopped at left limit
JC EQ,RotateDirectionOutput1//GE - greater/equal
RotateDirectionOutput1:
sio 0,2,0
SGP 1, 2, 0 //set 0 register to value 0
GAP 1, 0//get ctual position
AGP 1, 2 //put current value to register 0
//CALC ADD, 1 //the result is written back to the accumulator
GGP 1,2 // get current value from register 0
COMP 0 //is 0,the motor is stopped at right limit
JC EQ,RotateDirectionOutput2//GE - greater/equal
RotateDirectionOutput2:
sio 1,2,0
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby Olav Kahlbaum (TRINAMIC) » 30 May 2011, 07:46

You will have to poll the status of the motor (e.g. the actual speed, the actual position or whatever you would like to monitor) and then set the output low or high, depending on that value. I think that your code snippet will do the job.
To restart the program, one would also have to poll an input and react on that (e.g. jump to the very beginning of the program). But there is no command to reset the module.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3363
Joined: 11 Aug 2006, 08:02

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 30 May 2011, 10:26

thank you very much.
now i have a difficult question to inqury of you.we need the tmcl-140-42-232 working power supply at the range of 22V-31.5V,but from the handbook we konw that tmcl-140-42-232 's power supply is 28.5V MAX.How can i do to solve it? can i add a 28V zener diode at the input of power(if the power supply exceeds 28V,it will work to clamp the power supply to 28V)?and anything esle to do(should the general output be added a 28V zener diode )?
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby TRINAMIC_BD » 31 May 2011, 09:37

Hello,

the maximum supply voltage of this module is determined by the 30V power MOSFETs. There is some headroom, but operation above the max. value is not safe. You should add a voltage regulator i.e. LM317 type set to 28V, so losses will be minimized, with a large output capacitor of 4700µF.
User avatar
TRINAMIC_BD
Site Admin
 
Posts: 2445
Joined: 25 Jul 2006, 12:21
Location: Hamburg (Germany)

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 31 May 2011, 17:12

thanks.
the tmcl-140-42-232 is demanded to work properly within the scope of 22Vdc to 29Vdc,and is not demanded to work properly within the scope of 29Vdc to 31.5Vdc.but when the too high power supply( 29Vdc to 31.5Vdc) is turned off,the tmcl-140-42-232 need not to be damaged.can the tmcl-140-42-232 be worked in the case of list above without any change ?
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 04 Jun 2011, 12:40

AND another question is how to get the current status,such as now the rotating direction of the the motor( there is no feedback sensor attched to the motor)the main code is list below,but i don't know how to add other code to complete the status check.
SGP 77, 0, 1
SAP 4, 0, 1000 //set maximum positioning speed
SAP 5, 0, 500 //set maximum acceleration speed
SAP 6, 0, 100 //set absolute maximum current
SAP 7, 0, 20 //set standby current
SAP 12, 0, 0 //right limit switch enable
SAP 13, 0, 0 //left limit switch enable
SAP 140, 0, 5 //set microstep resolution ,32 microsteps
SAP 153, 0, 7 //set ramp divisor ,2 exp 7
SAP 154, 0, 3 //set pulse divisor ,2 exp 3

SAP 195, 0, 4 //set home speed
SAP 193, 0, 3 //3,first search right ref switch


ROR 0, 1000 //speed 1000
WAIT LIMSW, 0, 0 //until limit switch is hit
//JC ETO, RefErr

MST 0 // stop motor 0
SAP 1, 0, 0 // set current position(actual position) 0
MVP REL, 0, -1500
WAIT POS, 0, 0
MST 0
SAP 1, 0, 0

//main program
LOOP1://first stop the motor
MST 0
GIO 0, 0 //get status of digital inputs 0 ,port number 0, bank number 0
COMP 1 //compare with 1
JC EQ, LEFTRUN //if status is 1,jump to leftrun,left move
GIO 1, 0 //get status of digital inputs 1
COMP 1 //compare with 1
JC EQ, RIGHTRUN //if status is 1,jump to rightrun,right move

JA LOOP1

LEFTRUN: GIO 0, 0 //leftrun subprogram
COMP 1 //compare with 1
JC NE, LOOP1 // if status is 0,jump to loop1
MVP ABS, 0, 0
WAIT POS, 0, 0
JA LEFTRUN

RIGHTRUN: GIO 1, 0 //right run subprogram
COMP 1 //compare with 1
JC NE, LOOP1
MVP ABS, 0, -10000
WAIT POS, 0, 0
JA RIGHTRUN
STOP
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby Olav Kahlbaum (TRINAMIC) » 06 Jun 2011, 08:06

You will have to add this to the main loop, too:
Code: Select all
    GAP 2, 0    //get actual speed
    COMP 0
    JC LT, NegDir
    SIO 0, 2, 1    //set output #0 high when running in positive direction
    JA PosDir
NegDir:
    SIO 0, 2, 0    //set outout #0 low when running in negative direction


Just add this to your main loop.
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3363
Joined: 11 Aug 2006, 08:02

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 07 Jun 2011, 10:31

thank you very much.
how to get the combination status of general input 0 and 1 ,such as when the general input 0 is low and general input 1 is high,then the motor rorate right;when the general input 0 is high and general input 1 is low ,then the motor rorate left;when the general input 0 is low and general input 1 is low ,restart the program;
i'm looking forward to your instruction.
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby Olav Kahlbaum (TRINAMIC) » 08 Jun 2011, 08:19

Code: Select all
Restart:
MainLoop:
    GIO 0, 0              //get the state of input 0
    JC NZ, Input0High
    GIO 1, 0              //input 0 is low, now get the state of input 1
    JC ZE, Inp0LowInp1Low
    ROR 0, 1000           //input 0 low, input 1 high => ROR
    JA MainLoop
Inp0LowInp1Low:           //both low => restart
    JA Restart

Input0High:
    GIO 1, 0              //input 0 is high, now get the state of input 1
    JC ZE, Inp0HighInp1Low
    MST 0                 //input 0 high, input 1 high => MST
    JA MainLoop
Inp0HighInp1Low:
    ROL 0, 1000           //input 0 high, input 1 low  => ROL
    JA MainLoop
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3363
Joined: 11 Aug 2006, 08:02

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 09 Jun 2011, 06:47

I am puzzled at how to check the position stepmotor stop at. A few code list below is recommended BY you.

GAP 2,0 //get target (next) speed //WHERENEVER STOPMOTOR STOPED,ALWAYS GET 0 IF USE "GAP 2,0 ,COMP 0 "?
COMP 0 //
JC LT, NEGATIVEDIRECTION //why use “lt”?
SIO 0,2,1 //set out-0(yellow) to high

JA POSITIVEDIRECTION //
NEGATIVEDIRECTION:
SIO 0,2,0 //set out-0(yellow) to low
。。。。。。。。。
But I think use “gap 1,0 “ to check the status will be better,does it?JUST LIKE :
GAP 1,0 //get actual position
COMP -295000//
JC EQ, StopAtRIGHTLimitSwitch
//if actual position is -295000, stop at RIGHT limit switch(THE MOTOR MOVE FROM 0 TO -295000,AND RETURN TO 0,I AM NOT SURE BECAUSE THERE IS NO FEEDBACK SENSOR ATTACHED TO THE MOTOR ,SO POSITION PRECISION IS A PROBLEM)
SIO 0,2,1 //set out-0(yellow) to low
SIO 1,2,0 //set out-1(orange) to high
JA ReturnToOriginal
StopAtRightLimitSwitch: //close the window
SIO 0,2,1 //set out-0(yellow) to low
SIO 1,2,1 //set out-1(orange) to low
THANKS!
Last edited by layman2008 on 14 Jun 2011, 08:26, edited 1 time in total.
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Re: how to get the status of motor (tmcl-140-42-232)

Postby layman2008 » 09 Jun 2011, 08:02

LOOP1://first stop the motor
MST 0
GIO 0, 0 //get status of digital inputs 0 ,port number 0, bank number 0
COMP 1 //compare with 1
JC EQ, LEFTRUN //if status is 1,jump to leftrun,left move
GIO 1, 0 //get status of digital inputs 1
COMP 1 //compare with 1
JC EQ, RIGHTRUN //if status is 1,jump to rightrun,right move

JA LOOP1

LEFTRUN: GIO 0, 0 //leftrun subprogram
COMP 1 //compare with 1
JC NE, LOOP1 // if status is 0,jump to loop1
MVP ABS, 0, 0
WAIT POS, 0, 0
JA LEFTRUN//which is the correct code here between "JA LEFTRUN" and "JA LOOP1",thanks



ANOTHER QUESTION:
Working procedure:the steel rope is draged by stepmotor.firstly the stepmotor run right to hit the right limit switch,then realease it.the coordinate is set to 0,0.
when the combination of the general input0 and the general input1 is 10,move right; the combination of the general input0 and the general input1 is 00,move left; the combination of the general input0 and the general input1 is 01,restart the program and the combination of the general input0 and the general input1 is 11,detect;during selfdetect procedure,the tmcm140 should output the position stepmotor stop at.and during selfdetect procedure,whennever left or right limt switch is hit,then first move a few distance,after this is done,research the home(right limit switch).
I am puzzled at how to check the position stepmotor stop at. A few code list below is recommended from you.

GAP 2,0 //get target (next) speed
COMP 0 //
JC LT, NEGATIVEDIRECTION //why use “lt”?
SIO 0,2,1 //set out-0(yellow) to high

JA POSITIVEDIRECTION //
NEGATIVEDIRECTION:
SIO 0,2,0 //set out-0(yellow) to low
。。。。。。。。。
But I think use “gap 1,0 “ to check the status will be better,does it?

GAP 1,0 //get actual position
COMP -295000//
JC EQ, StopAtLeftLimitSwitch

My code is list below,I am not sure that it will complete the Working procedure correctly.
would you please help me to check it ?thank you very much
Last edited by layman2008 on 14 Jun 2011, 08:24, edited 2 times in total.
layman2008
Power User
Power User
 
Posts: 16
Joined: 11 Apr 2011, 04:55

Next

Return to Trinamic Motion Control Language (TMCL)

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron