PDA

View Full Version : SIOC Experts: What does this mean?



jmig
09-03-2008, 04:56 PM
I found and borrowed some code for using a pot to set rudder trim. The code listed below works. My question is what do the various math steps do. I would like to understand HOW it works, not just copy.

The code is:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 10"><meta name="Originator" content="Microsoft Word 10"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CJ%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman";} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1026"/> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1"/> </o:shapelayout></xml><![endif]-->Var 0085, Link FSUIPC_OUT, Offset $2EC0, Length 8, Numbers 2 // inicio scrip rudder trim

Var 0400, Link USB_ANALOGIC, Input 1, PosL 0, PosC 125, PosR 255
{
L0 = V0400 * 155
L0 = L0 - 19530
V0085 = L0 / 1000
L1 = L0 / 1000
<!--[if !supportLineBreakNewLine]-->
I understand the two Variable lines. I understand that L0 is a temp variable.

Why multiply V0400 by 155?

Why subtract 19530 from the result?

Then why divide by 1000?

Can someone help a programing noob understand?



<!--[endif]-->

pdpo
09-04-2008, 05:45 AM
Var 0085, Link FSUIPC_OUT, Offset $2EC0, Length 8, Numbers 2

Var 0400, Link USB_ANALOGIC, Input 1, PosL 0, PosC 125, PosR 255
{
L0 = V0400 * 155
L0 = L0 - 19530
V0085 = L0 / 1000
L1 = L0 / 1000
}

Hopw you understand it with the following explanation :
1) the middle point of the pot should result in 0 so 126 * 155 = 19530 => V0085 will be 0 if the V0400 = 126
(I would probably change this to 125*155=19375 => so V0085 would be 0 at V0400=125)

2) the pot can increase then its value to 255 => V0085 = 19.995
or it can decrease to 0 => V0085 = -19.530

turning of the rudder trim pot will result in a value from -19.530 to 19.995.
Now we have defined here the FSUIPC_OUT to have Numbers 2.
This will make the value be divided by 100 ... so actually the value in the offset will be
-0.19530 to 0.19995
if you convert this to degrees you se a rudder trim deflection between - 11.5 to 11.5 degrees.

in fact , you could rewrite this code and not divide L0 by 1000 to get V0085
but define the fsuipc_output with Numbers = 5

This is a quote form the help file in config_sioc.exe
"Numbers : If we work with 8 bytes FLOAT, this attribute sets the division factor. If we set 1 and FLOAT is 123, the variable will store 12.3."

Greetings Peter Depoortere

jmig
09-04-2008, 07:33 AM
Thank you Peter. This is JUST what I needed to see. It allows me to understand the inner workings of SIOC.

I have always been a person who wants to understand the "whys" and "wherefore" of things. In this way you can actually the system and figure out what is wrong when it doesn't work according to plan.

I didn't know sioc.exe had a help file. I will have to look it over.

Michael Carter
09-04-2008, 07:57 AM
I used to drive my math teachers absolutely crazy for that reason.

I never could get a straight answer out of them. I used to do the same to the Boeing instructors when I went through tech school at Chanute too.

Amazing how some can teach subjects but not explain the "why".

pdpo
09-04-2008, 08:07 AM
Jmig,

the help file is the one from CONFIG_SIOC.EXE , not the sioc.exe ...
Anyway, its only when you truly understand an example code that you can start
fiddling yourself. Once you get the basics , and you understand them well you can
try out some variations and new things with it....
Thats my main reason that I dont get started in programming windows (visual C++) ...
so many classes existing and not really seeing how they work and interact ...
Still trying...

Greetz Peter