Stationeers

Stationeers

View Stats:
TargetLost May 11, 2020 @ 2:15am
No Sin in IC MIPS?
Is this correct? There is no Sin, Cos, Acos.. or any trigonometrie functionality in the IC MIPS language?

How do you do a Sin calculation? I know you can approximate Sin but I don't know how fast is the MIPS process each line? Would this make sense?

I ask because after a break I would like to start another game on that litle moon/planet where you have hardly any sun energy. I figured a solar controller is essential for surviving there.

So instead building it with discrete logic... I thought maybe it's time to use an IC for once and spare some components....but without a Sin function that's not a good alterantive. Is it? How do you do it?

Formulas:

With Eclipse (Mars):
Solar Panel Horizontal = Acos( Cos(Beta) / Sin(Alfa) )
Solar Panel Vertical = ( 50 / 75 ) * ( 75 - Alfa )

Without Eclipse (Moon):
Solar Panel Vertical = ( 50 / 75 ) * ( Beta - 15 )

Whereas Alfa is the Top Daylight Sensor and Beta the East Daylight Sensor

https://steamcommunity.com/app/544550/discussions/0/1732089092442876694/
Originally posted by Rocket:
I have added Trigonometric functions to the IC system, available in build rv10892.

I am looking at the suggested reset, and maybe even the suggested network system.
< >
Showing 1-15 of 31 comments
Dani May 11, 2020 @ 3:16am 
I use vert/hor modes of the sensor.
The advantage with using an IC is that you can use one sensor and switch modes.
You get a horizontal angle and only need to add 90,180 or 270 correction depending on how you placed the panels.
The vertical is in degrees and has to be converted to % for the panels.
TargetLost May 11, 2020 @ 10:27am 
That's an idea. Always forget about this sensor modes. I disliked a lot solutions because they wanted the user to first switch the sensor mode but with the Ic you can do that with the program.

I would really like to know the speed: How many lines per second does MIPS processed?

Depending on this I can see if it will make sense to code a Sin approximation or if this solution would be too slow.

I hope that I can import a mips program on a text file /IC simluator into the game and don't have to code it all in the game..uh..
Maireen May 11, 2020 @ 12:47pm 
Originally posted by TargetLost:
I would really like to know the speed: How many lines per second does MIPS processed?
all 125 lines in one tick (half sec)
Scratch May 11, 2020 @ 12:55pm 
I have been using the code from:

Perfect Solar Tracking
Bushwackah's Solar Tracking V 1.0
Please view setup video on his site. Very power efficient as well.

His code is solid and I have had no issues since day one. His video was excellent. Got that going months ago.
TargetLost May 12, 2020 @ 3:57am 
Thank you Maireen.

Sounds good so I guess I will simple code the sin function myself.

I like to develope things by myself. More fun and you always learn something by doing the hard stuff yourself. The formulas I provided above is a perfect tracking solution.
TargetLost May 13, 2020 @ 2:32am 
Using this simulator:
https://stationeering.com/tools/ic

I prepared this code below. Didn't test it in game yet.

Next to Sin,Cos etc PI is missing.

Codeing is nice and straight forward and that simulator useable. That's cool! Thanks Devs!

The 128 line limit is bothering me thought.
The Acos approximation converges very very slow so this only leaves space for an inaccurate Acos approx. I could code a loop but then I guess there is a speed reason for the 128 line limit and a loop executing more lines in a tick maybe causes a timing problem!?
I guess my solution is good enough I will see.

Do I have to connect a batch writer on d3 and d4 and sensor reader on d0 and d1 or can I connect those devices and actors directly to the IC?


