HAL CiA402 Drive Interface for Can Bus,Ethercat etc...

More
5 years 2 months ago #217309 by db1981
thread order:

first lcec.read-all, , at last lcec.write-all.

please attach the hal file for checking this.

Please Log in or Create an account to join the conversation.

More
5 years 2 months ago #217320 by JimPanski
Hi Dominik,

yes, my hal had that in the right order - only I had it the wrong war round im my head.
see attached hal

Please Log in or Create an account to join the conversation.

More
5 years 2 months ago - 5 years 2 months ago #217323 by db1981
Hi,

sorry, but this can't work :
addf motion-command-handler servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf lcec.read-all servo-thread
addf lcec.write-all servo-thread
addf cia402.0.read-all servo-thread
addf cia402.1.read-all servo-thread
addf cia402.0.write-all servo-thread
addf cia402.1.write-all servo-thread
addf pid.s.do-pid-calcs servo-thread
addf classicladder.0.refresh servo-thread
#addf spi_interlock servo-thread
addf carousel.0 servo-thread
addf near.0 servo-thread
addf scale.0 servo-thread

The function execution order is an fundamental part of every machine control, plc, software programm etc. 
I explained this a few times in the ethercat thread, also in the doc for the 402 component and it is good explained in the
"Hal introduction" and "Hal Basics" Chapter of the linuxcnc docs .....

In an Microcontroller or Realtime Program you have an task. (example servo-thread) this task is executed in an specified rate (examble every 1ms) . Into this task you have to add programms (functions) that do certain things. if you got more then one function and they have to interact together it is important  which is the first that is executed.  Injecting fuel after the ignition of the spark plug  will not work...

In an hal-thread the functions are executed as they are added in the hal file (addf).

looking at this:
 
addf motion-command-handler servo-thread

addf motion-controller servo-thread

addf lcec.read-all servo-thread

addf lcec.write-all servo-threadyour task starts and do the calculating of the motion part, but you have not readed the position and other values from the hardware yet. the result is that motions uses the old value from the last cycle. If you have a PID Systems this would let to horible behaviour.... The correct order would be :

-First read from hardware 
-motion calculations 
-(pid calculations)   (important: pids after motion!) 
-last write to hardware (with the new calculated values from this cycle)

this also is important for the 402 component and for scale/near components. You need the actual values from this cycle. 

The correct order for your hal would be:

addf lcec.read-all servo-thread
addf cia402.0.read-all servo-thread
addf cia402.1.read-all servo-thread
addf scale.0 servo-thread scale in front of near, because it calcs the input for near and motion
addf near.0 servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.s.do-pid-calcs servo-thread
addf classicladder.0.refresh servo-thread
#addf spi_interlock servo-thread
addf carousel.0 servo-thread
addf cia402.0.write-all servo-threadaddf cia402.1.write-all servo-threadaddf lcec.write-all servo-thread

i hope this helps, i think the behaviour should now changed. At your old order the pos_cmd (with the new home pos) arrived one cycle later as the mode switch bit. so the drive would have seen zero or another value instead of the new readed fb_pos and it says fb-err at this moment.
 hmm, hab gerade erst in der hal gesehen das ich mir gar keinen in Denglisch hätte abbrechen müssen..... 

 

Last edit: 5 years 2 months ago by db1981.
The following user(s) said Thank You: JimPanski

Please Log in or Create an account to join the conversation.

More
5 years 2 months ago #217378 by JimPanski
Hi Dominik,

now we're cooking! Thank you so much!
This is so embarrassing, sorry for ignoring the really basics :/
Also thinking doing english things in this intern. part of the forum seems to be very okay ;)

Greetz
Conny

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #229760 by rodw
Hi, I've been trying hard to get my cia402 drives using this component and have had no luck with homing.
The drives can home to a home switch. At this stage I am just using a proximity sensor connected to the motor on the bench.
If I commence homing, the motor takes off and when I activate the home switch it stops. but if I leave it there too long I get a following error
If I deactivate the sensor, I the drive continues moving again.
I have my config in Git
github.com/rodw-au/linuxcnc-cia402

Hal FIle:  github.com/rodw-au/linuxcnc-cia402/blob/main/cia402.hal
Ini File:  github.com/rodw-au/linuxcnc-cia402/blob/main/cia402.ini
XML FIle:  github.com/rodw-au/linuxcnc-cia402/blob/main/ethercat-conf.xml
I did try the suggested change to the source but it only prevented all movement but the DRO's were changing.
I would appreciate some guidance.

 

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #229764 by db1981
Hi,

please try what happens if you set home_search_velocity to zero.

Using the drives internal home functions with this component is like a work around, to prevent changing a lot in lcncs internal home procedure.

There are no official pins to get the home command from motion. Related to this
i only use the index_homing part from the lcnc internal homing part. For the index homing the pin index_enable exists.
the behaviour should be like this:

-start home (search_velocity = 0)
-lcnc internal homing jumps to the state home_on_index
-lcnc sets joint.x.index_enable to 1
-with index_enable at 1, the CIA402 starts the internal home routine of the drive
-if the drive finished homing, CIA sets joint.x.index_enable to 0.
-lcnc detects the end of the index search run and reads the enc_pos and finished homing.

If you got following errors, try to set the home_latch_velo to the same velocity you have configured in your drive for homing.

Please Log in or Create an account to join the conversation.

Time to create page: 0.370 seconds
Powered by Kunena Forum