Jump to content

triise

Members
  • Posts

    91
  • Joined

  • Last visited

Personal Information

  • Flight Simulators
    DCS and FSX
  • Location
    Norway
  • Occupation
    Military officer

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thank you John :) I've been very busy the last 6 months with my new job, so the homepit has been collecting dust for the most of the time. Hopefully I'll have some time again soon. It's a bit annoying not having time for it, as I had a quick testflight last week and discovered that I'd forgotten many of the HOTAS commands... Well, they probably come back fast when I start again :pilotfly: Hows your project coming along John?
  2. Here is a link to all my files: https://www.dropbox.com/sh/ga4cgryjse1uonv/AADrdRTiHNqVnAPRpyNE9B7Qa?dl=0 It includes CamBam-files (and some in DXF only, there is even some in just GCODE as I don't know where the originals are...) for the panels I've made so far and also Arduino code for the panels. Keep in mind that the CamBam files is partly named in Norwegian, but I think you'll figure it out. The panels include: UFC, Altimeter, AUX-panel, NAV, Caution light panel, CMSP, Engine gauges, Landing gear panel, Armament panel, Elec panel, SAS panel. It also includes my Arduino code for the panels I've built. All the best - Tore
  3. It's been a while scince I've worked on my cockpit build, but I get a lot of requests for schematics and code. I'm posting it here for everyone who needs it. Caution panel: #include <DcsBios.h> #include <Servo.h> /**** Make your changes after this line ****/ DcsBios::LED clA1(0x10d4, 0x0001, 2); DcsBios::LED clA2(0x10d4, 0x0002, 3); DcsBios::LED clA3(0x10d4, 0x0004, 4); DcsBios::LED clA4(0x10d4, 0x0008, 5); DcsBios::LED clB1(0x10d4, 0x0010, 6); DcsBios::LED clB2(0x10d4, 0x0020, 7); DcsBios::LED clB3(0x10d4, 0x0040, 8); DcsBios::LED clB4(0x10d4, 0x0080, 9); DcsBios::LED clC1(0x10d4, 0x0100, 10); DcsBios::LED clC2(0x10d4, 0x0200, 11); DcsBios::LED clC3(0x10d4, 0x0400, 15); DcsBios::LED clC4(0x10d4, 0x0800, 14); DcsBios::LED clD1(0x10d4, 0x1000, 16); DcsBios::LED clD2(0x10d4, 0x2000, 17); DcsBios::LED clD3(0x10d4, 0x4000, 18); DcsBios::LED clD4(0x10d4, 0x8000, 19); DcsBios::LED clE1(0x10d6, 0x0001, 20); DcsBios::LED clE2(0x10d6, 0x0002, 21); DcsBios::LED clE3(0x10d6, 0x0004, 22); DcsBios::LED clE4(0x10d6, 0x0008, 23); DcsBios::LED clF1(0x10d6, 0x0010, 24); DcsBios::LED clF2(0x10d6, 0x0020, 25); DcsBios::LED clF3(0x10d6, 0x0040, 26); DcsBios::LED clF4(0x10d6, 0x0080, 27); DcsBios::LED clG1(0x10d6, 0x0100, 29); DcsBios::LED clG2(0x10d6, 0x0200, 28); DcsBios::LED clG3(0x10d6, 0x0400, 31); DcsBios::LED clG4(0x10d6, 0x0800, 30); DcsBios::LED clH1(0x10d6, 0x1000, 33); DcsBios::LED clH2(0x10d6, 0x2000, 32); DcsBios::LED clH3(0x10d6, 0x4000, 35); DcsBios::LED clH4(0x10d6, 0x8000, 34); DcsBios::LED clI1(0x10d8, 0x0001, 36); DcsBios::LED clI2(0x10d8, 0x0002, 37); DcsBios::LED clI3(0x10d8, 0x0004, 38); DcsBios::LED clI4(0x10d8, 0x0008, 39); DcsBios::LED clJ1(0x10d8, 0x0010, 40); DcsBios::LED clJ2(0x10d8, 0x0020, 41); DcsBios::LED clJ3(0x10d8, 0x0040, 42); DcsBios::LED clJ4(0x10d8, 0x0080, 43); DcsBios::LED clK1(0x10d8, 0x0100, 44); DcsBios::LED clK2(0x10d8, 0x0200, 45); DcsBios::LED clK3(0x10d8, 0x0400, 46); DcsBios::LED clK4(0x10d8, 0x0800, 47); DcsBios::LED clL1(0x10d8, 0x1000, 49); DcsBios::LED clL2(0x10d8, 0x2000, 48); DcsBios::LED clL3(0x10d8, 0x4000, 50); DcsBios::LED clL4(0x10d8, 0x8000, 51); /**** In most cases, you do not have to change anything below this line ****/ /* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */ DcsBios::ProtocolParser parser; void setup() { Serial.begin(500000); } /* Your main loop needs to pass data from the DCS-BIOS export stream to the parser object you instantiated above. It also needs to call DcsBios::PollingInput::pollInputs() to detect changes in the state of connected controls and pass them on to DCS. */ void loop() { // feed incoming data to the parser while (Serial.available()) { parser.processChar(Serial.read()); } // poll inputs DcsBios::PollingInput::pollInputs(); } /* You need to define void sendDcsBiosMessage(const char* msg, const char* arg) so that the string msg, followed by a space, the string arg and a newline gets sent to the DCS-BIOS import stream. In this example we send it to the serial port, so you need to run socat to read the data from the serial port and send it over UDP to DCS-BIOS. If you are using an Ethernet Shield, you would probably want to send a UDP packet from this subroutine. */ void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); } /* This subroutine gets called every time a message is received from the export stream (you need to define it even if it does nothing). Use this to handle outputs which are not covered by the DcsBios Arduino library (e.g. displays). */ void onDcsBiosWrite(unsigned int address, unsigned int value) { }Schematics: https://www.dropbox.com/s/05br7jfawsnkidc/caution%20light_panel%20LED%20MEGA%20kretskort.cb?dl=0 CMSP Panel: #include <DcsBios.h> #include <Servo.h> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); /**** Make your changes after this line ****/ DcsBios::Switch2Pos cmspArw1("CMSP_ARW1", 42); DcsBios::Switch2Pos cmspArw2("CMSP_ARW2", 43); DcsBios::Switch2Pos cmspArw3("CMSP_ARW3", 40); DcsBios::Switch2Pos cmspArw4("CMSP_ARW4", 41); DcsBios::Switch3Pos cmspDisp("CMSP_DISP", 38, 39); DcsBios::Switch3Pos cmspJmr("CMSP_JMR", 34, 35); DcsBios::Switch2Pos cmspJtsn("CMSP_JTSN", 51); const byte cmspModePins[5] = {45, 46, 47, 48, 49}; DcsBios::SwitchMultiPos cmspMode("CMSP_MODE", cmspModePins, 5); DcsBios::Switch3Pos cmspMws("CMSP_MWS", 32, 33); DcsBios::Switch2Pos cmspRtn("CMSP_RTN", 50); DcsBios::Switch3Pos cmspRwr("CMSP_RWR", 36, 37); DcsBios::Switch3Pos cmspUpdn("CMSP_UPDN", 53, 52); void onCmsp1Change(char* newValue) { lcd.setCursor(0, 0); lcd.print(newValue); } DcsBios::StringBuffer<19> cmsp1Buffer(0x1000, onCmsp1Change); void onCmsp2Change(char* newValue) { lcd.setCursor(0, 1); lcd.print(newValue); } DcsBios::StringBuffer<19> cmsp2Buffer(0x1014, onCmsp2Change); /**** In most cases, you do not have to change anything below this line ****/ /* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */ DcsBios::ProtocolParser parser; void setup() { Serial.begin(500000); lcd.begin(20, 2); lcd.clear(); } /* Your main loop needs to pass data from the DCS-BIOS export stream to the parser object you instantiated above. It also needs to call DcsBios::PollingInput::pollInputs() to detect changes in the state of connected controls and pass them on to DCS. */ void loop() { // feed incoming data to the parser while (Serial.available()) { parser.processChar(Serial.read()); } // poll inputs DcsBios::PollingInput::pollInputs(); } /* You need to define void sendDcsBiosMessage(const char* msg, const char* arg) so that the string msg, followed by a space, the string arg and a newline gets sent to the DCS-BIOS import stream. In this example we send it to the serial port, so you need to run socat to read the data from the serial port and send it over UDP to DCS-BIOS. If you are using an Ethernet Shield, you would probably want to send a UDP packet from this subroutine. */ void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); } /* This subroutine gets called every time a message is received from the export stream (you need to define it even if it does nothing). Use this to handle outputs which are not covered by the DcsBios Arduino library (e.g. displays). */ void onDcsBiosWrite(unsigned int address, unsigned int value) { } Schematics: https://www.dropbox.com/s/2tg4edssgah41po/cmsp_Panel%204.cb?dl=0 I'll post more later :pilotfly:
  4. https://vimeo.com/142653309 Here I tried to use micro steps... Seems like the Arduino can't keep up with multiple gauges. Or maybe I should write the code in some other way(?)
  5. Thanks again John, helpfull as always! I'd been stuck without you :) Ok, So I got the Left RPM gauge to behave like I wanted, but when I try to do the same with Left Oil press, I get some strange behaviour. Also, I don't get consistent results every time.. Sometimes it doesn't zero, and sometimes the RPM gauge goes to 60-70 when its supposed to go to 95%. Looks like the steppers sometimes stop for a fraction of a second, and then run again. I could not get the results I was looking for with stepper.moveTo(), and had to use stepper.runToNewPosition(). when using the moveTo it didn't sync with the sim if I started in-flight. I'm starting to get grey hairs... https://vimeo.com/142651911
  6. Thanks for the input John. What happens when I use your sketch is that the stepper goes to in the start for zeroing (opposite of what it should do). May I ask how you wire your stepper? maybe I've gotten it wrong... Also, how do you wire your stepper on the Easydriver board? I've got some of them but didn't get the stepper to move at all... EDIT: got the stepper to run on the Easydriver board. Now, I get the pointer on my gauge to move, but it only moves between 0 and 10%.... Looks like it only moves 1/10th of the distance its supposed to. Here is the code: #include <AccelStepper.h>// include AccelStepper library #include <DcsBios.h> #include <Servo.h> // DcsBios-related declarations DcsBios::ProtocolParser parser; AccelStepper stepper (1, 9, 8); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5 int targetpos = 0; void setup() { stepper.setMaxSpeed(1500.0); stepper.setAcceleration(10000.0); stepper.setSpeed(1000); stepper.runToNewPosition(-630); //backwards sweep to find hard stop stepper.setCurrentPosition(0); //establishes the zero position { Serial.begin(250000); } } void loop() { // handle DcsBios communication while (Serial.available()) { parser.processChar(Serial.read()); stepper.run(); } DcsBios::PollingInput::pollInputs(); } void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); } void onDcsBiosWrite(unsigned int address, unsigned int value) { if (address == 0x10b4) { targetpos = map(value, 0, 65535, 0, 590); stepper.moveTo(targetpos); } }
  7. Yes, you are most certainly correct. I discovered my little mistake pretty quick. Now this code doesn't work very well, so I'll have to come up with something else. The problem with my code is when I start in game and let's say the RPM is at 60%, the pointer should first go to 0, then up to 60%, but it goes only to zero and then stays there. If I increase RPM to 80%, my pointer goes to 20%... Also I can't seem to get the stepper to move fast enough to keep up with the in game pointer. It doesn't matter what speed I set in the code, it runs at the same speed. Have you got your gauges up and running John?
  8. Thanks for the tip John, actually I eventually stumbeled upon your thread in the forums over there. Now I think I have something that works. Will try to run all the steppers from one mega using this code. // include AccelStepper library #include <AccelStepper.h> #include <DcsBios.h> #include <Servo.h> // DcsBios-related declarations DcsBios::ProtocolParser parser; #define STEPS_PER_REVOLUTION 630 AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5 int currentStepperPosition = 0; // current stepper position (in steps, from 0 to STEPS_PER_REVOLUTION+1) signed long lastAccelStepperPosition; void setup() { stepper.setMaxSpeed(1000.0); stepper.setAcceleration(10000.0); stepper.setSpeed(1000); stepper.runToNewPosition(630); //backwards sweep to find hard stop stepper.setCurrentPosition(0); //establishes the zero position { Serial.begin(250000); } } int targetposLRPM = 0; int posLRPM = 0; void loop() { // handle DcsBios communication while (Serial.available()) { parser.processChar(Serial.read()); } DcsBios::PollingInput::pollInputs(); } void onDcsBiosWrite(unsigned int address, unsigned int value) { if (address == 0x10b4) { int targetposLRPM = map(value, 65535, 0, 0, 590); { if (value == targetposLRPM) return; stepper.runToNewPosition(targetposLRPM); value = targetposLRPM; stepper.run(); } } }
  9. Well, you are not alone. Over here in Norway all building materials are measured in inches... some things are not ment to change :music_whistling:
  10. Ok, so now I did test the Accelstepper on my Arduino, but I'm quite stuck... As you might understand, my coding skills are rather limited, but I usually get the hang of it when I find some code and do some modifications to it. Now I have managed to interface the left engine core speed for my EMI, but as I am used to the "stepper" library, I don't get the hang of how you do things in Accelstepper. Here is the code I've been fiddling with tonight: // include AccelStepper library #include <AccelStepper.h> //#include <Stepper.h> // include DcsBios library #include <DcsBios.h> #include <Servo.h> // DcsBios-related declarations DcsBios::ProtocolParser parser; #define STEPS_PER_REVOLUTION 630 #define ZERO_OFFSET 0 AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5 int currentStepperPosition = 0; // current stepper position (in steps, from 0 to STEPS_PER_REVOLUTION+1) signed long lastAccelStepperPosition; void setup() { stepper.setMaxSpeed(2000.0); stepper.setAcceleration(2000.0); stepper.setSpeed(400); stepper.runToNewPosition(630); //backwards sweep to find hard stop stepper.setCurrentPosition(0); //establishes the zero position { Serial.begin(250000); // pinMode (12,INPUT); // LOW when in zero position, HIGH otherwise // stepper.setMaxSpeed(100); //stepper.setAcceleration(20); //stepper.moveTo(500); // set up stepper motor for zeroing //stepper.setMaxSpeed(1000); //stepper.setSpeed(500); // run clockwise until we detect the zero position //while (digitalRead (12)==1) { // stepper.runSpeed(); //} // add zero offset //stepper.runToNewPosition(stepper.currentPosition() + ZERO_OFFSET); // tell the AccelStepper library that we are at position zero stepper.setCurrentPosition(0); lastAccelStepperPosition = 0; // set stepper acceleration in steps per second per second // (default is zero) stepper.setAcceleration(1000); } } void loop() { // handle DcsBios communication while (Serial.available()) { parser.processChar(Serial.read()); } DcsBios::PollingInput::pollInputs(); // move stepper motor stepper.run(); } void onDcsBiosWrite(unsigned int address, unsigned int value) { if (address == 0x10a8) { digitalWrite (13,1); unsigned int alt100ftValue = (value & 0xffff) >> 0; // convert data from DCS to a target position expressed as a number of steps int targetPosition = map(alt100ftValue, 0, 65535, 0, 600); // adjust currentStepperPosition to include the distance our stepper motor // was moved since we last updated it int movementSinceLastUpdate = stepper.currentPosition() - lastAccelStepperPosition; currentStepperPosition += movementSinceLastUpdate; lastAccelStepperPosition = stepper.currentPosition(); if (currentStepperPosition < 0) currentStepperPosition += STEPS_PER_REVOLUTION; if (currentStepperPosition > STEPS_PER_REVOLUTION) currentStepperPosition -= STEPS_PER_REVOLUTION; int delta = targetPosition - currentStepperPosition; // if we would move more than 180 degree counterclockwise, move clockwise instead if (delta < -(STEPS_PER_REVOLUTION/2)) delta += STEPS_PER_REVOLUTION; // if we would move more than 180 degree clockwise, move counterclockwise instead if (delta > (STEPS_PER_REVOLUTION/2)) delta -= STEPS_PER_REVOLUTION; // tell AccelStepper to move relative to the current position stepper.move(delta); } } The first thing I notice is that the steppers move in the opposite direction (CCW), so when I increase the throttle the pointer goes CCW and vice versa when I decrease it. Haven't figured out how to reverse this. Anyone? :helpsmilie: Also, I can't find out how I define the number of steps the motor has (630 for 315 deg) so that the DCS-BIOS -> Arduino scale will be the same. Then I need to find out how to map the position correctly... As you can see, the code was something I found on another thread here which is written to work with the Altimeter (and it did work well). But now I'm trying to incorporate this code to work with my EMI. Inputs are very much welcome :) Now it's off to bed...
  11. Now I've done some more fiddling with this. Found out that I had the wrong address on the left oil pressure gauge, and when I set up two steppers alone, it works. I'm now guessing that it might be some interference between the steppers and all the wiring. Going to try to make cabling a bit more tidier and see what happens. Also I've reduced the motor speed to 20, and using the 250000 serial interface. One problem that seems to happen anyway, is that some of the steppers flip back and forth while they are stepping towards the hard stop (going back to zero pos). And sometimes they stop at 10%, sometimes at 0% or in between. The steppers still think that they are at zero, and I get wrong readings. (Not sure if you understood that, I'll make a video later.)
  12. triise's A-10C pit Some problems with my setup. Temp gauges and right RPM works, the rest behaves irrationally. It's the same code on both RPM gauges, so it's a bit of a mystery to me... https://vimeo.com/141770184 Anyone care to look at the code and se if I've done something completly wrong? #include <Stepper.h> #include <DcsBios.h> #include <Servo.h> #define STEPS_LTEMP 590 // steps per revolution (limited to 315°) #define LTEMP1 2 #define LTEMP2 3 #define LTEMP3 4 #define LTEMP4 5 #define STEPS_RTEMP 590 #define RTEMP1 6 #define RTEMP2 7 #define RTEMP3 8 #define RTEMP4 9 #define STEPS_LRPM 590 #define LRPM1 10 #define LRPM2 11 #define LRPM3 12 #define LRPM4 14 #define STEPS_RRPM 590 #define RRPM1 15 #define RRPM2 16 #define RRPM3 17 #define RRPM4 18 #define STEPS_LOIL 630 #define LOIL1 19 #define LOIL2 20 #define LOIL3 21 #define LOIL4 22 #define STEPS_ROIL 630 #define ROIL1 23 #define ROIL2 24 #define ROIL3 25 #define ROIL4 26 #define STEPS_LFAN 630 #define LFAN1 27 #define LFAN2 28 #define LFAN3 29 #define LFAN4 30 #define STEPS_RFAN 630 #define RFAN1 31 #define RFAN2 32 #define RFAN3 33 #define RFAN4 34 #define STEPS_LFFL 630 #define LFFL1 35 #define LFFL2 36 #define LFFL3 37 #define LFFL4 38 #define STEPS_RFFL 630 #define RFFL1 39 #define RFFL2 40 #define RFFL3 41 #define RFFL4 42 #define STEPS_APURPM 590 #define APURPM1 43 #define APURPM2 44 #define APURPM3 45 #define APURPM4 46 #define STEPS_APUEGT 590 #define APUEGT1 47 #define APUEGT2 48 #define APUEGT3 49 #define APUEGT4 50 Stepper LTEMP (STEPS_LTEMP, LTEMP1, LTEMP2, LTEMP3, LTEMP4); Stepper RTEMP (STEPS_RTEMP, RTEMP1, RTEMP2, RTEMP3, RTEMP4); Stepper LRPM (STEPS_LRPM, LRPM1, LRPM2, LRPM3, LRPM4); Stepper RRPM (STEPS_RRPM, RRPM1, RRPM2, RRPM3, RRPM4); Stepper LOIL (STEPS_LOIL, LOIL1, LOIL2, LOIL3, LOIL4); Stepper ROIL (STEPS_ROIL, ROIL1, ROIL2, ROIL3, ROIL4); Stepper LFAN (STEPS_LFAN, LFAN1, LFAN2, LFAN3, LFAN4); Stepper RFAN (STEPS_RFAN, RFAN1, RFAN2, RFAN3, RFAN4); Stepper LFFL (STEPS_LFFL, LFFL1, LFFL2, LFFL3, LFFL4); Stepper RFFL (STEPS_RFFL, RFFL1, RFFL2, RFFL3, RFFL4); Stepper APURPM (STEPS_APURPM, APURPM1, APURPM2, APURPM3, APURPM4); Stepper APUEGT (STEPS_APUEGT, APUEGT1, APUEGT2, APUEGT3, APUEGT4); //int posSPEED = 0; //int targetposSPEED = 0; //int posVSI = 0; //int targetposVSI = 0; int posLTEMP = 0; int targetposLTEMP = 0; int posRTEMP = 0; int targetposRTEMP = 0; int posLRPM = 0; int targetposLRPM = 0; int posRRPM = 0; int targetposRRPM = 0; int posLOIL = 0; int targetposLOIL = 0; int posROIL = 0; int targetposROIL = 0; int posLFAN = 0; int targetposLFAN = 0; int posRFAN = 0; int targetposRFAN = 0; int posLFFL= 0; int targetposLFFL = 0; int posRFFL = 0; int targetposRFFL = 0; int posAPURPM = 0; int targetposAPURPM = 0; int posAPUEGT = 0; int targetposAPUEGT = 0; void onDcsBiosWrite(unsigned int address, unsigned int value) { if (address == 0x10b4) { targetposLTEMP = map(value,0,65535,0,590); } if (address == 0x10b8) { targetposRTEMP = map(value,0,65535,0,590); } if (address == 0x10a6) { targetposLRPM = map(value,0,65535,0,590); } if (address == 0x10ac) { targetposRRPM = map(value,0,65535,0,590); } if (address == 0x10c6) { targetposLOIL = map(value,0,65535,0,630); } if (address == 0x10c8) { targetposROIL = map(value,0,65535,0,630); } if (address == 0x10a2) { targetposLFAN = map(value,0,65535,0,630); } if (address == 0x10a4) { targetposRFAN = map(value,0,65535,0,630); } if (address == 0x10ae) { targetposLFFL = map(value,0,65535,0,630); } if (address == 0x10b0) { targetposRFFL = map(value,0,65535,0,630); } if (address == 0x10be) { targetposAPURPM = map(value,0,65535,0,590); } if (address == 0x10c0) { targetposAPUEGT = map(value,0,65535,0,590); } } DcsBios::ProtocolParser parser; void setup() { Serial.begin(250000); LTEMP.setSpeed(30); // set the motor speed to 30 RPM (360 PPS aprox.). LTEMP.step(590); //Reset Position(630 steps counter-clockwise). RTEMP.setSpeed(30); // set the motor speed to 30 RPM (360 PPS aprox.). RTEMP.step(590); //Reset Position(630 steps counter-clockwise). LRPM.setSpeed(30); // set the motor speed to 30 RPM (360 PPS aprox.). LRPM.step(590); //Reset Position(630 steps counter-clockwise). RRPM.setSpeed(30); RRPM.step(590); LOIL.setSpeed(30); LOIL.step(630); ROIL.setSpeed(30); ROIL.step(630); LFAN.setSpeed(30); LFAN.step(630); RFAN.setSpeed(30); RFAN.step(630); LFFL.setSpeed(30); LFFL.step(630); RFFL.setSpeed(30); RFFL.step(630); APURPM.setSpeed(30); APURPM.step(590); APUEGT.setSpeed(30); APUEGT.step(590); } void loop() { // feed incoming data to the parser while (Serial.available()) { parser.processChar(Serial.read()); } if(abs(targetposLTEMP - posLTEMP)> 2){ //if diference is greater than 2 steps. if(targetposLTEMP > posLTEMP) { LTEMP.step(-1); // move one step to the left. posLTEMP++; } if(targetposLTEMP < posLTEMP){ LTEMP.step(1); // move one step to the right. posLTEMP--; } } if(abs(targetposRTEMP - posRTEMP)> 2){ //if diference is greater than 2 steps. if(targetposRTEMP > posRTEMP) { RTEMP.step(-1); // move one step to the left. posRTEMP++; } if(targetposRTEMP < posRTEMP){ RTEMP.step(1); // move one step to the right. posRTEMP--; } } if(abs(targetposLRPM - posLRPM)> 2){ //if diference is greater than 2 steps. if(targetposLRPM > posLRPM) { LRPM.step(-1); // move one step to the left. posLRPM++; } if(targetposLRPM < posLRPM){ LRPM.step(1); // move one step to the right. posLRPM--; } } if(abs(targetposRRPM - posRRPM)> 2){ //if diference is greater than 2 steps. if(targetposRRPM > posRRPM) { RRPM.step(-1); // move one step to the left. posRRPM++; } if(targetposRRPM < posRRPM){ RRPM.step(1); // move one step to the right. posRRPM--; } } if(abs(targetposLOIL - posLOIL)> 2){ //if diference is greater than 2 steps. if(targetposLOIL > posLOIL) { LOIL.step(-1); // move one step to the left. posLOIL++; } if(targetposLOIL < posLOIL){ LOIL.step(1); // move one step to the right. posLOIL--; } } if(abs(targetposROIL - posROIL)> 2){ //if diference is greater than 2 steps. if(targetposROIL > posROIL) { ROIL.step(-1); // move one step to the left. posROIL++; } if(targetposROIL < posROIL){ ROIL.step(1); // move one step to the right. posROIL--; } } if(abs(targetposLFAN - posLFAN)> 2){ //if diference is greater than 2 steps. if(targetposLFAN > posLFAN) { LFAN.step(-1); // move one step to the left. posLFAN++; } if(targetposLFAN < posLFAN){ LFAN.step(1); // move one step to the right. posLFAN--; } } if(abs(targetposRFAN - posRFAN)> 2){ //if diference is greater than 2 steps. if(targetposRFAN > posRFAN) { RFAN.step(-1); // move one step to the left. posRFAN++; } if(targetposRFAN < posRFAN){ RFAN.step(1); // move one step to the right. posRFAN--; } } if(abs(targetposLFFL - posLFFL)> 2){ //if diference is greater than 2 steps. if(targetposLFFL > posLFFL) { LFFL.step(-1); // move one step to the left. posLOIL++; } if(targetposLFFL < posLFFL){ LFFL.step(1); // move one step to the right. posLFFL--; } } if(abs(targetposRFFL - posRFFL)> 2){ //if diference is greater than 2 steps. if(targetposRFFL > posRFFL) { RFFL.step(-1); // move one step to the left. posRFFL++; } if(targetposRFFL < posRFFL){ RFFL.step(1); // move one step to the right. posRFFL--; } } if(abs(targetposAPURPM - posAPURPM)> 2){ //if diference is greater than 2 steps. if(targetposAPURPM > posAPURPM) { APURPM.step(-1); // move one step to the left. posAPURPM++; } if(targetposAPURPM < posAPURPM){ APURPM.step(1); // move one step to the right. posAPURPM--; } } if(abs(targetposAPUEGT - posAPUEGT)> 2){ //if diference is greater than 2 steps. if(targetposAPUEGT > posAPUEGT) { APUEGT.step(-1); // move one step to the left. posAPUEGT++; } if(targetposAPUEGT < posAPUEGT){ APUEGT.step(1); // move one step to the right. posAPUEGT--; } } DcsBios::PollingInput::pollInputs();} void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); }
  13. I'm using the VID2902P, as I think it's easier to have the connections on the back (for access).
  14. Finished up on the code tonight, now I'll have to draw the PCB for the stepper motors. Will probably cut it tomorrow and test the code. (I've already tested this code for one of the steppers, so it should in theory work on all 12 - knock on wood). Here's the code if it's of interest: #include <Stepper.h> #include <DcsBios.h> #include <Servo.h> #define STEPS_LTEMP 590 // steps per revolution (limited to 315°) #define LTEMP1 2 #define LTEMP2 3 #define LTEMP3 4 #define LTEMP4 5 #define STEPS_RTEMP 590 #define RTEMP1 6 #define RTEMP2 7 #define RTEMP3 8 #define RTEMP4 9 #define STEPS_LRPM 630 #define LRPM1 10 #define LRPM2 11 #define LRPM3 12 #define LRPM4 14 #define STEPS_RRPM 630 #define RRPM1 15 #define RRPM2 16 #define RRPM3 17 #define RRPM4 18 #define STEPS_LOIL 630 #define LOIL1 19 #define LOIL2 20 #define LOIL3 21 #define LOIL4 22 #define STEPS_ROIL 630 #define ROIL1 23 #define ROIL2 24 #define ROIL3 25 #define ROIL4 26 #define STEPS_LFAN 630 #define LFAN1 27 #define LFAN2 28 #define LFAN3 29 #define LFAN4 30 #define STEPS_RFAN 630 #define RFAN1 31 #define RFAN2 32 #define RFAN3 33 #define RFAN4 34 #define STEPS_LFFL 630 #define LFFL1 35 #define LFFL2 36 #define LFFL3 37 #define LFFL4 38 #define STEPS_RFFL 630 #define RFFL1 39 #define RFFL2 40 #define RFFL3 41 #define RFFL4 42 #define STEPS_APURPM 590 #define APURPM1 43 #define APURPM2 44 #define APURPM3 45 #define APURPM4 46 #define STEPS_APUEGT 590 #define APUEGT1 47 #define APUEGT2 48 #define APUEGT3 49 #define APUEGT4 50 Stepper LTEMP (STEPS_LTEMP, LTEMP1, LTEMP2, LTEMP3, LTEMP4); Stepper RTEMP (STEPS_RTEMP, RTEMP1, RTEMP2, RTEMP3, RTEMP4); Stepper LRPM (STEPS_LRPM, LRPM1, LRPM2, LRPM3, LRPM4); Stepper RRPM (STEPS_RRPM, RRPM1, RRPM2, RRPM3, RRPM4); Stepper LOIL (STEPS_LOIL, LOIL1, LOIL2, LOIL3, LOIL4); Stepper ROIL (STEPS_ROIL, ROIL1, ROIL2, ROIL3, ROIL4); Stepper LFAN (STEPS_LFAN, LFAN1, LFAN2, LFAN3, LFAN4); Stepper RFAN (STEPS_RFAN, RFAN1, RFAN2, RFAN3, RFAN4); Stepper LFFL (STEPS_LFFL, LFFL1, LFFL2, LFFL3, LFFL4); Stepper RFFL (STEPS_RFFL, RFFL1, RFFL2, RFFL3, RFFL4); Stepper APURPM (STEPS_APURPM, APURPM1, APURPM2, APURPM3, APURPM4); Stepper APUEGT (STEPS_APUEGT, APUEGT1, APUEGT2, APUEGT3, APUEGT4); //int posSPEED = 0; //int targetposSPEED = 0; //int posVSI = 0; //int targetposVSI = 0; int posLTEMP = 0; int targetposLTEMP = 0; int posRTEMP = 0; int targetposRTEMP = 0; int posLRPM = 0; int targetposLRPM = 0; int posRRPM = 0; int targetposRRPM = 0; int posLOIL = 0; int targetposLOIL = 0; int posROIL = 0; int targetposROIL = 0; int posLFAN = 0; int targetposLFAN = 0; int posRFAN = 0; int targetposRFAN = 0; int posLFFL= 0; int targetposLFFL = 0; int posRFFL = 0; int targetposRFFL = 0; int posAPURPM = 0; int targetposAPURPM = 0; int posAPUEGT = 0; int targetposAPUEGT = 0; void onDcsBiosWrite(unsigned int address, unsigned int value) { if (address == 0x10b4) { targetposLTEMP = map(value,0,65535,0,590); } if (address == 0x10b8) { targetposRTEMP = map(value,0,65535,0,590); } if (address == 0x10a6) { targetposLRPM = map(value,0,65535,0,630); } if (address == 0x10ac) { targetposRRPM = map(value,0,65535,0,630); } if (address == 0x10c6) { targetposLOIL = map(value,0,65535,0,630); } if (address == 0x10c8) { targetposROIL = map(value,0,65535,0,630); } if (address == 0x10a2) { targetposLFAN = map(value,0,65535,0,630); } if (address == 0x10a4) { targetposRFAN = map(value,0,65535,0,630); } if (address == 0x10ae) { targetposLFFL = map(value,0,65535,0,630); } if (address == 0x10b0) { targetposRFFL = map(value,0,65535,0,630); } if (address == 0x10be) { targetposAPURPM = map(value,0,65535,0,590); } if (address == 0x10c0) { targetposAPUEGT = map(value,0,65535,0,590); } } DcsBios::ProtocolParser parser; void setup() { Serial.begin(500000); LTEMP.setSpeed(60); // set the motor speed to 30 RPM (360 PPS aprox.). LTEMP.step(590); //Reset Position(630 steps counter-clockwise). RTEMP.setSpeed(60); // set the motor speed to 30 RPM (360 PPS aprox.). RTEMP.step(590); //Reset Position(630 steps counter-clockwise). LRPM.setSpeed(60); // set the motor speed to 30 RPM (360 PPS aprox.). LRPM.step(630); //Reset Position(630 steps counter-clockwise). RRPM.setSpeed(60); RRPM.step(630); LOIL.setSpeed(60); LOIL.step(630); ROIL.setSpeed(60); ROIL.step(630); LFAN.setSpeed(60); LFAN.step(630); RFAN.setSpeed(60); RFAN.step(630); LFFL.setSpeed(60); LFFL.step(630); RFFL.setSpeed(60); RFFL.step(630); APURPM.setSpeed(60); APURPM.step(590); APUEGT.setSpeed(60); APUEGT.step(590); } void loop() { // feed incoming data to the parser while (Serial.available()) { parser.processChar(Serial.read()); } if(abs(targetposLTEMP - posLTEMP)> 2){ //if diference is greater than 2 steps. if(targetposLTEMP > posLTEMP) { LTEMP.step(-1); // move one step to the left. posLTEMP++; } if(targetposLTEMP < posLTEMP){ LTEMP.step(1); // move one step to the right. posLTEMP--; } } if(abs(targetposRTEMP - posRTEMP)> 2){ //if diference is greater than 2 steps. if(targetposRTEMP > posRTEMP) { RTEMP.step(-1); // move one step to the left. posRTEMP++; } if(targetposRTEMP < posRTEMP){ RTEMP.step(1); // move one step to the right. posRTEMP--; } } if(abs(targetposLRPM - posLRPM)> 2){ //if diference is greater than 2 steps. if(targetposLRPM > posLRPM) { LRPM.step(-1); // move one step to the left. posLRPM++; } if(targetposLRPM < posLRPM){ LRPM.step(1); // move one step to the right. posLRPM--; } } if(abs(targetposRRPM - posRRPM)> 2){ //if diference is greater than 2 steps. if(targetposRRPM > posRRPM) { RRPM.step(-1); // move one step to the left. posRRPM++; } if(targetposRRPM < posRRPM){ RRPM.step(1); // move one step to the right. posRRPM--; } } if(abs(targetposLOIL - posLOIL)> 2){ //if diference is greater than 2 steps. if(targetposLOIL > posLOIL) { LOIL.step(-1); // move one step to the left. posLOIL++; } if(targetposLOIL < posLOIL){ LOIL.step(1); // move one step to the right. posLOIL--; } } if(abs(targetposROIL - posROIL)> 2){ //if diference is greater than 2 steps. if(targetposROIL > posROIL) { ROIL.step(-1); // move one step to the left. posROIL++; } if(targetposROIL < posROIL){ ROIL.step(1); // move one step to the right. posROIL--; } } if(abs(targetposLFAN - posLFAN)> 2){ //if diference is greater than 2 steps. if(targetposLFAN > posLFAN) { LFAN.step(-1); // move one step to the left. posLFAN++; } if(targetposLFAN < posFAN){ LFAN.step(1); // move one step to the right. posLFAN--; } } if(abs(targetposRFAN - posRFAN)> 2){ //if diference is greater than 2 steps. if(targetposRFAN > posRFAN) { RFAN.step(-1); // move one step to the left. posRFAN++; } if(targetposRFAN < posRFAN){ RFAN.step(1); // move one step to the right. posRFAN--; } } if(abs(targetposLFFL - posLFFL)> 2){ //if diference is greater than 2 steps. if(targetposLFFL > posLFFL) { LFFL.step(-1); // move one step to the left. posLOIL++; } if(targetposLFFL < posLFFL){ LFFL.step(1); // move one step to the right. posLFFL--; } } if(abs(targetposRFFL - posRFFL)> 2){ //if diference is greater than 2 steps. if(targetposRFFL > posRFFL) { RFFL.step(-1); // move one step to the left. posRFFL++; } if(targetposRFFL < posRFFL){ RFFL.step(1); // move one step to the right. posRFFL--; } } if(abs(targetposAPURPM - posAPURPM)> 2){ //if diference is greater than 2 steps. if(targetposAPURPM > posAPURPM) { APURPM.step(-1); // move one step to the left. posAPURPM++; } if(targetposAPURPM < posAPURPM){ APURPM.step(1); // move one step to the right. posAPURPM--; } } if(abs(targetposAPUEGT - posAPUEGT)> 2){ //if diference is greater than 2 steps. if(targetposAPUEGT > posAPUEGT) { APUEGT.step(-1); // move one step to the left. posAPUEGT++; } if(targetposAPUEGT < posAPUEGT){ APUEGT.step(1); // move one step to the right. posAPUEGT--; } } DcsBios::PollingInput::pollInputs();} void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); }
  15. triise's A-10C pit Testing APU stepper (sorry about the rotated video) https://vimeo.com/141662385 Final assembly:
×
×
  • Create New...