(Formula With Eclipse (Mars)):
start: alias TopSensorAngle d0 alias EastSensorAngle d1 alias SolarPanelVerticalAngle d3 alias SolarPanelHorizontalAngle d4 alias FIOReg r15 alias FReg1 r14 alias FReg2 r13 alias FReg3 r12 alias FReg4 r11 l r0 TopSensorAngle SolarAngle l r1 EastSensorAngle SolarAngle move r2 r0 move FIOReg r0 jal Sin move r0 FIOReg move FIOReg r1 jal Cos div FIOReg FIOReg r0 jal ACos s SolarPanelHorizontalAngle Horizontal FIOReg sub r2 75 r2 mul r2 r2 50 div r2 r2 75 s SolarPanelVerticalAngle Vertical r2 yield j start Sin: #x = (PI/180) * Input #FReg1 = x #Freg2 = x^2 mul FReg1 FIOReg 3.14159265359 div FReg1 FReg1 180 mul FReg2 FReg1 FReg1 #Output = x move FIOReg FReg1 #Output = x - x^3/3! mul FReg3 FReg1 FReg2 div FReg4 FReg3 6 sub FIOReg FIOReg FReg4 #Output = x - x^3/3! + x^5/5! mul FReg3 FReg3 FReg2 div FReg4 FReg3 120 add FIOReg FIOReg FReg4 #Output = x - x^3/3! + x^5/5! - x^7/7! mul FReg3 FReg3 FReg2 div FReg4 FReg3 5040 sub FIOReg FIOReg FReg4 #Output = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! mul FReg3 FReg3 FReg2 div FReg4 FReg3 362880 add FIOReg FIOReg FReg4 j ra Cos: #x = (PI/180) * Input #FReg1 = x #Freg2 = x^2 mul FReg1 FIOReg 3.14159265359 div FReg1 FReg1 180 mul FReg2 FReg1 FReg1 #Output = 1 move FIOReg 1 #Output = 1 - x^2/2! move FReg3 FReg2 div FReg4 FReg3 2 sub FIOReg FIOReg FReg4 #Output = x - x^2/2! + x^4/4! mul FReg3 FReg3 FReg2 div FReg4 FReg3 24 add FIOReg FIOReg FReg4 #Output = x - x^2/2! + x^4/4! - x^6/6! mul FReg3 FReg3 FReg2 div FReg4 FReg3 720 sub FIOReg FIOReg FReg4 #Output = x - x^2/2! + x^4/4! - x^6/6! + x^8/8! mul FReg3 FReg3 FReg2 div FReg4 FReg3 40320 add FIOReg FIOReg FReg4 j ra ASin: #x = Input #FReg1 = x #Freg2 = x^2 move FReg1 FIOReg mul FReg2 FReg1 FReg1 #Output = x + (1/2)* x^3/3 mul FReg3 FReg1 FReg2 div FReg4 FReg3 6 add FIOReg FIOReg FReg4 #+ ((1*3)/(2*4))*x^5/5 mul FReg3 FReg3 FReg2 mul FReg4 FReg3 3 div FReg4 FReg4 40 add FIOReg FIOReg FReg4 # + ((1*3*5)/(2*4*6))*x^7/7 mul FReg3 FReg3 FReg2 mul FReg4 FReg3 15 div FReg4 FReg4 336 add FIOReg FIOReg FReg4 # + ((1*3*5*7)/(2*4*6*8))*x^9/9 mul FReg3 FReg3 FReg2 mul FReg4 FReg3 105 div FReg4 FReg4 3456 add FIOReg FIOReg FReg4 # + ((1*3*5*7*9)/(2*4*6*8*10))*x^9/11 mul FReg3 FReg3 FReg2 mul FReg4 FReg3 945 div FReg4 FReg4 42240 add FIOReg FIOReg FReg4 # + ((1*3*5*7*9*11)/(2*4*6*8*10*12))*x^9/13 mul FReg3 FReg3 FReg2 mul FReg4 FReg3 10395 div FReg4 FReg4 599040 add FIOReg FIOReg FReg4 # Output = (180/PI) * Asin(Input) mul FIOReg FIOReg 180 div FIOReg FIOReg 3.14159265359 j ra ACos: #Acos = 90-Asin(x) push ra jal ASin pop ra sub FIOReg 90 FIOReg j ra
Last edited by TargetLost; May 13, 2020 @ 2:34am
Puma May 13, 2020 @ 4:46am 
@TargetLost
No. There are no trigonometric functions on the IC10. I personally think there should be a more advanced IC11 that incorporates those because solving spherical triangles gets really computationally heavy using sine approximation. But single sensor solar tracking on Mimas is "fine" using very crude sine approximation. (Depending on your criteria of what is considered "fine".)

If you are using two sensors you can always use clever sensor placement to get perfect (99+% efficiency) solar tracking with no trigonometric calculations needed, since you already get the needed angles from the sensor. And I have no idea what is going on with your formulas, since "top daylight sensor" and "east daylight sensor" both mean next to nothing without the mode and orientation information. But even without understanding what is going on there, I can tell with absolute certainty that your formula is needlessly complicated if you are already using two sensors.

Where you start needing trigonometry is in a setup where you have one or zero sensors. And as Dani pointed out, you can use clever sensor placement and clever mode switching to get one sensor to act sort of as two sensors. You get 98+% efficiency using single sensor with mode switching, with no trigonometric calculations needed.

And I absolutely agree with you on figuring out things by yourself. As things are right now, there is no sustainable game loop, and learning to play the game is the game. And if you are skipping the part where you develop solutions to run your base, and just copy ready made solutions made by others, you end up skipping most of the game.

PS. It's 128 lines per tick, not 125. Or 512 lines per second.
PPS. I don't think "eclipse" means what you think it means.
TargetLost May 13, 2020 @ 6:52am 
Originally posted by Puma:
@TargetLost

If you are using two sensors you can always use clever sensor placement to get perfect (99+% efficiency) solar tracking with no trigonometric calculations needed, since you already get the needed angles from the sensor. And I have no idea what is going on with your formulas, since "top daylight sensor" and "east daylight sensor" both mean next to nothing without the mode and orientation information. But even without understanding what is going on there, I can tell with absolute certainty that your formula is needlessly complicated if you are already using two sensors.

Well the Sensor placement is in my earlier thread from a long time ago:

https://steamcommunity.com/sharedfiles/filedetails/?id=1529971024

https://steamcommunity.com/app/544550/discussions/0/1732089092442876694/

In short I made absolutly NO requirements to the sensors other than placeing them flat on a surface with the normal pointing skyward (Top Sensor) or Eastward (East Sensor).

