Mesa Serial Connection / GPIO question

More
09 Jan 2017 02:42 #85498 by BishopCNC15
Hi,

First question: I read in the Mesa documentation that the FPGA is able to create a serial connection using the GPIO pins. I have a 5i23. I'd like to make an I2C or SPI connection to an analog to digital converter I have. My end goal is to use this to control temperature on a 3D printer nozzle and heat bed. How can I set this up in pncconf / HAL?

Second question: If I select SVST8_4 (8 encoder, 8 pwm, 4 stepper) and reduce the number of steppers to zero in pncconf, will they return to being GPIO? I don't have any stepper motors to use but I'd like the extra GPIO. Just want to make sure a custom bit file isn't needed for that.

Final question: This is kind of an afterthought - can I just write something in C++ or python (or anything really) to directly control the 5i23's pins?

Thanks!
More
17 Jan 2017 13:25 #85915 by andypugh
Yes, unused pins become GPIO.

You can write a HAL component that uses GPIO to directly drive pins. There is an example here
github.com/LinuxCNC/linuxcnc/blob/master...onents/max31855.comp
which pin-bangs GPIO to read a temperature sensor chip.

It is written using this pre-processor code:
linuxcnc.org/docs/2.7/html/hal/comp.html

This has a max data rate of no more than 1kHz (probably half that, actually) because it runs in the servo thread.
For higher data rates you could use a Mesa firmware that includes BSPI channels, and write a .comp driver to control that directly.
Accessing BSPI on the Mesa card from a .comp is a bit of a fiddle, but there is an example of doing that here:
github.com/LinuxCNC/linuxcnc/blob/master...ivers/mesa_7i65.comp

And a similar example accessing a serial UART from a Mesa firmware:
github.com/LinuxCNC/linuxcnc/blob/master...ivers/mesa_uart.comp

Mesa bitfiles such as ...svssua... have UARTS (ua = uart, sv = servo encoder / pwm, st = stepgens)
The following user(s) said Thank You: BishopCNC15
Moderators: cmorley
Time to create page: 0.095 seconds
Powered by Kunena Forum