ColorCNC Colorlight 5A-75E/5A-75B as FPGA controller board

More
23 Feb 2023 12:44 - 23 Feb 2023 14:19 #265115 by deroj
How can I see wether a new module is included?
I used the template generator. Then

litexcnc intsall_driver
litexcnc buuild_firmware ".../test.json" --build

But to build firmware I would have to add some lines for an additional module, or not?

When I go into the module folder and run poetry install it complains, that I need litexcnc (^1.0.0). 

poetry add git+https://github.com/Peter-van-Tol/LiteX-CNC#11-add-external-extensions-to-litexcnc[cli] installs 0.9.0a5
Last edit: 23 Feb 2023 14:19 by deroj.

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

More
23 Feb 2023 21:25 #265153 by TOLP2
@deroj
Today I found an evening to solve some of the problems you've just run into. 
  1. When I go into the module folder and run poetry install it complains, that I need litexcnc (^1.0.0). 
    To solve this, remove the line 'litexcnc = "^1.0.0" from the file pyproject.toml. The re-add litexcnc with the following command poetry add "git+https://github.com/Peter-van-Tol/LiteX-CNC#11-add-external-extensions-to-litexcnc[cli]"
  2. When you have the latest commit of the above mentioned branch, your source file will be automatically detected. However, this requires a split between the configuration and the firmware. This is required because otherwise Litex is required on your CNC, which is quiet a hefty import, while it is not used for the driver, but only for the firmware. 
An example of the split you can now find on my  toolerator module .

When I compile this, it will show the driver source is copied and then installed:
sudo -E env PATH=$PATH litexcnc install_driver

OUTPUT:
INFO: Retrieving main driver to compile...
Copying file 'watchdog.c'
Copying file 'watchdog.h'
Copying file 'halcompile.py'
Copying file 'wallclock.h'
Copying file '__init__.py'
Copying file 'wallclock.c'
Copying file 'litexcnc.h'
Copying file 'litexcnc.c'
Copying file 'pos2vel.h'
Copying file 'pos2vel.c'
INFO: Retrieving modules to compile...
Copying file 'litexcnc_encoder.c'
Copying file 'litexcnc_encoder.h'
Copying file 'litexcnc_gpio.c'
Copying file 'litexcnc_gpio.h'
Copying file 'litexcnc_pwm.c'
Copying file 'litexcnc_pwm.h'
Copying file 'litexcnc_stepgen.c'
Copying file 'litexcnc_stepgen.h'
Copying file 'litexcnc_toolerator.c'
Copying file 'litexcnc_toolerator.h'
INFO: Retrieving board drivers to compile...
Copying file 'litexcnc_eth.c'
Copying file 'litexcnc_eth.h'
Copying file 'etherbone.c'
Copying file 'etherbone.h'
INFO: Compiling LitexCNC driver...
Compiling realtime litexcnc.c
litexcnc.c: In function ‘litexcnc_register’:
litexcnc.c:492:1: warning: label ‘fail0’ defined but not used [-Wunused-label]
 fail0:
 ^~~~~
Linking litexcnc.so
cp litexcnc.so /usr/lib/linuxcnc/modules/
Compiling realtime pos2vel.c
Linking pos2vel.so
cp pos2vel.so /usr/lib/linuxcnc/modules/
Compiling realtime litexcnc_encoder.c
Linking litexcnc_encoder.so
cp litexcnc_encoder.so /usr/lib/linuxcnc/modules/
Compiling realtime litexcnc_gpio.c
Linking litexcnc_gpio.so
cp litexcnc_gpio.so /usr/lib/linuxcnc/modules/
Compiling realtime litexcnc_pwm.c
Linking litexcnc_pwm.so
cp litexcnc_pwm.so /usr/lib/linuxcnc/modules/
Compiling realtime litexcnc_stepgen.c
Linking litexcnc_stepgen.so
cp litexcnc_stepgen.so /usr/lib/linuxcnc/modules/
Compiling realtime litexcnc_toolerator.c
Linking litexcnc_toolerator.so
cp litexcnc_toolerator.so /usr/lib/linuxcnc/modules/
Compiling realtime litexcnc_eth.c
Linking litexcnc_eth.so
cp litexcnc_eth.so /usr/lib/linuxcnc/modules/
INFO: LitexCNC driver installed

After compiling the code, you can test whether the driver can be loaded into the HAL, by starting halrun. For example for the toolerator:
halcmd: loadrt litexcnc
Note: Using POSIX realtime
litexcnc: Loading Litex CNC driver version 1.1.0
litexcnc: Loading and registering default modules:
litexcnc: Registered module gpio
litexcnc: Registered module pwm
litexcnc: Registered module encoder
halcmd: loadrt litexcnc_toolerator
litexcnc: Loading Litex toolerator module driver version 1.0.0
litexcnc: Registered module toolerator

Please note that the default module stepgen is not yet enabled in the branch. Will come this weekend.
The following user(s) said Thank You: Pro_El

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

