Jump to content

Stepper x27 and DCS Bios request


Johan4668

Recommended Posts

Hi, I have been looking for a simple explanation how the stepper arduino scripts work..

Iam new to this and made leds and sevo work on it (109 K4) dcs bios.

Now the Challenge begins.....

What script do I need for...

X27 stepper and no modification, and what are the values I need to change pin and steps.

X27 stepper mod 360 and a 0 point sensor ir

Vid26 2 axis for altitude 

That would be so helpfull for code nobs like me..

I see f18 a10 and so on... but what is the common... what I need..

Thanks in advance

 

Johan


Edited by Johan4668
Link to comment
Share on other sites

  • Johan4668 changed the title to Stepper x27 and DCS Bios request

This is a really simple code, you do not need a stepper driver and it will make an X27-168 stepper motor display the A10-C Engine 1 Core RPM as long as you connect the four stepper connections to pins 3, 4, 5 and 6  - although you will have to try the four variations to make it work right. It's pretty simple and needs no stepper drive as it is driven directly from the Nano. Please note that I am not the author of this code, that hero is also here on the forum!

Quote

//#define DCSBIOS_IRQ_SERIAL

#define DCSBIOS_RS485_SLAVE 35
#define TXENABLE_PIN 2

#include "DcsBios.h"
#include <Arduino.h>

// ---------- Stepper Motor Declarations ----------
#include <AccelStepper.h>

// kind of Switec X25.168 stepper motor clone, 630 steps (1260 half steps) per revolution (limited to 315°) -> 4 steps per degree
 // pin 4 @ 2h, pin 5 @ 4h, pin 6 @ 8h and pin 7 @ 10h o'clock positions (view from needle)

AccelStepper stepper(AccelStepper::HALF4WIRE , 3, 4, 6, 5);

// ----------------------------------------------------------------------------
//     DCS Bios Stuff here
//-----------------------------------------------------------------------------

void onLEngCoreChange(unsigned int newValue) {
  unsigned int stepperPosition = map(newValue, 0, 65535, 0, 1080);
  stepper.runToNewPosition(stepperPosition);
}
DcsBios::IntegerBuffer lEngCoreBuffer(0x10a8, 0xffff, 0, onLEngCoreChange);

// ----------------------------------------------------------------------------
//     SETUP loop
//-----------------------------------------------------------------------------
void setup(void)
{
  DcsBios::setup();

// ----- Stepper init
    

    stepper.setMaxSpeed(12000);    //  maximum speed in steps per second. Must be > 0.
    stepper.setAcceleration(6000);  //  desired acceleration in steps per second per second. Must be > 0.0
    stepper.runToNewPosition(1260); // go to the upper end stop
    delay(250);
    stepper.setCurrentPosition(1260); // set max steps
    stepper.runToNewPosition(0);    // go to the lower end stop
    delay(250);
    stepper.setCurrentPosition(0);  // set steps to zero
    
}

// ----------------------------------------------------------------------------
//     LOOP loop - try to keep empty
//-----------------------------------------------------------------------------
void loop() {
  DcsBios::loop();
}

  Cheers

Les

Link to comment
Share on other sites

Hi Johan,

If you are looking for plug and play code you probably are not in the right forum here.

We mostly are hobbyists, having learned how to design and produce panels and deal with microcontrollers and their programming over years within that community.

As almost nobody uses the same hardware / software combination here, we only may suggest parts of a technical solution and point you into a new direction.

Depending on your implementation and feedback of results, we may bring you a step further to finalize your product.

So if you would show us parts of your code, we may look through it and post ideas to bring it to work.

Please don’t expect full code examples for exotic airplanes like the Bf-109 or so, as most of us started with the A-10, F-18 or similar modern jets.

The X27 stepper should work like that X25.168 from the example above, adjustment of the values are “trial and error” and best guesses.

The example is documented, so you even may adjust the steps and steps per degree of your motors.

For the modified one you have to provide us with more details on your modification.

As I personally don’t know the Vid26 stepper, you probably may point to a respective data sheet to see if we can help.

 

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

On 2/26/2023 at 12:08 PM, Vinc_Vega said:

Hi Johan,

If you are looking for plug and play code you probably are not in the right forum here.

We mostly are hobbyists, having learned how to design and produce panels and deal with microcontrollers and their programming over years within that community.

