Unable to connect to direct stepper motors (28BYJ-48)

More
08 Nov 2021 15:38 #225698 by dgdodo
Hello all,

I'm a first-time-user, with less or no experience with linuxcnc.

I build a simple XY plotter for any pen, but I'm completely unable to connect it to linuxcnc.
On a Raspberry 3B with python3 I wrote a program that can drive XY & servo.
It can draw its maximum usable square (1000x6000 full- and halfsteps).

Now I want to read G-code file and pass it to the plotter, but how?
I don't wanna re-write G-code converter for it, so thinking of linuxcnc should do it.
If it can drive my Four-Phase Step Types motors and the servo...

Each motor has its own start- and endswitch and should stay between those switches.

Diagram (of motor X-axis):Rpi pins     GPIO        Driver?         28BYJ-48
+
+                +
+         +
+
| rpi   18 +--1----IN1-+ L293D     +---A---+ motor |
|        22 +--4----IN2-+    or          +---A'--+   X      |
|        24 +--5----IN3-+ ULN2003 +---B---+           |
|        28 +--6----IN4-+                 +---B'--+            |
|              |                +
+          +
+
|        38 +
SWstart
|        40 +
SWend
+
+
What I know about linuxcnc is that I can NOT use Stepconf or CNFconf wizard, as I don't use MESA or parallel/PCI cards.
So I have to use hal-config, but there goes the trouble.
1 motor runs half-step, the other full-step.
From: linuxcnc.org/docs/2.8/html/hal/rtcomps.html#sec:stepgen
The motors are bipolair stepper, so within halcmd I've to use: loadrt stepgen step_type=6,9,1 
This creates all necessary pins (In my eyes even too much. Can it be done with less?)
--
Component Pins:
Owner   Type  Dir         Value  Name
     4  s32   OUT             0  stepgen.0.counts
     4  bit   IN          FALSE  stepgen.0.enable
     4  bit   OUT         FALSE  stepgen.0.phase-A
     4  bit   OUT         FALSE  stepgen.0.phase-B
     4  bit   OUT         FALSE  stepgen.0.phase-C
     4  bit   OUT         FALSE  stepgen.0.phase-D
     4  float IN              0  stepgen.0.position-cmd
     4  float OUT             0  stepgen.0.position-fb
     4  s32   OUT             0  stepgen.1.counts
     4  bit   IN          FALSE  stepgen.1.enable
     4  bit   OUT         FALSE  stepgen.1.phase-A
     4  bit   OUT         FALSE  stepgen.1.phase-B
     4  bit   OUT         FALSE  stepgen.1.phase-C
     4  bit   OUT         FALSE  stepgen.1.phase-D
     4  float IN              0  stepgen.1.position-cmd
     4  float OUT             0  stepgen.1.position-fb
     4  s32   OUT             0  stepgen.2.counts
     4  bit   OUT         FALSE  stepgen.2.down
     4  bit   IN          FALSE  stepgen.2.enable
     4  float IN              0  stepgen.2.position-cmd
     4  float OUT             0  stepgen.2.position-fb
     4  bit   OUT         FALSE  stepgen.2.up
     4  s32   OUT             0  stepgen.capture-position.time
     4  s32   OUT             0  stepgen.make-pulses.time
     4  s32   OUT           781  stepgen.update-freq.time
--
How to I connect stepgen.0.phase-A to pin 18 
                 stepgen.0.phase-B to 22
                 stepgen.0.phase-C to 24
                 stepgen.0.phase-D to 28 of the Raspberry Pi?

I can not find any example or how to do this.
Tried several days now but mostly my .ini file failes to load linuxcnc at all.
If linuxcnc does start, it has NOT my .hal file active?
And never I see any activity on my hardware.
Linuxcnc has so many options, I can't see through them all.

Can linuxcnc run on RPI and run direct attached motors, as in my diagram?
I've not seen this anywhere, all have 'different' drivers or driverboards.

Any help will be appreciated.

Regards, DGdodo
 

Please Log in or Create an account to join the conversation.

