SPI ADC hal component?

79 views
Skip to first unread message

blaz...@gmail.com

unread,
Jun 30, 2020, 9:46:28 PM6/30/20
to Machinekit
I was thinking on how to go about using an ADC with a raspberryPi4 for a project. It's a simple machine so I'd be trying to keep it light on hardware. First, I'm not really sure what RP4 support looks like in MK, LCNC has a hal-pi-gpio driver but I'm not sure if hal GPIO works on a rpi4 (or anything else), maybe somebody can fill me in.

Anyway assuming that I can get hal running the GPIO's, I was looking to no avail to find a component that worked similarly to this one https://github.com/LinuxCNC/linuxcnc/blob/master/src/hal/components/max31855.comp
That "bitbangs" the SPI bus of that thermocouple chip and that one specifically probably because adafruit offers a little board for it https://www.adafruit.com/product/269

There's plenty of SPI ADC chips out there though I don't know of many little breakout boards for them, but they're easy to implement anyway. It'd be great to have a hal component to handle this. Not something I can write since I'm no programmer, but a somewhat generic hal component that does this would enable ADCs simply on just about anything that has some pins available to hal on it. 

I was actually wondering if there were any similarities between doing this and the MKSOCFPGA nano-adc firmware module, since I believe the ADC on a DE(1)0-nano board is also an SPI chip. The hal component that me and a friend came up with  https://github.com/machinekit/machinekit-hal/blob/master/src/hal/components/vari_bit_adc.comp to work with nano-adc could be incorporated. Anyone else think this is a good idea?

justin White

unread,
Jul 1, 2020, 1:07:56 AM7/1/20
to Machinekit
Just to clarify, I'm interested in using the adc to read voltage not temps.

Michael Brown

unread,
Oct 15, 2020, 8:58:07 AM10/15/20
to Machinekit
While the DEX_Nano_Soc's are using a SPI chip pin implementation is in the fpga fabric like this:

ADC (voltage) values are then directly presented via the mesa hostmot2 interface into the hal.

So very different from a Rpi.implementastion via a spi driver port.

Best Wishes Michael
Reply all
Reply to author
Forward
0 new messages