EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026 Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026
<== Date ==> <== Thread ==>

Subject: Re: Drivers for SPI-based stepper motor controllers
From: Rea Domitrović via Tech-talk <tech-talk at aps.anl.gov>
To: Torsten Bögershausen <tboegi at edom.se>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Fri, 10 Jul 2026 08:39:48 +0000
Hi Torsten,

yes - in principle you could probably call pasynOctetSyncIO directly in the axis class methods and bypass writeReadController. In the FASTech driver that I was previously making, I also had to send binary data (over UDP that time), and as a design decision I overrode the base class function writeReadController to make a customised pasynOctetSyncIO call, with the length defined within the data frame rather than as the length of a null-terminated ASCII string. I think this makes the code more readable and maintainable versus of having a direct pasynOctetSyncIO call in, for example, the move function, as well as maintaining consistency with the rest of the motor modules, which all call writeReadController to perform the transaction.

As far as my question, I was debating whether to make a model 3 driver and adapt the base classes to the weirdness of this specific use case, or a driver that is *not* model 3, i.e. make everything myself more or less from scratch; I'm currently making a test driver that will interface with C++ code directly rather than through EPICS. I think, for the final implementation, you've more than convinced me to go with model 3. Just have to figure out how to include drvAsynSPI as a dependency, but I think I'll take a leaf out of the motor build files. Cheers,

Rea





From: Torsten Bögershausen <tboegi at edom.se>
Sent: Friday, July 10, 2026 09:47
To: Rea Domitrović; tech-talk at aps.anl.gov
Subject: Re: Drivers for SPI-based stepper motor controllers
    
Hej Rea,

I am not sure if I understand your question correcty:

"I'm wondering if it might just be easier to bypass Asyn/model 3 and
make a driver that talks to the motor record directly, using a different
C++ library to handle the SPI communication.
"


I think that the motorRecord "talks" to the model 3 driver.
Which means that, somewhat simplified, when you write to the
VAL field in the motorRecord  move() is called.
What next ?
move() has all freedom in the world to do what needs to be done.
(and all responsiblity, but we are protected by a mutex, so that
e.g only one move() is called at a time).
You don't need to use
writeController, readController and writeReadController.
They are there because most (!) controllers use ASCII and
all share the same principle.
You can, to my understanding, correct me if this is very wrong,
just issue a number of multiple pasynOctetSyncIO to do the move()
And use the spi driver to provide you with the asynOctet interface
which your driver code calls.
Best Regards
/Torsten




On 2026-07-09 13:52, Rea Domitrović via Tech-talk wrote:
> Hi all,
>
> I'm working with an ST Microelectronics X-Nucleo IHM02A1 board, which is a daughterboard with two L6470 stepper motor controllers, plugged into a Raspberry Pi. The controllers talk over SPI, and if the headache wasn't bad enough, the two chips are daisy chained  together and share the same chip-select line, rather than the standard SPI approach of giving each slave device its own line. I'm looking to develop an EPICS driver for those controllers so that we can use them to control steppers in the lab, and while there  is an Asyn plug-in to enable SPI communication (https://urldefense.us/v3/__https://github.com/kek-acc/drvAsynSPI__;!!G_uCfscf7eWS!YDwm4DSyktS6YoYYgOF-qLUVEpcbvLzaBQ9yED4mw8XJRWQ5jbQ8o7rDnFRSAEHgNwWTkEjfdNC1ruyyDZJ5cnpiRT6Bvg$ ), I'm wondering  if it might just be easier to bypass Asyn/model 3 and make a driver that talks to the motor record directly, using a different C++ library to handle the SPI communication.
>
> So far, what I've figured out is: Due to the daisy chaining, data has to be sent interlaced, with zero-bytes for the L6470/motor we don't want to talk to. This means a single command with a 3-byte argument, such as jog, takes four SPI transmissions to fully  propagate, each with one byte of the four-byte command frame. So, for example, jogging forward at 3/256 step/tick, for the device nearest the master:
>
> Transmission 1: (0x00, 0x51)
> Transmission 2: (0x00, 0x00)
> Transmission 3: (0x00, 0x30)
> Transmission 4: (0x00, 0x00)
>
> This means, using Asyn, I would probably have to write custom writeController, readController and writeReadController functions with multiple pasynOctetSyncIO calls per command to make sure everything propagates through as needed. This doesn't sound too difficult,  but that's assuming the Asyn/SPI driver even works as intended. On the other hand, bypassing Asyn would mean including a non-EPICS package as a dependency - I'm currently working with spidev_lib++.
>
> Any suggestions and comments are more than welcome. Kind regards,
>
> Rea Domitrović
> Institut Ruđer Bošković
> Zagreb, Croatia

Oprez: Ova poruka stigla je od vanjskog pošiljatelja. Prije otvaranja poveznica ili privitaka provjerite pošiljatelja. Caution:This email originated from an external sender. Please verify the sender before opening links or attachments.
    

References:
Drivers for SPI-based stepper motor controllers Rea Domitrović via Tech-talk
Re: Drivers for SPI-based stepper motor controllers Torsten Bögershausen via Tech-talk

Navigate by Date:
Prev: Re: Drivers for SPI-based stepper motor controllers Torsten Bögershausen via Tech-talk
Next: RE: [EXTERNAL] Re: support for LXI devices (Bustec ProDAQ 6150 specifically) Evans, Richard K. (GRC-H000) via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026
Navigate by Thread:
Prev: Re: Drivers for SPI-based stepper motor controllers Torsten Bögershausen via Tech-talk
Next: support for LXI devices (Bustec ProDAQ 6150 specifically) Evans, Richard K. (GRC-H000) via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026
ANJ, 10 Jul 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·