More
08 Nov 2021 23:11 - 09 Nov 2021 01:27 #225729 by tommylight
A bit rusty but pretty sure stegen type 9 is for 5 phase steppers.
And i never used a RPI for that as it has bad latency, but i did use all stepgen types on parallel ports, they all work as advertised.
forum.linuxcnc.org/27-driver-boards/2905...r-drives-for-diy-ers
There are some samples there with configs attached, the 4 input one is the same thing as ULN2003.
Edit:
The first line was wrong, stepgen types from 11 to 14 are 5 phase, sorry for the mess up.
Last edit: 09 Nov 2021 01:27 by tommylight. Reason: Wrong info

Please Log in or Create an account to join the conversation.

More
09 Nov 2021 00:38 - 09 Nov 2021 00:41 #225741 by dgdodo
Thanks, tommylight

But according: linuxcnc.org/docs/html/man/man9/stepgen.9.html
--
Types 9 and 10: four phase, half step
 Four pins, phases A through D. Eight steps per full cycle. Type 9 is suitable for unipolar drive, and type 10 for bipolar drive.
--
And the motors are unipolair. (Types 11 to 14 are for 5phase motors)

I build the RPi Preempt-RT version, should have less latency issues, although -indeed- the motors are already slow, so that is not the issue.
Moreover I wanna know how the linuxcnc internal converter works (I saw it somewhere and can't find anymore ... too much data
-UPDATE- but found them @ linuxcnc.org/docs/html/hal/rtcomps.html#sec:stepgen ).
And how to connect those 'internal pins' to external rpi pins, so my motordrivers (L293D or ULN2003) get their required signals.
Until now I've not even got 1 signal working (led, button, or motor).
Only my pyhton program can drive the motors correctly.

Regards, DG.
 
Last edit: 09 Nov 2021 00:41 by dgdodo. Reason: -UPDATE- info

Please Log in or Create an account to join the conversation.

More
09 Nov 2021 01:31 #225746 by PCW
You should be able to use stepconf to create a hal/ini file set for the RPI
once these are created you just need to replace the parallel port driver
with the RPI GPIO driver and change the parallel port pins to the appropriate
RPI GPIO pins
The following user(s) said Thank You: dgdodo

Please Log in or Create an account to join the conversation.

More
09 Nov 2021 01:32 #225747 by tommylight
Oh cr@P ! Sorry for the mess up, been several years since i did use that.
As for RPI i only used it with a custom board through SPI, and now i am using them for 3D printers with MainSail/Klipper, so i have no idea how to use the pins directly.
Found these:
www.forum.linuxcnc.org/38-general-linuxc...control-loop?start=0

forum.linuxcnc.org/18-computer/38533-ras...pi3-gipo-single-axis

forum.linuxcnc.org/27-driver-boards/3770...rry-pi-gpios?start=0
The following user(s) said Thank You: dgdodo

Please Log in or Create an account to join the conversation.

More
11 Nov 2021 18:44 #226127 by dgdodo
Informational, to all:

After trying different cnc programs/installations on the raspberry, suddenly all switch IN ports start jittering.
In a way it was not workable anymore, and only on Raspberry, not on the switches itself (they also have LED's).
Thinking of pigpiod for python did something, or old cncjs install, which I already tried to uninstall, but every boot still some jobs were starting.

I had moving motors with LinuxCNC, although very, very, very slow.
1 step / sec  maybe due to wrong settings, but it was working!
Saved my LinuxCNC config and hal files (but forgot all my python programs ;( ).
Building new clean LinuxCNC (wiki.linuxcnc.org/cgi-bin/wiki.pl?RPi3BPreemptRT)

Until now I use rpi-gpio, so i need the following in .hal file:
 loadrt hal_pi_gpio dir=14895128 exclude=34649063
(This includes declaration of used in- and outports, within dir & exclude parameters.)
Next in .hal file is some functions declaration for base- and servo-thread.
Then 'net' internal pins to physically outpins (what I was looking for).

Some investigation later, of 'standard' & default declaration of LinuxCNC, it needs a stop button (estop-loop, soft- or hardware).
And I had already start- and endswitches declared & working, just not yet internally connected.
Then my inputs starts jittering, also after reboots or without external powersupply.
Let's see what a clean install does. And I've make new python scripts to eject my 'arms' from gears, as I used to do, but I lost those...

Thanks for pointing me out already to some interesting links :)

Regards, DG.
 

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum