Jump to content
Forum will be temporarily offline today from 5 pm PST (midnight UTC) ×

Recommended Posts

Ok back again. It occurred to me that since the sensors will need to adjust the course of the rocket more than once that my old code would be insufficient because it would only check for corrections at the moment of launch. Thus at the beginning of each code section I added 

while 1>0

Since this is always true it is an infinite loop. 

I tested this however but only the first sensor fired correctly. Furthermore it seemed like the rest of the program halted.

 

Here is the full code:

 

 

 

 

Flight Computer Mk3

-New Additions:

     More versatile calculator

     infinite corrections in theory

     Main Engine Firing

----------------------------------------------------------Copy-----------------------------------Below-------------------------------------------------This--------------------------------Line----------------------------------------------------------------

#---------------Import Section
import time
#---------------Class Section
class Calculator:
    def addition (x,y):
        add = x+y
        print(add)
    def subtraction (x,y):
        sub = x-y
        print(sub)
    def multiplication (x,y):
        mult = x*y
        print(mult)
    def division (x,y):
        div = x/y
        print(div)

#--------------Functions

def add1(x,y):
    Calculator.addition(x,y)

def sub1(x,y):
    Calculator.subtraction(x,y)

def mutl(x,y):
    Calculator.multiplication(x,y)

def div(x,y):
    Calculator.division(x,y)
    
def RME():
    Undefined Temperarily

 

#---------------Flight Code Section Secondary
while 1>0:
    a = 0
    def voltage1(b1):
        global c1
        c1 = b1 + 0
        if c1 > a:
            print("Activate Response") 
            print("The Value of Voltage +", c1)
            #Open RCS Valve Code
        elif c1==0:
            print("No Excessive Aerodynamic Forces sensor1")
            pass
    voltage1(0)
    
    #---Sensor 2
while 1>0:
    a = 0
    def voltage2(b2):
        global c2
        c2 = b2 + 0
        if c2 > a:
            print("Activate Response") 
            print("The Value of Voltage +", c2)
            #Open RCS Valve Code
        elif c2==0:
            print("No Excessive Aerodynamic Forces sensor2")
            pass
    voltage2(0)
    
    #---Sensor 3
while 1>0:
    a = 0
    def voltage3(b3):
        global c3
        c3 = b3 + 0
        if c3 > a:
            print("Activate Response") 
            print("The Value of Voltage +", c3)
            #Open RCS Valve Code
        elif c3==0:
            print("No Excessive Aerodynamic Forces sensor3")
            pass
    voltage3(0)
    
    #---Sensor 4
while 1>0:
    a = 0
    def voltage4(b4):
        global c4
        c4 = b4 + 0
        if c4 > a:
            print("Activate Response") 
            print("The Value of Voltage +", c4)
            #Open RCS Valve Code
        elif c4==0:
            print("No Excessive Aerodynamic Forces sensor4")
            pass
    voltage4(0)

#---------------Primary Code Section

TT = 1
time.sleep (TT)
print("Hello World")

Edited by Cheif Operations Director
Link to comment
Share on other sites

  On 6/3/2019 at 1:06 AM, Cheif Operations Director said:

I tested this however but only the first sensor fired correctly. Furthermore it seemed like the rest of the program halted.

Expand  

Yeah, you want just one loop at the bottom containing just the calls to the functions. The part where you define each function doesn't need to be in the loop.

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 6/3/2019 at 1:14 AM, HebaruSan said:

Yeah, you want just one loop at the bottom containing just the calls to the functions. The part where you define each function doesn't need to be in the loop.

  Reveal hidden contents

 

Expand  

Ok let me try it for my own knowledge why is this the way the logic works?

Link to comment
Share on other sites

while 1>0:
    voltage4
    voltage3
    voltage2
    voltage1

Didn't work

