FSFIan Posted October 5, 2015 Posted October 5, 2015 If you have modified your BIOSConfig.lua, make a backup of that. Then just copy the new Scripts/DCS-BIOS folder over the old one. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
triise Posted October 6, 2015 Author Posted October 6, 2015 Engine panel in progress. Made a mistake while engraving (top left gauge) so I'll be making a new tonight. Also found a god solution to use VID29 steppers for this application, and having 1 MEGA board to drive them all. I'll post the code later (it's based on an example I received from Warhog. Thanks again John. Regards, Tore - Newbie simpit builder and electronics geek -
triise Posted October 6, 2015 Author Posted October 6, 2015 (edited) triise's A-10C pit https://vimeo.com/141560760 Second run :) Result: The top plate, which also will contain plexiglass over the instruments. Stepper motors in place: Edited October 6, 2015 by triise 1 Regards, Tore - Newbie simpit builder and electronics geek -
triise Posted October 7, 2015 Author Posted October 7, 2015 (edited) triise's A-10C pit Testing APU stepper (sorry about the rotated video) https://vimeo.com/141662385 Final assembly: Edited October 7, 2015 by triise Regards, Tore - Newbie simpit builder and electronics geek -
triise Posted October 7, 2015 Author Posted October 7, 2015 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'); } Regards, Tore - Newbie simpit builder and electronics geek -
Patriot Posted October 7, 2015 Posted October 7, 2015 Very good! You use VID29-05P or VID29-02P ?? My cockpit A-10C Строю кокпит A-10C i7 7700k, 32Gb RAM, SSD NVMe, GTX 1080, Hotas Warthog, HTC Vive. ----------------- With love from Russia
triise Posted October 7, 2015 Author Posted October 7, 2015 Very good! You use VID29-05P or VID29-02P ?? I'm using the VID2902P, as I think it's easier to have the connections on the back (for access). Regards, Tore - Newbie simpit builder and electronics geek -
Hansolo Posted October 8, 2015 Posted October 8, 2015 Very nice Sir :thumbup: Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album
triise Posted October 8, 2015 Author Posted October 8, 2015 (edited) 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'); } Edited October 8, 2015 by triise Regards, Tore - Newbie simpit builder and electronics geek -
Warhog Posted October 8, 2015 Posted October 8, 2015 This is a complete guess on my part but I think it's the stepper library you are using. It blocks movement of steppers until one reaches it target and then two gets to reach its target and so on. Except nobody beyond the first one get to its target because all are in a continuous state of movement. I think you need to use the Accel library as it's designed to allow non blocking movement if you use the correct function calls. Is this correct?...asking anyone who knows the Accel library... Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
triise Posted October 8, 2015 Author Posted October 8, 2015 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.) Regards, Tore - Newbie simpit builder and electronics geek -
triise Posted October 8, 2015 Author Posted October 8, 2015 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... Regards, Tore - Newbie simpit builder and electronics geek -
Warhog Posted October 9, 2015 Posted October 9, 2015 Hi Tore Try asking these questions on this forum https://groups.google.com/forum/m/?hl=en#!forum/accelstepper The fellow who wrote the Accel library resides there and will help you. The people there are very knowledgeable. You might also look into this Easy Driver board. The Chinese knockoffs are less than $1.50 a piece. Also, to reverse direction there is an Accel command called invert pins (might be spelled differently:doh:) and that should reverse the default direction. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
triise Posted October 12, 2015 Author Posted October 12, 2015 Hi Tore Try asking these questions on this forum https://groups.google.com/forum/m/?hl=en#!forum/accelstepper The fellow who wrote the Accel library resides there and will help you. The people there are very knowledgeable. You might also look into this Easy Driver board. The Chinese knockoffs are less than $1.50 a piece. Also, to reverse direction there is an Accel command called invert pins (might be spelled differently:doh:) and that should reverse the default direction. 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(); } } } Regards, Tore - Newbie simpit builder and electronics geek -
Warhog Posted October 13, 2015 Posted October 13, 2015 Tore, if I'm not mistaken should you not have the run command in the actual loop? Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
triise Posted October 15, 2015 Author Posted October 15, 2015 (edited) Tore, if I'm not mistaken should you not have the run command in the actual loop? 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? Edited October 15, 2015 by triise Regards, Tore - Newbie simpit builder and electronics geek -
Warhog Posted October 15, 2015 Posted October 15, 2015 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? Nope. I'm still working on my ADI. But from looking at your code I can see some possible issues. First it appears your mapping is backwards ie) should be (value, 0, 65,5353, 0, 630). 90Now please understand that my coding skills are almost zero but I do recall that in mapping 0 is set to 0 and then the large value from DCS is set to the max stepper value that you want to use ie) 630 or 510 or whatever amount of sweep is necessary. Second is your speed. I would set it to 1500 start there. You want very fast speed. And I see you set acceleration to 10,000. You don't really want acceleration as you not moving anything. The gauges that you mimic already have acceleration built into the sim so they don't look funny jumping from 0 to 500 or whatever. Its strictly to make them "APPEAR" as if they are acting as real gauges. All we want to do is copy that appearance so as long as we have our motor going to the same locations as the sims gauges, all will be good. So No Acceleration...Setting it to 10,000 pretty much eliminates the use of it. And using the fastest speed possible (without loosing steps:smilewink:) allows the motor to move at whatever is required to mimic the sims gauge movement. Why is you initial movement to 630. If wired correctly you need to go to -630 to find the hard stop. Next I think you should use stepper.moveTo instead of runToNewPosition. Keep the RunToNewPosition for the -630 so you get to the hard stop and then set 0 as you did. After that try MoveTo(value) as your command in the DCSBIOS function call. Lastly, you are missing a big hunk of the DCS-BIOS code at the end of the sketch. I would use what I have proposed but copy over the relevant parts to a new DCS-BIOS template sketch to make sure you have everything you need. Try this and see what you get. There may be some minor syntax errors that need fixing but thats the gist of it. #include <AccelStepper.h>// include AccelStepper library #include <DcsBios.h> #include <Servo.h> // DcsBios-related declarations DcsBios::ProtocolParser parser; AccelStepper stepper; // 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 onDcsBiosWrite(unsigned int address, unsigned int value) { if (address == 0x10b4) { targetpos = map(value, 0, 65535, 0, 590); stepper.moveTo(targetpos); } void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); } Failing that, post your code on the Accel forum and ask what you are doing wrong. They will be a better resource than me. BTW, this is what I use to test my motors for speed and so I can fine tune the settings. I have run 3 motors at different speeds and directions using this sketch but I also use an Easy Driver board for each motor to get micro stepping. You should be able to just change the stepper motor definition at the beginning and have it work for you. The sweep and speed I change depending on whether I use full step, half step, quarter stepper or one eighth step (micro step). #include <AccelStepper.h> AccelStepper stepper (1, 10, 11);//driver, step, direction //AccelStepper stepper1 (1, 10, 11);//driver, step, direction //AccelStepper stepper2 (1, 6, 7);//driver, step, direction void setup() { stepper.setMaxSpeed(1250); stepper.setAcceleration(500.0); stepper.runToNewPosition(-13200); stepper.setCurrentPosition(0); stepper.moveTo(13200); /* stepper1.setMaxSpeed(600); stepper1.setAcceleration(2000.0); stepper1.runToNewPosition(-630); stepper1.setCurrentPosition(0); stepper1.moveTo(120); stepper2.setMaxSpeed(600); stepper2.setAcceleration(2000.0); stepper2.runToNewPosition(-630); stepper2.setCurrentPosition(0); stepper2.moveTo(11120);*/ } void loop() { stepper.run(); // stepper1.run(); //stepper.run(); } Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
triise Posted October 15, 2015 Author Posted October 15, 2015 (edited) 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); } } Edited October 15, 2015 by triise Regards, Tore - Newbie simpit builder and electronics geek -
Warhog Posted October 15, 2015 Posted October 15, 2015 ...and here's why. I assume you haven't used the MS1 or MS2 pins on the Easy Driver...Correct? If thats the case then your running at micro stepping. That means 630 steps are now 8 x 630 = 5040 steps based on 1/8 step rate. Does that give you an idea of why its only moving a little bit? Pinouts on the motor...looking at the back with the flat part of the motor case facing up. top right pin is 1 btm right pin is 2 btm left is 3 top left is 4 1 and 2 (or 2 and 1)is Coil A 3 and 4 (or 4 and 3) is Coil B You can flip the numbers as I demonstrated in brackets and it won't make a difference but whats important is that you assign one side of the motor (a complete coil) to the A set of motor pins and the other side (again a complete coil) to the B set of motor pins. If you get a motor thats just vibrates with no movement, then your wiring is not as I just outlined. You should read everything there is on the Easy Driver web site. That will answer many questions. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
triise Posted October 16, 2015 Author Posted October 16, 2015 (edited) 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 Edited October 16, 2015 by triise Regards, Tore - Newbie simpit builder and electronics geek -
triise Posted October 16, 2015 Author Posted October 16, 2015 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(?) Regards, Tore - Newbie simpit builder and electronics geek -
Warhog Posted October 17, 2015 Posted October 17, 2015 There are a number of factors in play Tore. First the idea of running three or more steppers from an Arduino seems to be a problem. I was reading way back to 2013 in Gremlins thread and I copied it ...Set up a prototype circuit to drive the stepper motors via the i2c bus. Using one atmel mega8 to drive 3 steppers. (More is not possible cause of available number of atmel pins and latency getting to high). Works fine. Just have to add three more cards and the panel is ready for build-in Attached Thumbnails It was from Gremlins thread http://forums.eagle.ru/showthread.php?t=86916&page=12 There are several things you can try. Most are over my pay grade. First is to eliminate the use of digitalwrite. Except thats probably located inside the Accel library and way way above my pay grade. But it does make things respond faster. Next talk to the guys at the Accel forum and ask for help. See what they recommend for changes to your code. (I highly recommended this - ie) "possible solution") Lastly, change boards...maybe the Arduino Due as it runs at 84mhz compared to the Mega at 16mhz.:thumbup: After spending time on the Accel forum last month I was kind of anticipating this as being a problem. To that end, I purchased a ChipKit board 3 weeks ago but haven't had an opportunity to try it yet. (to many smaller projects on the go) It runs at 80Mhz and the guys at the Accel forum tested it with either 10 or 20 steppers with no issues. I also noticed that they don't have anything nice to say about Arduino when it comes to running multiple stepper motors. I guess rightly so after what I've been seeing lately. That doesn't mean its a lost cause. Over Pro did it. But he wrote his own code using the 6606 drivers and he also eliminated "digitalwrite" in his code and went straight to the port. I haven't had any luck with the 6606 driver so far. I tried last weekend...all Saturday... I just couldn't drive a stepper motor with it. :cry: Maybe the IC is bad.:huh: At this point I can't offer much help as I'm at the same level as you are with programming, well maybe not even as far as you. Now I know Gadroc is working with the same motors and driver boards as we are so maybe he can solve this problem but its beyond my abilities at present.:( Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
triise Posted April 24, 2016 Author Posted April 24, 2016 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: Regards, Tore - Newbie simpit builder and electronics geek -
triise Posted April 24, 2016 Author Posted April 24, 2016 (edited) 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 Edited April 27, 2016 by triise 1 Regards, Tore - Newbie simpit builder and electronics geek -
ClayM Posted April 24, 2016 Posted April 24, 2016 Thanks for sharing Tore! Excellent work. Thanks also for the Arduino code. I already see some things that will help me out a lot. Clay
Recommended Posts