Jump to content

Recommended Posts

10 minutes ago, Cheif Operations Director said:

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.

But... you don't have sensors yet. The best you can do is simulate them with some sample inputs.

Link to comment
Share on other sites

1 minute ago, HebaruSan said:

But... you don't have sensors yet. The best you can do is simulate them with some sample inputs.

Sure but when I do the code needs to be able to replace the values with a number. When this happens should I replace all those temporary numbers with the b values and let the sensor define them?

Their has to be a better way to tell the code the scan multiple time a second

#---------------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
    if c1 > a:
        print("Activate Response 1") 
        print("The Value of Voltage +", c1)
        #Open RCS Valve Code
    elif c1==0:
        print("No Excessive Aerodynamic Forces sensor1")
        pass
voltage1(0)
#---Sensor 2

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

#---Sensor 3

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

#---Sensor 4

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

while 1>0:
    voltage4(0)
    voltage3(0)
    voltage2(0)
    voltage1(0)

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

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

 

Everything I put in bold is redundant

Furthur more it updates hundreds of times a second which puts unnessicary stain on a system

Link to comment
Share on other sites

T1 = 0.25
while 1>0:
    time.sleep (T1)
    voltage4(1)
    voltage3(0)
    voltage2(0)
    voltage1(0)

This seems to resolve the issue but im not sure if it takes up more or less ram is their a way to check and sorry for the rant that would rival a presidential candidate during a debate.

Link to comment
Share on other sites

44 minutes ago, Cheif Operations Director said:

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.

What you're going to have to do there is, every time your program loops, read values off the sensors, and then determine whether or not you have to take some cation based on the values read from the sensors. Gyroscopes (or magnetometers, if you want to orient yourself off of Earth's magnetic field) aren't digital, on/off sensors. They're analog, and output readings continuously. They aren't "triggered", in the way something like a limit switch is triggered.

Edited by IncongruousGoat
Clearly I don't know the worth of my own writing
Link to comment
Share on other sites

def repeatingchecks():
    time.sleep(T1)
    while 1>0:
        time.sleep (T1)
        voltage4(1)
        voltage3(0)
        voltage2(0)
        voltage1(0)

 

When I call "repeatingchecks()" it still gets me stuck in a loop

7 minutes ago, IncongruousGoat said:

Do you want me to restore it? I can try to restore the original text, if you really think it's that valuable.

If you said something feel free to post it

Link to comment
Share on other sites

18 minutes ago, IncongruousGoat said:

What you're going to have to do there is, every time your program loops, read values off the sensors, and then determine whether or not you have to take some cation based on the values read from the sensors. Gyroscopes (or magnetometers, if you want to orient yourself off of Earth's magnetic field) aren't digital, on/off sensors. They're analog, and output readings continuously. They aren't "triggered", in the way something like a limit switch is triggered.

You could get a digital one right? Also these sensors are simply to test if wind is hitting the rocket.

Link to comment
Share on other sites

3 minutes ago, Cheif Operations Director said:

You could get a digital one right? Also these sensors are simply to test if wind is hitting the rocket.

If wind is hitting the rocket? What kind of sensor, specifically, were you planning to use for this?

As for a digital gyroscope, any gyroscope you buy is going to contain some digital hardware, but you're going to be hard-pressed to find one that produces a digital reading.

Link to comment
Share on other sites

Just now, IncongruousGoat said:

If wind is hitting the rocket? What kind of sensor, specifically, were you planning to use for this?

As for a digital gyroscope, any gyroscope you buy is going to contain some digital hardware, but you're going to be hard-pressed to find one that produces a digital reading.

Push sensor

Link to comment
Share on other sites

25 minutes ago, Cheif Operations Director said:

def repeatingchecks():
    time.sleep(T1)
    while 1>0:
        time.sleep (T1)
        voltage4(1)
        voltage3(0)
        voltage2(0)
        voltage1(0)

 

When I call "repeatingchecks()" it still gets me stuck in a loop

But you told it to!

Anyway, since IG says your sensors will probably be query-based rather than event-based, it might be worth making a simple test harness modeled on that. You can write a function that accepts a series of values to pass to each function and executes it, as if they were real sensor values coming in off the wire, and you can see the output that would be generated. Then various scenarios can be encoded in lists and passed in:

def doTest(test):
    for readings in test:
        voltage1(readings[0])
        voltage2(readings[1])
        voltage3(readings[2])
        voltage4(readings[3])

test1 = [
    [ 0, 0, 0, 0 ],
    [ 0, 1, 0, 0 ],
    [ 0, 0, 1, 0 ],
    [ 0, 0, 0, 1 ],
    [ 1, 0, 0, 0 ]
]

doTest(test1)

This also has the advantage of being a finite loop rather than an infinite one.

Link to comment
Share on other sites

2 minutes ago, HebaruSan said:
33 minutes ago, Cheif Operations Director said:

def repeatingchecks():
    time.sleep(T1)
    while 1>0:
        time.sleep (T1)
        voltage4(1)
        voltage3(0)
        voltage2(0)
        voltage1(0)

 

When I call "repeatingchecks()" it still gets me stuck in a loop

 But you told it to!

Yes I did but the whole point of putting it into a callable function was to make it run infinitely in the background. This program need to be able to run that loop and check to ensure the system is working ASWELL as run the rest of the code.

Link to comment
Share on other sites

8 hours ago, Kerbart said:

The code contains some inefficiencies. You might want to put more work in  studying the language. You’ll end up writing less code, and less code means less mistakes.

I would echo this. I think you need to spend a bit more time getting a solid grounding in the language before you try to jump in and code a rocket control system.

Link to comment
Share on other sites

10 hours ago, Cheif Operations Director said:

Push sensor

You mean, something like a touch sensor? I don't think those work for wind, especially for picking up lateral wind in an environment where there's already going to be a lot of vertical wind.

Edited by IncongruousGoat
Link to comment
Share on other sites

11 hours ago, Cheif Operations Director said:

 run infinitely in the background

You have to understand that unless you are working on a multi threaded CPU your code can do only one single thing at the time.  It can do a task quickly and get to the next task in a blink of an eye that we puny humans might interpret as two events happening at the same time, but for the computer it is doing one thing, and only when that is done go on to the next task.

When you use "while 1>0" you tell the program to do whatever is in that block for as long as 1 is greater than 0, which is forever. You never allow the code to do something else. A proper way to do it would be something like this pseudocode:

note that "while 1 > 0" is replaced with something that will eventually return false and allow the code to progress further, but during flight it will check and do multiple things in sequence.

CountDown
Launch
CheckAccelerationSensor
if Acceleration > 0
	RocketInFlight = true
while RockeInFlight == true
	CheckAttitudeSensor1
	CheckAttitudeSensor1
	CheckAttitudeSensor1
	CheckAccelerationSensor
	CheckMotorThrust
	CalculateAttitude
	CalculateCorrection
	MoveControlSurface1
	MoveControlSurface2
	if Acceleration == 0
		EjectParachute
	CheckForSplashown	
	if SlashDown == true
		RocketInFlight == false
BeepHappyilyBecauseFlightIsOver
	

 

Link to comment
Share on other sites

5 hours ago, IncongruousGoat said:

You mean, something like a touch sensor? I don't think those work for wind, especially for picking up lateral wind in an environment where there's already going to be a lot of vertical wind.

If you offset the sensors inside the rocket or put a "cup" or cone spthing around it will deflect the air

I think I have a soltuion

I tried using time.clock and it worked using python 2 I'm going to need to convert it to python 3

Link to comment
Share on other sites

My advice is to stop worrying about the stuff you're worrying about now. Timing and sequencing will depend entirely on the library (or language) that you end up using to interface with the devices, so there's no point in trying to make that part realistic now. Focus on the logic of the controller, making it react appropriately to the sensor input values you expect to have in a variety of circumstances (initial launch, sudden gust of wind, max Q, whatever). Right now you just have it printing "Activate Response" if a parameter is positive, which probably isn't a simulation of anything useful.

Link to comment
Share on other sites

Just now, HebaruSan said:

My advice is to stop worrying about the stuff you're worrying about now. Timing and sequencing will depend entirely on the library (or language) that you end up using to interface with the devices, so there's no point in trying to make that part realistic now. Focus on the logic of the controller, making it react appropriately to the sensor input values you expect to have in a variety of circumstances (initial launch, sudden gust of wind, max Q, whatever). Right now you just have it printing "Activate Response" if a parameter is positive, which probably isn't a simulation of anything useful.

It will turn a motor which will open a valve that releases pressurized gas from a tank to counter the wind. This is pretty much KSPs SAS + RCS dumbed down

2 minutes ago, HebaruSan said:

My advice is to stop worrying about the stuff you're worrying about now. Timing and sequencing will depend entirely on the library (or language) that you end up using to interface with the devices, so there's no point in trying to make that part realistic now. Focus on the logic of the controller, making it react appropriately to the sensor input values you expect to have in a variety of circumstances (initial launch, sudden gust of wind, max Q, whatever). Right now you just have it printing "Activate Response" if a parameter is positive, which probably isn't a simulation of anything useful.

 

Not sure how to code that

I need more experience on the software end of things first.

Link to comment
Share on other sites

52 minutes ago, Cheif Operations Director said:

It will turn a motor which will open a valve that releases pressurized gas from a tank to counter the wind.

But if you really think something that simple could work, then you don't need a computer. You could just connect the wire from the sensor directly to the motor. The point of writing software is to do something complicated.

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...