You are not logged in.

#1 2017-03-28 19:14:51

ciclopez
Member
Registered: 2017-03-27
Posts: 6

Developing stepper board for Raspberry Pi

Hi,
This is my first post so hello everyone smile
In my free time after work, I've been developing a stepper motor shield that fits the Raspberry Pi and similar ARM computers like the Pine64. After several prototypes and coding I've finally finished a fully working piece of hardware that can be used to control up to 3 stepper motors using Python with smooth movements and a precision of 256 microsteps. It takes care of the step/dir signals, avoiding micro-cuts in the movements due to the overhead needed to directly control a stepper motor with the Raspberry Pi. It also prevents you from having to buy Arduino + Stepper driver shield + LCD screen & buttons. Takes care of giving power to the Raspberry Pi and you can control the power-up and shutdown process with the press of a button, it's an all-in-one solution to make a stand-alone DLP 3D printer or any other project that involves stepper motors with the Pi. It also has connections to power and control a couple of servos, and limit switch connections, although the latter is optional as I'm using Trinamic's drivers so theoretically they can detect if you reached a physical stop, but I'm still experimenting a bit more with that.

I made a Python API to control the steppers in an easy way. This is a simplified example:

driver_current = 1.1 # Electric current used to move the stepper motor in Amps
target_position = 7*200*256  # Target position in microsteps to make a 200 step motor do 7 full turns
velocity = 200*256 # Velocity in microsteps/second to make one turn per second.
setup(mot_X, driver_current) # setup the stepper driver
set_target_position(mot_X, target_position, velocity) # make the stepper move to the target position

I'm planning to launch a Kickstarter and release the source code soon, so I'm very interested in making NanoDLP work with my shield, but after some tests, the only thing I have managed to move are the servos, as they are directly connected to GPIOs.
What would be the better way to make nanoDLP communicate with my python API?

Any help would be appreciated,
Thank you!


Edit:
I add a couple of pictures of the board just in case anybody is interested:
IMG_0935.jpg IMG_0937.jpg

Last edited by ciclopez (2017-03-28 19:41:19)

Offline

#2 2017-03-28 22:57:12

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,546

Re: Developing stepper board for Raspberry Pi

Hi,

i2c and serial communications are much reliable than syscall. But you can call any python scripts from syscall/exec fields available on nanodlp setup/profile pages.

Offline

#3 2017-03-29 19:28:05

ciclopez
Member
Registered: 2017-03-27
Posts: 6

Re: Developing stepper board for Raspberry Pi

Thank you for your fast response,
I'm sorry that I asked such an obvious thing, I knew about the "Execute - Start of Print" in the Setup page but never tried to create a new profile.

As my shield can't directly receive serial/i2c commands, as it has been designed to be controlled through Trinamic's IC specific SPI commands, I'm driving it with Python (getting track of current position and all the logic of the stepper driver ICs). I'll try syscalls then, although it's not the best way.
Are you planning to expose some kind of event based API? It would be really useful for integrating this kind of software/hardware.

Thanks!

Offline

#4 2017-03-29 20:08:48

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,546

Re: Developing stepper board for Raspberry Pi

What you mean by event based API?

Offline

#5 2017-03-31 23:56:05

ciclopez
Member
Registered: 2017-03-27
Posts: 6

Re: Developing stepper board for Raspberry Pi

An API that developers could use to call their custom functions when events like z-axis position change occurs, or any other events that can happen during a printing process, without the limitations of syscalls.

Offline

#6 2017-04-01 07:41:23

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,546

Re: Developing stepper board for Raspberry Pi

You can use [[Net ]] keyword. It is fully async and customizable.
eg. [[Net http://127.0.0.1:3111/?layer=[[LayerNumber]]&where=AfterLayer]]

Offline

#7 2017-04-01 08:02:01

ciclopez
Member
Registered: 2017-03-27
Posts: 6

Re: Developing stepper board for Raspberry Pi

Hi,
Where could I find a list of available keywords or some kind of documentation? Maybe I'm missing basic info about the possibilities of NanoDLP and the way it works.
About the API, I was thinking on a Python, C or some other programming language API to your software, as it would be faster,  more reliable and convenient than syscalls or network interfaces.

Offline

#8 2017-04-01 08:45:55

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,546

Re: Developing stepper board for Raspberry Pi

Inside program you could find onscreen helps. For example if you click on gcode box help button you could see majority of gcode keywords.

If there is anything we miss I can add Rest API. But adding support to directly call C/Python is not possible.

Offline

#9 2017-04-01 09:14:10

ciclopez
Member
Registered: 2017-03-27
Posts: 6

Re: Developing stepper board for Raspberry Pi

Wow! That's all I needed, I was looking only the help buttons in the syscall boxes, and never saw the help of gcode boxes, I was missing a lot of info, sorry for my clumsiness. I will try with all your suggestions, I think they would do the job so I will post my progress here. Thanks a lot for your patience smile

Last edited by ciclopez (2017-04-01 09:17:09)

Offline

#10 2017-04-08 16:32:29

ciclopez
Member
Registered: 2017-03-27
Posts: 6

Re: Developing stepper board for Raspberry Pi

Hi,
I ended up creating a Python daemon that creates a virtual serial port, stays listening for gcode commands and responds with Z_move_comp when a movement is completed, and it works!
I didn't want to directly call python from syscalls, to avoid the overhead of opening and closing context on each call. I first tried with a named pipe (fifo) and echoing to it from syscalls, but it had the drawback of not being able to wait and respond with a "Z_move_comp", so I discarded it. I'm also considering using the [[Net ]] keyword but since I didn't notice any serious delay with the serial port and probably the serial is more friendly with the way people uses nanoDLP I think it's probably better to use the virtual serial port. Do you see any drawbacks on using the serial port instead of [[Net ]]?

Thanks!

Last edited by ciclopez (2017-04-08 16:36:34)

Offline

Board footer

Powered by FluxBB