Results 1 to 5 of 5
-
03-19-2011, 11:07 AM #1
DC Motors Card - How to use in SIOC?
Hi everyone,
I was just wondering if anyone could give me a quick tutorial on how to use the DC Motors card in SIOC.
I ask, because the manual provided with the card just gives you a script; it does not tell you what each declaration means and why it is there, etc.
Of course, I know the basics of SIOC. How to implement Offsets, variables, LEDs, switches... I have even, in the past, handled more complex items such as Servo Motors and the USBKeys card, etc.
So, I'd just appreciate a small test script, telling me exactly what each line does and why it's there. I have sucessfully managed to run the USBDCMotors_test.ssi file included with SIOC, but I do not understand how it works; hence my question.
By the way, the card is fully set up in SIOC.ini, it's all ready to use.
Kind regards,
Jacl
-
03-19-2011, 12:47 PM #2
- Join Date
- Jul 2013
- Posts
- 917
Re: DC Motors Card - How to use in SIOC?
Jack
Here you are courtesy of Hessel Oosten. It is not small but very well documented and explains the commands and principles of using DC motors and interface to FSUIPC
David
Code://////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // SIOC A/T file for B767 Level-D, // Lekseecon (www.lekseecon.nl), // FS2004 version. // // V. 1.0 // // Hessel Oosten (BoeingBrown), the Netherlands. // As always (!) thanks to Nico Kaan (Kiek) for his great help. // // 1 (= realistic !) DC_motor version. // // // // Introduction and comments. // // This comments do far extend the length of the whole file below... // The reason is, that i.m.o. so many files are too cryptic (for me) // to understand them... // Hope some people do like these extensive comments... // And remember, deleting this part only takes a few milliseconds ... // // // Starting with some constants: // lev1(or2)_max. The max thrust position of your lever. // lev1(or2)_idle. The idle possition of your lever. // // Remember that full thust in FS is 16384 and full reverse is -4096. // In total 20480 range. So 4094 is 20 %, the rest 80 %. // In general, keep these ratio in mind (look at the values). // // The A/T (when correcting the hardware lever) initially runs fast to the // target position (speed_fast). // When more nearby the tartget it enters the range_slow were the running // speed is reduced to speed_slow. // To reduce unnecessary motion due to pot spikes etc. in the dead_area the // lever does not react on sporadic impulses. // The values can be tuned to your liking. // // The scale of FS values (see above) is not equal to the values the pot // produces in the range of the lever. // A correction factor must calculate lever(so pot)values to FS values: // lev1(or 2)_FS_cf (lever1 to FS correction factor). // // // The scale of FS values (see above) is not equal to the values the motor // wants to see. 2 // The DC motor runs on a scale of 1 - 127 (more and more faster), // 128 is stop and 129 - 255 is again more and more faster BUT the turn // is now inverse. // A correction factor must calculate the FS value (16384) to the motor scale // (x (e.g. left) or (x + 128, right). // We use FS_mot1_cf: FS to motor1 correction factor. // // Then comes the Var pot1(or2)_value. This is in fact the Var belonging to your // physical potmeter, link USB_ANALOGIC. // Here the actual pot position is calculated by subtracting the actual position // pot1(or2)_value from the "zero position" : lev1(or2)_idle. // This outcome is multiplied with the correction factor. // We can't return decimal values to FS so the outcome is TRUNCated to integers // and then send it to FS (Lev1(or2)_to_FS). Remember to calibrate your physical // pot 0,128 and 255 values to what you find with a hardware lever attached // and probably make it a few points smaller on both sides. Eventually // calculate a new center position by dividing this found range by 2. // // When the A/T is functioning the potmeters will be used for measuring the // hardware lever position. This lever position is compared with the software // position in FS. // If there is a difference the hardware lever will be moved by the motor. // For disconnecting the pots as manual instruments and using them for A/T // feedback the Var: Lever1discon, Link FSUIPC_OUT, Offset $310A, Length 1 // is used (see FSUIPC for Programmers manual). // // When the ATSwitch is armed this lever1_(or2)_discon Var is set to 192, // when A/T is OFF to 0. Can't reproduce the origin of value 192 in the // "FSUIPC for Programmers" manual, but it works... // // When ATSwitch = 1 and Lever1(or2)discon = 192 the program starts the actions // for motor function. But before doing this Pause is checked. // You won't burn your motor while you are drinking coffee in the room // downstairs ... // // The Fs_to_Lev1 (FS value towards lever1) is read from FSUIPC. // The actual pot value is calculated by subtracting the actual value from // the idle value. // This value is multiplied by the motor correction factor from before and // divided by 100 (was multiplied by 100 before). // This value now, is our actual lever position in FS values. // // Also is calculated the target FS position as read in FS (L2). // Now the difference is calculated between these two. The value is TRUNCated // to have only integers. // Then the routine is called which will make from the difference (see before) a // value which the motor can understand (left or right and speed). // // This lev1_to_Mot routine looks is the difference is pos or negative and // stores that position in another local Variable (L1 = 0 or L1 = 128). 3 // Then the speed (L2) is is taken (speed_fast or speed_slow) and (0 or 128) is // added for the direction of the turn. // If the hardware lever is very nearby the target the hardware levers enters // the dead area and the speed (L2) is ordered zero. // At last the chosen speed and direction (all included in L2) is send to the // USB_DCMotor. // The pause function was already mentioned before. Var 0000 value 0 { &lev1_max = 220 &lev1_idle = 60 // &lev1_min = 20 // not used, educational &lev2_max = 220 &lev2_idle = 60 // &lev2_min = 20 // not used, educational &speed_fast = 100 &speed_slow = 40 &range_slow = 15 &dead_area = 10 call &lev1_FS_cf call &lev2_FS_cf call &FS_mot1_cf } Var 1001 name lev1_max Var 1002 name lev1_idle // Var XXXX name lev1_min // not used, educational Var 1003 name lev2_max Var 1004 name lev2_idle // Var XXXX name lev2_min // not used, educational Var 1005 name speed_fast Var 1006 name speed_slow Var 1007 name range_slow Var 1008 name dead_area Var 1009 name lev1_FS_cf { L0 = &lev1_max - &lev1_idle L1 = 16383 / L0 L1 = TRUNC L1 4 &lev1_FS_cf = L1 } Var 1010 name lev2_FS_cf { L0 = &lev2_max - &lev2_idle L1 = 16383 / L0 L1 = TRUNC L1 &lev2_FS_cf = L1 } Var 1011 name FS_mot1_cf { L0 = &lev1_max - &lev1_idle L1 = 12800 / L0 L1 = TRUNC L1 &FS_mot1_cf = L1 } Var 1012 name lev1_to_Fs link FSUIPC_OUT Offset $089A length 2 Var 1013 name lev2_to_Fs link FSUIPC_OUT Offset $0932 length 2 Var 1014 name pot1_value link USB_ANALOGIC Input 1 PosL 0 PosC 128 PosR 255 { L0 = &pot1_value - &lev1_idle L0 = L0 * &lev1_FS_cf L0 = TRUNC L0 &lev1_to_FS = L0 } Var 1015 name pot2_value link USB_ANALOGIC Input 2 PosL 0 PosC 128 PosR 255 { L0 = &pot2_value - &lev2_idle L0 = L0 * &lev2_FS_cf L0 = TRUNC L0 &lev2_to_FS = L0 } Var 1016 name Lever1discon Link FSUIPC_OUT Offset $310A Length 1 Var 292 name ATSwitch Link IOCARD_SW Input 9 Type I { IF &ATSwitch = 1 { &lever1discon = 192 } ELSE { &lever1discon = 0 } 5 } Var 1017 name FS_to_lev1 link FSUIPC_IN Offset $089A length 2 { IF &ATSwitch = 1 { IF &pause = 0 // GO, so no pause today { L0 = &pot1_value - &lev1_idle L1 = L0 * &FS_mot1_cf L1 = L1 / 100 L2 = &FS_to_lev1 / 128 L0 = L1 - L2 &levs1_diff = TRUNC L0 call &Lev1_to_Mot } } ELSE { &MOTOR = 0 } } Var 1018 name levs1_diff Var 1019 name Lev1_to_Mot link subrutine { L0 = &levs1_diff L1 = 0 IF L0 < 0 { L1 = 128 } L2 = &speed_fast + L1 L0 = ABS L0 IF L0 <= &range_slow { L2 = &speed_slow + L1 } IF L0 <= &dead_area { L2 = 0 } &MOTOR = L2 } Var 1020 name MOTOR link USB_DCMOTOR output 1 Var 1021 name pause link FSUIPC_IN Offset $0262 length 2 { 6 IF &pause = 1 { &MOTOR = 0 } } // end
-
03-20-2011, 07:28 AM #3
Re: DC Motors Card - How to use in SIOC?
Hi David,
Thanks for that.
One thing I do not understand is: Hessel Oosten says that the DC Motors card has a range of 1-127 (forward) and 129-255 (reverse)... But Manuel Velez's script that is incldued with each install of SIOC has the Motors listed as "300"... Please see below:
Code:// ***************************************************************************** // * Config_SIOC ver 3.7B1 - By Manolo V閘ez - www.opencockpits.com // ***************************************************************************** // * FileName : Motors_test.txt // * Date : 3/18/2011 Var 0000, name inicializa, Value 0 { &DIR = 1 &timer = TIMER 99 ,0 ,100 } Var 0001, name Motor_1, Link USB_DCMOTOR, Output 1 Var 0002, name Motor_2, Link USB_DCMOTOR, Output 2 Var 0003, name Motor_3, Link USB_DCMOTOR, Output 3 Var 0004, name Motor_4, Link USB_DCMOTOR, Output 4 Var 0005, name Motor_5, Link USB_DCMOTOR, Output 5 Var 0006, name Motor_6, Link USB_DCMOTOR, Output 6 Var 0010, name A1, Link USB_ANALOGIC, Input 1, PosL 0, PosC 127, PosR 255 Var 0011, name A2, Link USB_ANALOGIC, Input 2, PosL 0, PosC 127, PosR 255 Var 0012, name A3, Link USB_ANALOGIC, Input 3, PosL 0, PosC 127, PosR 255 Var 0013, name A4, Link USB_ANALOGIC, Input 4, PosL 0, PosC 127, PosR 255 Var 0014, name A5, Link USB_ANALOGIC, Input 5, PosL 0, PosC 127, PosR 255 Var 0015, name DIR Var 0099, name timer, Link SUBRUTINE { &DIR = &DIR * -1 IF &DIR < 0 { &Motor_1 = 95 &Motor_2 = 95 &Motor_3 = 95 &Motor_4 = 95 &Motor_5 = 95 &Motor_6 = 95 } ELSE { &Motor_1 = 300 &Motor_2 = 300 &Motor_3 = 300 &Motor_4 = 300 &Motor_5 = 300 &Motor_6 = 300 } }
Jack
-
03-20-2011, 09:26 AM #4
- Join Date
- Jul 2013
- Posts
- 917
Re: DC Motors Card - How to use in SIOC?
Jack
The USB DC Motors test file that I have from SIOC has the values of 126 and 254 respectively! It would appear that your file is incorrect, possibly modified?
Regards
David
-
04-20-2017, 09:11 PM #5
- Join Date
- Nov 2011
- Location
- London
- Posts
- 1
Re: DC Motors Card - How to use in SIOC?
Old thread I know, but does 0 have the same effect as 128 with a DC Motor Card?
Similar Threads
-
"Inner Circle" HSI - SIOC DC Motors Card Script
By Boeing 747 Flyer in forum OpenCockpits General DiscussionReplies: 64Last Post: 04-21-2011, 10:59 AM -
DC Motors card Potentiometer values?
By Boeing 747 Flyer in forum OpenCockpits General DiscussionReplies: 5Last Post: 04-03-2011, 01:47 PM -
Using Opencockpits DC Motors card for Motion
By Boeing 747 Flyer in forum OpenCockpits General DiscussionReplies: 12Last Post: 09-09-2010, 01:46 PM -
Oops, did I just fry my PhidgetsHC motors card?
By peterkwu in forum Phidgets & Cockpit Simulator BuilderReplies: 1Last Post: 01-30-2010, 11:39 AM -
USB DC Motors card
By flyboy01 in forum OpenCockpits General DiscussionReplies: 11Last Post: 12-19-2008, 08:01 AM
Looking for Fun? Connect with Women Seeking Casual Encounters in Your Town
JH startup on Client PC