More
24 Feb 2023 11:53 - 24 Feb 2023 15:16 #265222 by deroj
maybe i am too stupid again.
how do I tell the cli to use the poetry environment?
litexcnc install_driver just installs the three standard .so
litexcnc, litexcnc_eth and pos2vel

in home directory I do
poetry add "git+https://github.com/Peter-van-Tol/LiteX-CNC#11-add-external-extensions-to-litexcnc[cli]"

then "litexcnc install_driver"

with poetry shell it tells me it activates the folder in /home/.cache/.....
but still compiles only these three files

I am missing something

I am thinking about to reset my virtual maschine and start from scratch.
In which order do I have to install things?


So I gave it another try and copied the litexcnc folder from the poetry cache to the python site-packages folder.
I also copied the .c and .py file wich were generated by the template to the driver and firmware folders.
when i run "sudo ... litexcnc install_driver" I get this...

sudo -E env PATH=$PATH litexcnc install_driver
INFO: Retrieving main driver to compile...
Copying file 'watchdog.h'
Copying file 'litexcnc_debug.h'
Copying file 'litexcnc_serial.c'
Copying file 'stepgen copy 2.c'
Copying file 'encoder.h'
Copying file 'litexcnc.c'
Copying file 'gpio.h'
Copying file 'stepgen.h'
Copying file 'litexcnc_debug.c'
Copying file 'pos2vel.so'
Copying file 'litexcnc_serial.h'
Copying file 'halcompile.py'
Copying file 'gpio.c'
Copying file 'etherbone.c'
Copying file 'stepgen copy2.h'
Copying file 'watchdog.c'
Copying file 'wallclock.c'
Copying file 'pwm.c'
Copying file 'crc.c'
Copying file 'etherbone.h'
Copying file 'litexcnc_eth.so'
Copying file 'crc.h'
Copying file 'litexcnc.so'
Copying file 'litexcnc_eth.h'
Copying file 'litexcnc.h'
Copying file 'stepgen copy.c'
Copying file 'wallclock.h'
Copying file 'litexcnc_eth.c'
Copying file '__init__.py'
Copying file 'encoder.c'
Copying file 'pwm.h'
Copying file 'stepgen.c'
Copying file 'pos2vel.h'
Copying file 'pos2vel.c'
INFO: Retrieving modules to compile...
INFO: Retrieving board drivers to compile...
INFO: Compiling LitexCNC driver...
Compiling realtime litexcnc.c
litexcnc.c: In function ‘litexcnc_register’:
litexcnc.c:492:1: warning: label ‘fail0’ defined but not used [-Wunused-label]
 fail0:
 ^~~~~
Linking litexcnc.so
cp litexcnc.so /usr/lib/linuxcnc/modules/
Compiling realtime pos2vel.c
Linking pos2vel.so
cp pos2vel.so /usr/lib/linuxcnc/modules/
INFO: LitexCNC driver installed

So I think I don´t understand the basics from your workflow
Last edit: 24 Feb 2023 15:16 by deroj.

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

More
24 Feb 2023 15:33 #265242 by TOLP2
To run litexcnc in your poetry environment, please use:

sudo -E env PATH=$PATH poetry run litexcnc install_driver

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

More
25 Feb 2023 20:58 #265351 by TOLP2
Just finished the litexcnc_toolerator module (see this repo for the code). Based on this code I'm going to improve the template and LitexCNC on the following points:
  • the driver files will get an __init__.py file in the folder. The purpose of this file is to list all source and header-files for the driver. This makes manual bookkeeping in the config a lot easier. Also, this prevents the import of the config models completely; which makes it possible to combine the config and firmware again. The split felt unnatural to me, as the config only acts on the firmware.
  • the command install_driver will get an option to select which parts to install. This can speed up the development of new modules, as changes to 1 module does not require a complete recompilation.
  • the HAL component litexcnc will get an optional parameter extras, which will enable loading extra modules by their name. For example the toolerator can be called with loadrt litexcnc extras="toolerator". This will spare you an extra line in your HAL-file ;).
  • the HAL component litexcnc will get an optional parameter connection, which allows you to directly connect to your board by the connection string. The connection string consists out of the protocol (currently only eth) and then the address with a semi-colon as a separator. An example would be loadrt litexcnc connection="eth:10.0.0.10". This function can be combined with the earlier mentioned extras, so for my Emco 5 CNC, it would become loadrt litexcncextras="toolerator"  connection="eth:10.0.0.10".
The template is going to be updated with all the little things I've experienced so far.

Did you know ...
That if you create a HAL struct for the pins, that those pins must be connected in the driver with hal_pin_<type>_new orhal_pin_<type>_newf. Forget to do this, and the core will be dumped. Spent one evening on solving this one ...

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

