- Hardware & Machines
- Computers and Hardware
- LinuxCNC-RIO - RealtimeIO for LinuxCNC based on FPGA (ICE40 / ECP5)
LinuxCNC-RIO - RealtimeIO for LinuxCNC based on FPGA (ICE40 / ECP5)
works
Please Log in or Create an account to join the conversation.
Attachments:
Please Log in or Create an account to join the conversation.
www.youtube.com/shorts/U16rtV2JOMA
Please Log in or Create an account to join the conversation.
Joypad + Encoder + MPG + Buttons at the same time (build by the hal-generator)
Please Log in or Create an account to join the conversation.
OS:
- LinuxCNC 2.9.2 Raspberry Pi 5 OS based on Debian Bookworm Raspberry Pi 5 Uspace compatible with Mesa Ethernet and SPI interface boards.
# uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
In /dev/
Check do you have listed spidev0.0, should be!
In RIO.h define:
#define TRANSPORT_SPI5
In RIO C add lines:
#ifdef TRANSPORT_SPI5
#include <linux/spi/spidev.h>
#include <sys/ioctl.h>
#endif
/***********************************************************************
* STRUCTURES AND GLOBAL VARIABLES *
************************************************************************/
#ifdef TRANSPORT_SPI5
int spifd;
static uint8_t mode = SPI_MODE_0;
static uint8_t bits = 8;
static uint32_t speed = 1500000;
#endif
/***********************************************************************
* INIT AND EXIT CODE *
************************************************************************/
#ifdef TRANSPORT_SPI5
rtapi_print("Info: Initialize SPI5 connection\n");
spifd = open("/dev/spidev0.0", O_RDWR);
if (spifd < 0) {
rtapi_print_msg(RTAPI_MSG_ERR,"Failed to open SPI device\n");
return -1;
}
// Set SPI mode
if (ioctl(spifd, SPI_IOC_WR_MODE, &mode) == -1) {
rtapi_print_msg(RTAPI_MSG_ERR,"Failed to set SPI mode\n");
close(spifd);
return -1;
}
// Set bits per word
if (ioctl(spifd, SPI_IOC_WR_BITS_PER_WORD, &bits) == -1) {
rtapi_print_msg(RTAPI_MSG_ERR,"Failed to set bits per word\n");
close(spifd);
return -1;
}
// Set max speed
if (ioctl(spifd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) == -1) {
rtapi_print_msg(RTAPI_MSG_ERR,"Failed to set max speed\n");
close(spifd);
return -1;
}
#endif
//Edit rtapi_app_exit function, add close(spifd)
void rtapi_app_exit(void)
{
close(spifd);
hal_exit(comp_id);
}
//In fuction void rio_transfer() near end of it add:
#ifdef TRANSPORT_SPI5
struct spi_ioc_transfer tr = {
//.tx_buf = (uint64_t)tx_buf,
//.rx_buf = (uint64_t)rx_buf,
.tx_buf = (uint64_t)txData.txBuffer,
.rx_buf = (uint64_t)rxData.rxBuffer,
.len = SPIBUFSIZE,
.speed_hz = speed,
.delay_usecs = 0,
.bits_per_word = bits,
};
// Perform SPI transfer
if (ioctl(spifd, SPI_IOC_MESSAGE(1), &tr) == -1) {
rtapi_print_msg(RTAPI_MSG_ERR,"Failed to perform SPI transfer\n");
//close(spifd);
//return -1;
}
#endif
//Save and do hallcompile...
Please Log in or Create an account to join the conversation.
I think the problem with RPI5 and SPI was that it is not realtime-capable. But I don't know exactly, I don't have an RPI5 yet.
I'm looking forward to the first machine tests
Please Log in or Create an account to join the conversation.
Going thru /dev/spi doesn't appear to be fast enough, at least for the mesa cards.
Please Log in or Create an account to join the conversation.
Since implementing this solution, I haven't experienced any communication issues. I can't say the same for previous tests where I used a laptop and a W5500 chip.
While researching the topic, I came across cases where people use spidev kernel libraries to manage several displays. They even mention 200Mhz clocks what is hard to believe. Official RPi pages stays on maximum 50Mhz. So speed should not be issue and "realtime capable" out of my understanding.
I'm working on 1.5Mhz. I'm still learning and even don't know what is acceptable speeds. from orginal BMC library i extract some data that speed should be around 1.5Mhz.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
www.youtube.com/shorts/tQvyrIP7aVc
but i have a serious problem with the kinematic, i need only 4joints, but the melfa stuff have 6
don't know how to setup a 4dof robot the right way
Please Log in or Create an account to join the conversation.
- Hardware & Machines
- Computers and Hardware
- LinuxCNC-RIO - RealtimeIO for LinuxCNC based on FPGA (ICE40 / ECP5)