As almost nobody uses the same hardware / software combination here, we only may suggest parts of a technical solution and point you into a new direction.

Depending on your implementation and feedback of results, we may bring you a step further to finalize your product.

So if you would show us parts of your code, we may look through it and post ideas to bring it to work.

Please don’t expect full code examples for exotic airplanes like the Bf-109 or so, as most of us started with the A-10, F-18 or similar modern jets.

The X27 stepper should work like that X25.168 from the example above, adjustment of the values are “trial and error” and best guesses.

The example is documented, so you even may adjust the steps and steps per degree of your motors.

For the modified one you have to provide us with more details on your modification.

As I personally don’t know the Vid26 stepper, you probably may point to a respective data sheet to see if we can help.

 

Regards, Vinc

 

Thanks I'll make that and come back to you.. 

Link to comment
Share on other sites

I have this... see picture..

It is the altitude gauge.. driven by a x27 with 360 mod..

A arduino 

Easy driver..

How does it know where the 0 is? What do I need and can someone help me an the code .. it is for the 109 k4 

 

Thanks 

 

20230308_151906.jpg

1a578d09-7d81-47bd-9c2d-76eae896e098.jpg

Link to comment
Share on other sites

I personally have not tryed out the zero detection so far, therefore I have no code examples.

But, have you already read these postings?

 

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

On 2/23/2023 at 9:05 PM, lesthegrngo said:

This is a really simple code, you do not need a stepper driver and it will make an X27-168 stepper motor display the A10-C Engine 1 Core RPM as long as you connect the four stepper connections to pins 3, 4, 5 and 6  - although you will have to try the four variations to make it work right. It's pretty simple and needs no stepper drive as it is driven directly from the Nano. Please note that I am not the author of this code, that hero is also here on the forum!

  Cheers

Les

Hi Les I see that I can directly connect the x27.. can you help me to cet it to work and with a 0 ir? 

Thanks.. and can you provide the code.. I read your post also on arduino..

On 2/24/2023 at 5:44 AM, lesthegrngo said:

Good point - if you want it for USB you would replace 

//#define DCSBIOS_IRQ_SERIAL

#define DCSBIOS_RS485_SLAVE 35
#define TXENABLE_PIN 2

with

#define DCSBIOS_IRQ_SERIAL

//#define DCSBIOS_RS485_SLAVE 35
//#define TXENABLE_PIN 2

and the slave number is what you choose it to be

Les

I like to use rs485.. I also have that.. can I operate all on 5v?

Link to comment
Share on other sites

Looks good so far but you may have to change some pins.

Look at the first sketch here for swapped pins D5 and D6 within the AccelStepper declaration (3,4,6,5).

Beware off, that standard TX_Enable pin at the Nano is D2 or you have to declare another pin within your sketch.

Furthermore, D13 is not good as input pin as there already is the onboard LED connected to it. Use that pin as an output or de-solder the LED (not recommended).

You may use the analog pins as digital inputs as well.

For the RS485 master only an Arduino Mega works.

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

2 hours ago, Vinc_Vega said:

Looks good so far but you may have to change some pins.

Look at the first sketch here for swapped pins D5 and D6 within the AccelStepper declaration (3,4,6,5).

Beware off, that standard TX_Enable pin at the Nano is D2 or you have to declare another pin within your sketch.

Furthermore, D13 is not good as input pin as there already is the onboard LED connected to it. Use that pin as an output or de-solder the LED (not recommended).

You may use the analog pins as digital inputs as well.

For the RS485 master only an Arduino Mega works.

Regards, Vinc

 

Will an uno work also?

Link to comment
Share on other sites

No, unfortunately only Megas will work as masters. But each Mega can support up to 3 RS485 buses.

Edit: As a slave, the Mega, Uno and Nano boards do work.

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

3 hours ago, Vinc_Vega said:

No, unfortunately only Megas will work as masters. But each Mega can support up to 3 RS485 buses.

Edit: As a slave, the Mega, Uno and Nano boards do work.

Regards, Vinc

 

Ordered one.. can you help me on the code? That finds the zero point at startup? And the sketch in here I can use fot the non 360 dial? Is that correct?

I leave the rs485 until the mega will arrive..

Thanks I. Advance.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...