Also I do not make use of Sensor Modes and let them in their default mode. I saw descriptions where you first have to switch the sensor mode manual and such...urgh
And placeing Sensor upside down and such fun that I have seen..that is really not my taste.

So what you have for free with the Sensor mode is what I calculate and this is where you need the trigonometry. It's not complicated. Normal math operations and if the IC10 provided that it had been an easy pace. The Formula is really compact. Developing the formula however of course required a bit more knowledge. Like I say I love the harder stuff.

Eclipse is the wrong word. Don't know the right one but I think it is clear enough what is meant.

The 128 line is where the simulator complained about the program beeing too long. Seems there is a limit. Can be it's 125 I don't know but the program length is very limited according to the simulator.
Last edited by TargetLost; May 13, 2020 @ 7:03am
Puma May 13, 2020 @ 9:07am 
I saw descriptions where you first have to switch the sensor mode manual and such...urgh
Oh. I see. So you went through all that to avoid writing this
s HorizontalSensor Mode 1
Makes perfect sense. But there is nothing wrong in creating an artificial challenge for yourself. And if you still want to stick with trigonometry. Because the solar angle is constant, it is possible to calculate both horizontal and vertical angles from a single sensor output in the default mode.
TargetLost May 13, 2020 @ 9:41am 
In default sensor mode from one or 2 years ago this isn't possible at least not without some hackings because the sun position is not defined to one point and one point only. (you would have to use time or something to decide which point)

Yes certainly with the IC you can switch the mode easy today. But I do not like to use that artificial sensor mode at all. Even the default mode provides more than a normal RL sensor does.
I wonder why instead that mode the devs didn't right away provide an all in one complete solarpanel controller.

Anyway as explained I like doing the hard stuff. A matter of taste.
Last edited by TargetLost; May 13, 2020 @ 9:48am
Puma May 13, 2020 @ 12:33pm 
Yes. Because the sun and the rest of the skybox is rotating at a fixed angle and fixed rate, you only need to know what time of day it is to calculate where the sun is. And you can get the time of day with just one sensor in any mode. No hackings needed.

It's a video game, all modes and everything is artificial. But you are allowed create extra artificial challenge to yourself as you please. You can do a "knives only" playthrough if you choose to. But doing the hard stuff and doing stuff the hard way are two different things.

If you like the hard stuff, might I suggest automatic satellite finding. It took me a couple of days to figure that out. And there is no need to make it any more difficult than it already is.
TargetLost May 13, 2020 @ 1:02pm 
You might be surprised I actually learned to calculate the sun position on earth given time, longitude and latitude. But that is many years in my past.
I am not interested in satellite findings.
Don't see what is hard about a simple formula with a sin and a cos. It's more work yes but it is really very simple and at the end it is basicly the same an IC + 2 sensor. The other solution is an IC + 1 Sensor. So what is the difference here? I know exactly what I calculate. People just using the easy sensor mode don't learn so much. Don't have to if they don't want. At the end it's each there own. Again it's a matter of taste and skills one has.
Scratch May 13, 2020 @ 1:19pm 
I agree totally that you must learn the programming and understand it. This game is very overwhelming at the beginning and making use of others knowledge is a great advantage to get yourself settled in the game. I used Bushwackah's Solar Tracking because it gave me a solution then and I did need the extra power from the 25 panels just standing there in there preset position.

I started programming MIPS a couple of weeks ago and its not bad. Its great to see others program and study there ways. Later when you program your own you make it even better. Very different from VB and C. I started converting all my Logics to IC10. Definitely need it with AIMEe and the Wireless transmitters.

If you in it to 100% do your own thing thats also fine. We all learn our own way. As long as you don't frustrate yourself so much that you get discouraged.

PS ! The 128 Lines are really very limiting. Put your notes next to your code and as little above as possible.

Enjoy
Rocket  [developer] May 15, 2020 @ 7:19am 
What are the overall peoples thoughts on adding math functions to the IC? I could go through and add some of these. I realize they take away from the spirit of it, but they would free up line numbers for other work rather than basic math stuff.
TargetLost May 15, 2020 @ 10:31am 
For me personel I don't see why you offer squareroot and logarithm but no trigo functionality.
Simplest is to have everything you have as discrete IC function available in IC10 too.

If the idea is to be as close to an Assembler Language/Microprocessor...you know that most systems will offer a function library. Maybe that could be a way to go..calling hidden system function library..thought the user than has to take care about pushing and poping the register makes it maybe too complicated.

What I really wonder.. why is there a 128 line limit? Likely people would like to have that limit increased to make more with just one IC.

Byway I couldn't test my program in game yet..I figured I need all sorts of advanced ingots....so for a first survival solution I am better off with discrete logic.

Just exploring the miner module. It says small miner. Wonder if it maybe will be possible to build custom made miners in the future!?. I build crazzy digging machines with the
redpower 2 mod in minecraft in the past.
Last edited by TargetLost; May 15, 2020 @ 10:52am
< >
Showing 1-15 of 31 comments
Per page: 1530 50

Date Posted: May 11, 2020 @ 2:15am
Posts: 31