More
26 Feb 2023 12:36 #265414 by wuyatom
[codenet x-index-enable => pid.x.index-enable <= joint.0.index-enable => [LITEXCNC](NAME).encoder.00.index_enable
        net x-enable      pid.x.enable  <= joint.0.amp-enable-out  => [LITEXCNC](NAME).stepgen.00.enable => [LITEXCNC](NAME).gpio.j11:1.out
        
        net x-pos-cmd       joint.0.motor-pos-cmd => pid.x.command
        net x-vel-fb        [LITEXCNC](NAME).encoder.00.velocity => pid.x.feedback-deriv
        net axis.0.motor-pos-fb <= [LITEXCNC](NAME).encoder.00.position => pid.x.feedback
        net x-output       pid.x.output => [LITEXCNC](NAME).stepgen.00.velocity-cmd][/code]
Is there a problem with the syntax of my encoder connection? I don't know whether there is a problem with my hal or my hardware connection

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

More
26 Feb 2023 18:34 #265431 by TOLP2

[code]
net x-index-enable => pid.x.index-enable <= joint.0.index-enable => [LITEXCNC](NAME).encoder.00.index_enable
net x-enable      pid.x.enable  <= joint.0.amp-enable-out  => [LITEXCNC](NAME).stepgen.00.enable => [LITEXCNC](NAME).gpio.j11:1.out
        
net x-pos-cmd       joint.0.motor-pos-cmd => pid.x.command
net x-vel-fb        [LITEXCNC](NAME).encoder.00.velocity => pid.x.feedback-deriv
net axis.0.motor-pos-fb <= [LITEXCNC](NAME).encoder.00.position => pid.x.feedback
net x-output       pid.x.output => [LITEXCNC](NAME).stepgen.00.velocity-cmd
[code]
Is there a problem with the syntax of my encoder connection? I don't know whether there is a problem with my hal or my hardware connection
 

Could you please explain what you are trying to achieve. Without this, it is difficult to judge what the problem might be. Please:
  • add your machine config, so we can try to replicate your error;
  • give a description of what the machine should do;
  • give a description of what the machine is actually doing.
From what I can see from this code is that you are trying to 'close the loop'. You want to use an encoder as feedback and adjust based on this value. I think this is not something which can be done out-of-the-box. The reason is the way the communication is done:
  • T = 0 cycle: LinuxCNC reads the FPGA and thus encoder position, which is the current position;
  • T = 0.1 cycle:  LinuxCNC processes the information and determines how fast the motor should move to get to the wanted position;
  • T = 0.5 cycle: The data is then send to the FPGA, together with an apply time. From this timestamp the movement is started and this will be in the future;
  • T = 0.5 cycle: The FPGA processes the data, but is not moving yet as it awaits the apply time.
  • T = 0.9 cycle: The FPGA commands the steppers to move
  • T = 1.0 cycle: .... the process starts again.
When closing the loop one MUST take into account that the received position lags one full cycle behind commanded position. Because of this, the stepgen module also has the pin 'position-predicted', which makes a forecast where the stepper shall be. This pin has been created to give motmod  the feedback it requires. If you want to connect a stepper you would either:
  • have to close the loop in the FPGA;
  • have to make a module which can predicted the position at the start of the next cycle.
IMO: the first option would be the best.

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

More
27 Feb 2023 02:51 #265472 by wuyatom
I think the input of 5A-75E is connected to the encoder output interface of the servo driver to achieve full closed-loop control 

File Attachment:

File Name: file_0191eb5.hal
File Size:11 KB
 

File Attachment:

File Name: file_15cfcd5.ini
File Size:5 KB
 

File Attachment:

File Name: 5a-75e_v7....2-26.txt
File Size:5 KB
Attachments:

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

More
27 Feb 2023 17:11 #265508 by deroj

To run litexcnc in your poetry environment, please use:

sudo -E env PATH=$PATH poetry run litexcnc install_driver
 

Sorry...This doesn´t work either.
oj@VMLinuxCNC:~$ sudo -E env PATH=$PATH poetry run litexcnc install_driver
[sudo] Passwort für oj: 

/home/oj/src/litexcnc does not contain any element

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

More
27 Feb 2023 21:29 #265519 by TOLP2

I think the input of 5A-75E is connected to the encoder output interface of the servo driver to achieve full closed-loop control 

File Attachment:

File Name: file_0191eb5.hal
File Size:11 KB
 

File Attachment:

File Name: file_15cfcd5.ini
File Size:5 KB
 

File Attachment:

File Name: 5a-75e_v7....2-26.txt
File Size:5 KB

There is one thing missing in your HAL-file: you have to connect the feedback of the position to the motmod. The pin joint.N.motor-pos-fb is currently not connected in your HAL. This will cause joint following errors, because the motmod won't see your axis responding to the input.

If you don't use your encoders, you can connect it like this (see also litex-cnc.readthedocs.io/en/latest/modules/stepgen.html ):
net xpos-fb  <= [LITEXCNC](NAME).stepgen.00.position_prediction
net xpos-fb  => joint.0.motor-pos-fb
 When you want to close-the-loop with using the encoders, you have to find your way to get the information to back to motmod.

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

Moderators: PCWjmelson
Time to create page: 0.122 seconds
Powered by Kunena Forum