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

More
09 Dec 2022 15:49 - 09 Dec 2022 15:51 #259008 by wuyatom
run code
The coordinates will still shift in the pause state, which will cause the servo motor to rotate at a slow speed and will not stop
Last edit: 09 Dec 2022 15:51 by wuyatom.

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

More
15 Dec 2022 14:44 #259558 by TOLP2
Finally managed to build some of the LitexCNC firmware. I've tried many combinations of Litex, Yosys and Nextpnr-ecp to find out why the synthesis was so slow. I have found a parameter which is a good prediction whether it will build or not: TRELLIS_COMB. I don't know what this parameter exactly is, my first guess was the combinatorial part of the design, but I'm not sure.

When using a lot data-fields this parameter could reach up to 75% or even more, which makes placement really ahrd for Nextpnr and thus long or impossible build times and timing constraints not met. Keep this at 60% and the build is a breeze. I found that this parameter is heavily affected by the number of parameters in the MMIO register. 

As every stepgen used at least 7 parameters, this was too heavy. The parameters were:
  • pos-fb;
  • speed-fb;
  • speed-target1;
  • speed-target2;
  • acceleration1;
  • acceleration2;
  • apply-time2
So I've reduced this list to a mere 4 items:
  • pos-fb;
  • speed-fb;
  • speed-target;
  • acceleration.
And finally I could get the thing to build.

However, this means parts of the proposed functionality (S-curve acceleration within each cycle) has gone lost. But I think I've found the maximum of the card in combination with open-source toolchain. Another good thing is that this change will also simplify the HAL...

Before I go to push this change to the repo, I've to modify the driver to re-align the data.
 
The following user(s) said Thank You: Pro_El

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

More
16 Dec 2022 11:26 #259628 by muvideo
Hello, in my last commits there are two small updates to make easier the firmware generation and management:
  • ini files for storing and retrieving the configuration: perupherals, pinout, harware details
  • GUI configurator utility, I was tired of editing endless lists of pins, this will make easier the board configuration (you'll need dearpygui library in python for this)
  • Lcnc on github
 
Attachments:
The following user(s) said Thank You: tommylight, TOLP2

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

More
17 Dec 2022 08:41 - 18 Dec 2022 21:47 #259719 by TOLP2
Really nice work! This is still on my 'most wanted' list. At the moment I use VsCode for this task. I aligned all the rows with data, so I can easily change 6 lines up a time with a shortcut. But better method is most welcome.

Status-update from Litex-CNC:
  • re-wrote the firmware so it compiles within minutes;
  • error checking the driver for the changes required for the re-write above. At this moment GPIO and PWM is working. Enabling stepgen leads to a core dump, so most likely a memory issue there.
  • could reproduce the large amount of 'Apply time exceeding timings'. Will put on a log on this error and plot the progress of the timings during usage.
  • the BOB are in! I've now BOB's for:
    • GPIO in: confirmed working,
    • GPIO out: second version, should work. First version had a P-channel FET mirrored as I mixed it up with an N-channel. Now confirmed working, able to switch 100 mA per channel (12 Volt), less at 24 Volt. 
    • stepgen (partly built, received missing parts (XOR-gate for hardware inversion of ENA and ALARM)
    • fast encoder (to be built, still missing 6N137 to be delivered).
Edit:
I just committed all required changes for reducing the size of the data package. If anyone wants to try this:
  • requires rebuilding the firmware
  • requires rebuilding the driver
  • some minor changes are required for the HAL file regarding the stepgen, which has become simpler. Please see code example below.
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt litexcnc
loadrt litexcnc_eth config_file="[LITEXCNC]CONFIG_FILE"
loadrt pos2vel number=1

# Add the functions to the thread
addf [LITEXCNC](NAME).read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pos2vel.convert servo-thread
addf [LITEXCNC](NAME).write servo-thread

[...]

########################################################################
STEPGEN
########################################################################
# - timings (prevent re-calculation)
net pos2vel.period-s       <= [LITEXCNC](NAME).stepgen.period-s
net pos2vel.period-s-recip <= [LITEXCNC](NAME).stepgen.period-s-recip

STEPGEN - X-AXIS
########################################################################
# POS2VEL
# - position control
net xpos-fb  <= [LITEXCNC](NAME).stepgen.00.position_prediction
net xpos-fb  => joint.0.motor-pos-fb
net xpos-fb  => pos2vel.0.position-feedback
net xvel-fb  pos2vel.0.velocity-feedback <= [LITEXCNC](NAME).stepgen.00.velocity-prediction
net xpos-cmd pos2vel.0.position-cmd      <= joint.0.motor-pos-cmd
# - settings
setp pos2vel.0.max-acceleration [JOINT_2]STEPGEN_MAXACCEL
# setp pos2vel.0.debug 1

# STEPGEN
# - Setup of timings
setp [LITEXCNC](NAME).stepgen.00.position-scale   [JOINT_2]SCALE
setp [LITEXCNC](NAME).stepgen.00.steplen          5000
setp [LITEXCNC](NAME).stepgen.00.stepspace        5000
setp [LITEXCNC](NAME).stepgen.00.dir-hold-time    10000
setp [LITEXCNC](NAME).stepgen.00.dir-setup-time   10000
setp [LITEXCNC](NAME).stepgen.00.max-velocity     [JOINT_2]MAX_VELOCITY
setp [LITEXCNC](NAME).stepgen.00.max-acceleration [JOINT_2]STEPGEN_MAXACCEL
# setp [LITEXCNC](NAME).stepgen.00.debug 1
# - Connect velocity command
net pos2vel.0.velocity-cmd => [LITEXCNC](NAME).stepgen.00.velocity-cmd
# - Set the acceleration to be used (NOTE: pos2vel has fixed acceleration)
setp [LITEXCNC](NAME).stepgen.00.acceleration-cmd [JOINT_2]STEPGEN_MAXACCEL
# - enable the drive
net xenable joint.0.amp-enable-out => [LITEXCNC](NAME).stepgen.00.enable
########################################################################

[...]

Another change I've made in the stepgen is the timing constraint. When there is some jitter on the thread period this error might get triggered, nothing to worry about. However, sometimes the error would get 'stuck'. Stuck means that is the timing is below the minimum it is set to this minimum. However, this value will be used in the next cycle as a starting point. This means that as soon the warning occurs, it will most likely keep on recurring. To prevent this, I don't set the apply time equal to the boundary, but provide some slack or space.

I've checked that the apply time is not slowly decreasing or increasing, which is definitely not the case.
 
Last edit: 18 Dec 2022 21:47 by TOLP2. Reason: GPIO out BOB working

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

More
19 Dec 2022 09:34 #259879 by TOLP2
Just released another version of LitexCNC to PyPi.org. To try it out:
pip install --extra-index-url https://test.pypi.org/simple/ litexcnc
# After installation
python3 litexcnc build_driver
python3 litexcnc install_litex
python3 litexcnc install_toolchain

After this your set to build your firmware. See for full documentation (including the changes to the driver):  litex-cnc.readthedocs.io/en/latest/index.html
 

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

More
22 Dec 2022 08:43 #260063 by TOLP2
I improved the etherbone driver a bit, so the buffers (write/read-read-request) are now part of the FPGA struct. This prevents a whole lot of copying data around in memory. This improved the speed of the driver with roughly 10% when using a 5A-75E with all pins appointed.This should address the issue of the high CPU usage partly.

Tonight I'm going to test the encoder on my system. Is it finally possible to release a full version before Christmas?
The following user(s) said Thank You: tommylight, Pro_El, wzor

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

More
24 Dec 2022 21:56 #260264 by TOLP2
Merry Christmas to everybody. I would like to thank everybody for their support in making the firmware and driver last year.

Wish everybody good days and stay safe!
The following user(s) said Thank You: tommylight, Pro_El, muvideo

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

More
26 Dec 2022 22:59 #260356 by TOLP2
Today I finally merged and deleted the branch 'envoders' in which I was developing the support for encoders. Tested the working for encoders successfully and put everything in main. Some nice facts / features on the encoders:
  • In the JSON-config you can set minimum and maximum value for the encoders. This plays really nice for setting feed, rapid and spindle override. You can directly use the output of the encoder counts with gmoccapy or you can use the scaled value to simulate an potentiometer with this function 
  • In the JSON-config you can set the reset_value. This is the value to which the counts are set on the FPGA when either the FPGA is being reset (for example at start up of LinuxCNC) or when the index enable is set to TRUE and an index pulse happens.
  • A breakout board for fast encoders is available. The speed aimed for is 1 MHz.
Now I'm going to focus to solder more of my breakout boards and actually finish the EMCO5 with it. Please come with issues or suggestions either here or in the  issue list  and they will be looked in to.
 
The following user(s) said Thank You: wzor

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

More
27 Dec 2022 13:56 - 29 Dec 2022 22:15 #260394 by TOLP2
My 5a-75e is ff-up. Does any one in Europe, or even better in The Netherlands, have a spare card? It takes so long to get a new one otherwise.

Update:
Just ordered two more cards. Spend more then 8 hours trying to rewire the broken traces and fix the buffers. But I think some more of the board has been damaged, because I cannot get any response from the JTAG. Either something shortened out in the FPGA and had it fried, or something else is terrible wrong which I cannot solve.

The new boards will arrive on 15th of January (if everything goes well), then I'll be back in business. 
Last edit: 29 Dec 2022 22:15 by TOLP2.

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

More
30 Dec 2022 07:46 #260540 by juergenmoser
Hello together, i am a beginner at this point. I have one Question - can i use this board (5a75b) also only for stepper motors without encoder feedback?
Kind regards

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

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