#---------------Import Section
import time
#---------------Class Section
class Calculator:
    def addition (x,y):
        add = x+y
        print(add)
    def subtraction (x,y):
        sub = x-y
        print(sub)
    def multiplication (x,y):
        mult = x*y
        print(mult)
    def division (x,y):
        div = x/y
        print(div)

#--------------Functions

def add1(x,y):
    Calculator.addition(x,y)

def sub1(x,y):
    Calculator.subtraction(x,y)

def mutl(x,y):
    Calculator.multiplication(x,y)

def div(x,y):
    Calculator.division(x,y)
    
def RME():
    hi

 

#---------------Flight Code Section Secondary

a = 0
def voltage1(b1):
    global c1
    c1 = b1 + 0
    while c1 > a:
        print("Activate Response") 
        print("The Value of Voltage +", c1)
        #Open RCS Valve Code
    while c1==0:
        print("No Excessive Aerodynamic Forces sensor1")
        pass
voltage1(0)

#---Sensor 2

a = 0
def voltage2(b2):
    global c2
    c2 = b2 + 0
    while c2 > a:
        print("Activate Response") 
        print("The Value of Voltage +", c2)
        #Open RCS Valve Code
    while c2==0:
        print("No Excessive Aerodynamic Forces sensor2")
        pass
voltage2(0)

#---Sensor 3

a = 0
def voltage3(b3):
    global c3
    c3 = b3 + 0
    while c3 > a:
        print("Activate Response") 
        print("The Value of Voltage +", c3)
        #Open RCS Valve Code
    while c3==0:
        print("No Excessive Aerodynamic Forces sensor3")
        pass
voltage3(0)

#---Sensor 4

a = 0
def voltage4(b4):
    global c4
    c4 = b4 + 0
    while c4 > a:
        print("Activate Response") 
        print("The Value of Voltage +", c4)
        #Open RCS Valve Code
    while c4==0:
        print("No Excessive Aerodynamic Forces sensor4")
        pass
voltage4(0)

while 1>0:
    voltage4
    voltage3
    voltage2
    voltage1

Link to comment
Share on other sites

I still got the message for sensor #1 only even though I put it last

  On 6/3/2019 at 1:22 AM, HebaruSan said:

Presumably it would complain about b1, b2, b3, and b4 not being defined for that.

Expand  

It did not work with the parent empty

I need to call the function without inputing a value. The whole point is that it will reassess if their is a change to the value

Link to comment
Share on other sites

  On 6/3/2019 at 1:22 AM, Cheif Operations Director said:

I still got the message for sensor #1 only even though I put it last

Expand  

Oh, I didn't notice that you changed this as well:

  On 6/3/2019 at 1:17 AM, Cheif Operations Director said:

    while c1 > a:
        print("Activate Response") 
        print("The Value of Voltage +", c1)
        #Open RCS Valve Code
    while c1==0:
        print("No Excessive Aerodynamic Forces sensor1")
        pass

Expand  

Each of those bold lines is also going to be an infinite loop, so it's getting stuck there. Try changing them back to 'if' statements.

Link to comment
Share on other sites

  On 6/3/2019 at 1:26 AM, HebaruSan said:

Oh, I didn't notice that you changed this as well:

Each of those bold lines is also going to be an infinite loop, so it's getting stuck there. Try changing them back to 'if' statements.

Expand  

Ok I fixed that. It still is demanding a value for b1 b2 b3 b4

I tried testing it will numbers and it works as intended but the numbers will be inputed from a sensor in flight thus I can not when this program is actually running type in the numbers

Link to comment
Share on other sites

  On 6/3/2019 at 1:29 AM, HebaruSan said:

Yeah, don't use b1, b2, b3, and b4. :) Give a number.

Expand  

Again I can not.

Remember this is an RCS System that is automated. If a sensor is trigger (meaning the rocket off course) it inputs a value greater than 1 into those b places. This means that I can not write an number into a code because that number is determined by things like the wind on the day of launch. 

I tested it with numbers and it worked as intended but as I stated above that is just to ensure success of the system the numbers need to come from a sensor.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...