LUA script for stepper ENA+ ??

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: LUA script for stepper ENA+ ??

#11 Post by jph »

This is a good one as well. I had a note of this one in my little book....
As can be seen again, the code is fairly simple when broken down.
You can build the contraption and test it - you don't need to 3d print anything. A normal servo arm and a bit of bent wire will work ;) .
Arduino code is in the links under the title.
https://www.youtube.com/watch?v=JFTJ2SS ... ectronoobs

It will be in 4.21 then @Ralph ? :lol:
:D
Joe
Joe. CISSP, MSc.

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: LUA script for stepper ENA+ ??

#12 Post by Ralph »

Don't ask me ;) It would also be interesting for creating an autopilot.

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: LUA script for stepper ENA+ ??

#13 Post by jph »

Ralph wrote: Wed Oct 05, 2022 2:42 pm Don't ask me ;) It would also be interesting for creating an autopilot.
Or motion platform... force feedback.. (via a dedicated custom UDP simple interface at 100Mb) Then you can also run real time closed loops / feedback and SPI / I2C natively. :D
Joe. CISSP, MSc.

jangaloo
Posts: 11
Joined: Sat Mar 28, 2020 9:10 am

Re: LUA script for stepper ENA+ ??

#14 Post by jangaloo »

Thanks very much for getting back to me.

Yes the Hall sensors are of the angular type. Thanks for the pointers, I´ll have a look at the DAC stuff and report back! Probably take me a while to figure that out.....

Am currently running the drivers with 1 amp - might step it up a bit.

As for manual pilot intervention - yeh not sure how i´ll handle that one yet. If the torque isnt too high on the steppers then maybe it would be possible to slightly adjust them if need be - otherwise there´s always the A/T disconnect button I guess! But yes it would be nice to get it as accurate as possible.

Many thanks for your help!

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: LUA script for stepper ENA+ ??

#15 Post by jph »

You dont actually need steppers in this application. Small geared DC motors would work fine. You have the positioning with the angular hall sensors so absolutely no need for steppers. You can tell the distance to travel from ADC reading (not DAC !) at the time - which is where you are - to the adc reading of where you want to be.
So the control is a simple on off - or even better - a PWM dc motor controller. With a dc motor control you could measure current flow which would give you an indication of the motors being resisted by hand so you could move them manually. The steppers are virtually impossible to monitor current due to the frequency of the pulse to the coils and the nature of the rise and fall.

If you decide to stick to the steppers, then you would be better with the TMC2208 or TMC2209 drivers. they will run 1.5A all day and 2A peak. The drives are fully adjustable current limiting so you could set them to the absolute minimum required, then when you restrict the movement the limit will kick in. This could actually work as you would be able to tell that you were not moving as the pulses would continue but the adc reading from the angular sensors would not change. In this case you could drop out the EN control for a set period of time. That would work very much like the 'real' unit.

Another option is a friction clutch. R/C model cars with internal combustion engines tend to use a rudimentary unit. It is basically a few plates of material pressed together under a spring load that can slip against each other if enough torque is applied.
I would be tempted to use the current limiting and sensing if the movement is happening method to sense intervention. That could be made very realistic indeed.
Last edited by jph on Thu Oct 06, 2022 2:10 pm, edited 1 time in total.
Joe. CISSP, MSc.

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: LUA script for stepper ENA+ ??

#16 Post by jph »

Also, what voltage are you using for the steppers ? around 24V would be ideal
Joe. CISSP, MSc.

jangaloo
Posts: 11
Joined: Sat Mar 28, 2020 9:10 am

Re: LUA script for stepper ENA+ ??

#17 Post by jangaloo »

Sent you a PM the other day..

Am using a 24V switching power supply.

So I followed your advice and got some TMC2209 Drivers. They just arrived and now have no clue how to hook them up. Have spent a few hours scouring the net but haven't found anything really useful unless I´m intending to redo my 3D printer drivers ;)

Any pointers would be much appreciated.

Thanks very much!

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: LUA script for stepper ENA+ ??

#18 Post by jph »

It's exactly the same as connecting them to a 3d printer ;)
Follow the details for your actual board to set the step size and to adjust the operating current limit. The rest of the connections are self explanatory.

Here is an example from AliEx.
https://www.aliexpress.com/item/1005002 ... HSbTBtsYXn
Joe. CISSP, MSc.

jangaloo
Posts: 11
Joined: Sat Mar 28, 2020 9:10 am

Re: LUA script for stepper ENA+ ??

#19 Post by jangaloo »

Thanks - I got so far as to have it connected as per the driver I got from bigtreetech but how do I set the microsteps? That bits got me puzzled... no dip switches or jumpers to place. Do I need to connect them to somewhere on the arduino Mega?

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: LUA script for stepper ENA+ ??

#20 Post by jph »

As per the link in the previous post. You use the MS1 and MS2 pins. You either tie them up or down. Sometimes other pins can be used, that depends on the driver board layout.
Do you not have a pinout of your board ? - it probably also uses the 'spread' pin as MS3.
Joe. CISSP, MSc.

Post Reply