multigcs / LinuxCNC-RIO

RealtimeIO for LinuxCNC based on an FPGA
https://forum.linuxcnc.org/18-computer/49142-linuxcnc-rio-realtimeio-for-linuxcnc-based-on-fpga-ice40-ecp5
GNU General Public License v2.0
72 stars 17 forks source link

unable to reset E-STOP #2

Closed TurBoss closed 1 year ago

TurBoss commented 1 year ago

Hello,

I'm trying to get the linuxcnc configs to run with the icebreaker board, but I'm unable to reset the E-STOP

I get this error: Bad SPI payload = 32303a30

Thanks

multigcs commented 1 year ago

does the ID change every time you try ?

i think this is a problem with SPI. you can try to set the SPI-divider to 256 in rio.c:

//bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_256);
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_128);
TurBoss commented 1 year ago

I think that is a bad setting in my board config clock speed, need to figure..

I tried changing that setting to 256 but this time got a different code in the message

multigcs commented 1 year ago

strange if it's work with the python tool if you changed the firmware, you have also to update the rio.h and recompile the hal-component.

multigcs commented 1 year ago

ahh, and you need min. one Joint, one DIN, DOUT, VIN and VOUT until i have a fix for the hal-component

TurBoss commented 1 year ago

hello,

i could not get it to work each time i press e-stop i get a different payload

I'll wait for the improvements. Thank you so much

multigcs commented 1 year ago

I don't know what I could improve at this point. I think it is a connection problem, maybe too long cable or too high spi speed.

TurBoss commented 1 year ago

I'll check wiring

thanks

multigcs commented 1 year ago

changing rio.c to bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_256); and recompile

does not help ?

TurBoss commented 1 year ago

Hello,

I tried soldering some headers to a PCB and got it like before, the qt app works but not linuxcnc, I tried changing that option in rio.c and recompile with halcompile but got different payload errors

:)

multigcs commented 1 year ago

:( hmm stange, can you send me your config please ?

TurBoss commented 1 year ago

sure here it is:

{
    "name": "ICEBreakerV1.0e",
    "description": "Small and low cost FPGA educational and development board",
    "toolchain": "icestorm",
    "family": "ice40",
    "type": "up5k",
    "package": "sg48",
    "clock": {
        "speed": "120000000",
        "pin": "35"
    },
    "interface": [
        {
            "type": "spi",
            "pins": {
                "MOSI": "42",
                "MISO": "43",
                "SCK": "38",
                "SEL": "36"
            }
        }
   ],
    "din": [
        {
            "debounce": true,
            "pin": "10"
        },
        {
            "debounce": true,
            "pin": "20"
        },
        {
            "debounce": true,
            "pin": "19"
        },
        {
            "debounce": true,
            "pin": "18"
        }
    ],
    "dout": [
        {
            "pin": "23"
        },
        {
            "pin": "25"
        },
        {
            "pin": "26"
        },
        {
            "pin": "21"
        },
        {
            "pin": "27"
        }
    ],
    "vin": [
        {
            "type": "frequency",
            "pin": "44",
            "pullup": true
        }
    ],
    "vout": [
        {
            "type": "pwm",
            "pin": "37",
            "invert_pwm": true
        },
        {
            "type": "pwm",
            "pin": "11",
            "invert_pwm": true
        }
    ],
    "joints": [
        {
            "comment": "J9.1+3+4",
            "type": "stepper",
            "cl": false,
            "pins": {
                "dir": "3",
                "step": "4",
                "enable": "48"
            }
        },
        {
            "comment": "J9.1+3+4_2",
            "type": "stepper",
            "cl": false,
            "pins": {
                "dir": "2",
                "step": "46",
                "enable": "47"
            }
        },
        {
            "comment": "J9.1+3+4_3",
            "type": "stepper",
            "cl": false,
            "pins": {
                "dir": "32",
                "step": "34",
                "enable": "28"
            }
        }
    ]
}
multigcs commented 1 year ago

Hmm, looks ok , this should generate a working rio.h file

TurBoss commented 1 year ago

hello,

I noticed having one more zero in the clock speed... :(

but if I configure 3 DOUT the python tool moves one more that is not in the json conf :/

Screenshot_2023-05-29_07-52-25

Thanks

multigcs commented 1 year ago

I have update the tool a little bit, it's really bad but is helpful for testing :)

Ahh, Ok, so you have a clock of 12Mhz ? maybe to slow for the fast SPI clock in the hal-component, but no problem (i hope): "clock": { "osc": "12000000", "speed": "50000000", "pin": "35" }, the 'osc' ist you real clock speed and the 'speed' option is what you want to have, this acitvates the internal PLL to push the clock speed up.

I think 50Mhz is ok, but you can also try 100Mhz

TurBoss commented 1 year ago

If I add the osc option i get this error


(venv) turboss@raspberrypi:~/LinuxCNC-RIO $ make
python3 buildtool.py configs/ICEBreakerV1.0e/config.json
generating files in Output/ICEBreakerV1.0e
generating linux-cnc config
generating linux-cnc component
generating firmware
generating qtgui
generating doc
(cd Output/ICEBreakerV1.0e/Firmware/ ; make)
make[1]: Entering directory '/home/turboss/LinuxCNC-RIO/Output/ICEBreakerV1.0e/Firmware'
yosys -q -l yosys.log -p 'synth_ice40 -top rio -json rio.json' vout_pwm.v vin_frequency.v quad_encoder.v joint_stepper.v joint_stepper_nf.v interface_spislave.v debouncer.v pll.v rio.v
nextpnr-ice40 -q -l nextpnr.log --up5k --package sg48 --json rio.json --pcf pins.pcf --asc rio.asc
ERROR: PLL 'mypll.uut' couldn't be placed anywhere, no suitable BEL found. Did you mean to use a PAD PLL ?
    PLL bel 'X12/Y31/pll_3' cannot be used as it conflicts with input 'sysclk_in$sb_io' on pin '35'.

ERROR: Packing design failed.
0 warnings, 2 errors
make[1]: *** [Makefile:12: rio.asc] Error 255
make[1]: Leaving directory '/home/turboss/LinuxCNC-RIO/Output/ICEBreakerV1.0e/Firmware'
make: *** [Makefile:39: firmware] Error 2
(venv) turboss@raspberrypi:~/LinuxCNC-RIO $

I'm very new to FPGA :)

Thank you

multigcs commented 1 year ago

ok, thats also new too me, my oss-cad-suite is a little bit to old and iceppl is missing parameter (-p). I have add a newer version of icepll (files/icepll) and add an exception to the firmware generator, hope this will now work for this case. Please try it again

Do you run the build on a workstation or on raspberry ?

TurBoss commented 1 year ago

I run he build from the pi itself

now got this one :)

python3 buildtool.py configs/ICEBreakerV1.0e/config.json
generating files in Output/ICEBreakerV1.0e
generating linux-cnc config
generating linux-cnc component
generating firmware
sh: 1: files/icepll: Exec format error
generating qtgui
generating doc
multigcs commented 1 year ago

aaaa, sorry, new update :) i have running 2 versions on my system, the one in the oss-cad-suite works fine.

You are running direct on the raspberry, i build it for amd64, sorry

TurBoss commented 1 year ago

okay got this and looks like what i had in config image

but still no way to get the estop out :/ the other time that got followin errors was becouse i commented that on hal :/

just notice that i'm getting the same payload now

Bad SPI payload = 32303a30
Bad SPI payload = 32303a30
Bad SPI payload = 32303a30
Bad SPI payload = 32303a30
Bad SPI payload = 32303a30

should i build from pc and try... :face_with_spiral_eyes:

multigcs commented 1 year ago

i don't think it makes a different on PC

multigcs commented 1 year ago

in binary, it looks like a speed issue: 0x32303a30 00110010001100000011101000110000 0x64617461 01100100011000010111010001100001

can you try to set the speed again:

and restart linuxcnc

this will slow down the spi speed to under 1Mhz

multigcs commented 1 year ago

and only to be sure, you have to stop the python tool if you running linuxcnc

TurBoss commented 1 year ago

yes yes only one app at time

multigcs commented 1 year ago

i have ordered an icebreaker board in china, hopefully in 2 weeks i will know more :)

TurBoss commented 1 year ago

:O awesome thank you so much!

multigcs commented 1 year ago

i need it anyway, i want to design a board and maybe use the up5k for it

thank you for investing so much time in this project

TurBoss commented 1 year ago

don't worry I'm having lots of fun

TurBoss commented 1 year ago

I found the issue

may fault by having a offset in the iceprog tool

big face palm :=)

can I set this as fixed :D

Thank you so much :D

multigcs commented 1 year ago

Wait what ? does it work now ?

TurBoss commented 1 year ago

yes it does

i was had an offset of 1M in the iceprog from another project and forgot to remove :_)

Just finished soldering the protoboard I'll try to get a video

multigcs commented 1 year ago

cooool !!!!

TurBoss commented 1 year ago

here a short long video :D

https://www.youtube.com/watch?v=58RNJSGD0qs

multigcs commented 1 year ago

Very cool, thank you !

and i like your GUI, have to test it