Jump to content

zitronen

Members
  • Posts

    692
  • Joined

  • Last visited

Everything posted by zitronen

  1. @Jimbofarrar Good work! I never quite figured out what port number format the serial port dll wanted. Thanks for the research. I'm away at a conference this week, will update the plugin with your code when I come back next week.
  2. OK you do not want to put anything in "loop()", the loop needs to run very fast without being slowed down by slow LCD stuff. Put your LCD code in "input()" under the KSP receive data if statement like this: if (KSPBoardReceiveData()){ deadtimeOld = now; returnValue = id; switch(id) { case 0: //Handshake packet Handshake(); break; case 1: Indicators(); //LCD CODE HERE ************** lcd.setCursor(0,0); lcd.print((long)VData.AP); lcd.setCursor(0,1); lcd.print((long)VData.PE); break; } //We got some data, turn the green led on digitalWrite(GLED,HIGH); Connected = true; }
  3. Well done! When you guys get stuff working, it makes me happy. I would suggest adding time to AP, it's really useful to have to know if you are going to slow or to fast to orbit efficiently. More or less. The way it's written the command goes on when pin is connected to Vcc (3.3 or 5V) not ground, but it's the same principle. Also this is set up for a switch, not a button, unless the button is latching. In order to turn on RCS, a specific bit in the controls byte of the data packet needs to be set. The maincontrols() function just makes the code easier for people to read. Rather than having to remember which bit number is RCS, and doing the bit maths do set it, you just do maincontrols(RCS, HIGH).
  4. Haha nice. This is also why I'm not sharing the code I use for my personal display, it's a huge mess! No you put the folder in GameData, like all other mods, not in PluginData. You can also use CKAN to install it automatically, since it was updated recently. Also yes you can change the default port in the config file. If the plugin can't find the default port it will check other available ports on your PC.
  5. That means it's connected. If you plug in some LEDs as described in the first post, do they work? If your inputs don't work, it's because there are problems for things like switches and axis controls in Windows 10, which are related to serial port drivers. Some arduino boards work some don't, some people report cheap ones from China have better chance of working. You can try searching this thread for previous attempts. Uh.. floats have a variable number of decimal points, that's why they are called "floating" point. Mach number is a sent as a float. Arduinos only support 32bit floats, they have about 7 significant digits (M=1.235678, M=12.345678 M=123.45678, etc.), times are always in seconds, but some are signed (int) because they can be negative and some are unsigned (UInt). The only time related variable that is a float is "deltaTime" which is the time interval in seconds since last serial packet was sent from KSP, used for calculating derivatives.
  6. If you are new, I would suggest starting with something simple, follow the instructions on the first post. Start with a button and LED. If you are using code from someone else and you have a problem, I can't really help you. Also please post the debug log https://wiki.kerbalspaceprogram.com/wiki/Debug_Toolbar
  7. You can try the latest version plugin 0.19.1 and arduino demo 17 (I updated links in first post). They should be compatible with KSP 1.7-1.3. Please post the KSP debug log, and tell us which version of the plugin and arduino code you are using.
  8. There are 2 main loops, a input and output with separate tabs. Input() has a if statement that checks if a packet is received from KSP, so put you LEDs, displays stuff in here so they only executes when you receive something new. Output() function has a if statement that checks against a timer, put your switches, axis and other controls in the controls() function this is triggered every 25ms. Avoid running stuff constantly in the background so the code has enough time to process the serial data when not doing your stuff. Remember the arduino is single threaded, it can only do one thing at a time.
  9. I think it's a bit too early to say what we can do at this stage, but this is definitely something that interest me. I still remember when I first landed on the Mun , this was like KSP 0.07, without landing legs, manoeuvre nodes or even quick save! I paid $10 for KSP, got all expansions for free. Pretty good deal! I do wish Squad and the original crew was making KSP 2, but definitely exciting times.
  10. I wouldn't worry about if statements. If statements themselves take almost no time (maybe 1 or 2 CPU cycles at 62.5ns per cycle), the digitalRead/digitalWrite functions are the slow bit, they take a few micro seconds. By default the IO pins are only checked every 25ms, when a control packet is sent to KSP, not all the time. 25ms is enough to check many 1000s of IOs with if statements. Of course you can use interrupts, but it won't make much difference in speed. Printing to LCDs, floating point math, sending and receiving serial data take far more time.
  11. No reason, just lazy and forgot! I think it's working fine with the latest KSP, I use it myself. Hmm.. The joystick code has not been updated since KSP added SAS modes, might look into changing it in the future, it is kind of outdated. I suggest for now you can use a arduino leo or similar in USB joystick mode (google arduino usb joystick if you've not done it before), and just map your axis in KSP like a normal joystick. Frankly you will have a better experience since USB HID joysticks can have much faster refresh rates than my plugin, and you won't have any SAS problems.
  12. Hmm this is weird. Why would you want to know this value? If you just want to know how deep you are in the atmosphere why not just use altitude and remember atmo start height for each planet? That formula is also odd since IRL density ratio is exponential, not 4th root. Density by itself is useful, if density halves your drag and lift halves at the same true air speed, which is why I included it.
  13. Is it not just air density? Where sea level is 100% (1.225kg/m^3) and space is 0%?
  14. Hi I'm not so sure taking out the if statement is a good idea, will reply to you on github.
  15. I just checked, with KSP IO version 0.19.1, arduino Demo 17, everything is working in KSP 1.7.1 with all the expansions (making history, breaking ground). Are you sure you have the right version of the plugin? Can you post the debug log?
  16. Don't know which arduino board you are using, but if your code is getting complex you can try reducing the update rate in the .cfg file or increase the arduino serial buffer in HardwareSerial.h with the downside of losing some RAM.
  17. Thanks, will look into it later the week. Does version 19.1 and Demo 17 work (page 83)?
  18. The argument out of range thing is not related to our plugin, maybe some other KSP bug. I also did aerospace for uni!
  19. Yeah this should work. Just divide the raw prograde pitch/heading value by 50.0 to get heading in degrees. If what freshmeat said doesn't work, can you post the debug log? It can be either the plugin not detecting your arduino or something wrong in the arduino code.
  20. Hi guys, I've just started to play some KSP again, realised I forgot to actually put the new version out. Update 0.19.1: Changes: Added pro-grade, maneuver, and target pitch and heading angles, as well as normal vector, thanks to @c4ooo Recompiled against KSP version 1.6.1, seems to work OK Plugin download link: https://sites.google.com/site/zitronfiles/KSPSerialIO_019_1.zip Arduino code dowload: https://sites.google.com/site/zitronfiles/KSPIODemo17.zip If you were using a previous version (demo 16), just add the following to your arduino code data structure: int16_t ProgradePitch; //56 Pitch Of the Prograde Vector; int_16 ranging from (-0x8000(-360 degrees) to 0x7FFF(359.99ish degrees)); int16_t ProgradeHeading; //57 Heading Of the Prograde Vector; see above for range (Prograde vector depends on navball mode, eg Surface/Orbit/Target) int16_t ManeuverPitch; //58 Pitch Of the Maneuver Vector; see above for range; (0 if no Maneuver node) int16_t ManeuverHeading; //59 Heading Of the Maneuver Vector; see above for range; (0 if no Maneuver node) int16_t TargetPitch; //60 Pitch Of the Target Vector; see above for range; (0 if no Target) int16_t TargetHeading; //61 Heading Of the Target Vector; see above for range; (0 if no Target) int16_t NormalHeading; //62 Heading Of the Prograde Vector; see above for range; (Pitch of the Heading Vector is always 0)
  21. It's because Unity does not have System.IO.Ports like MS .net. It can't access serial ports. If it did it would have made everyone's life so much easier.
  22. Not really sure how to do the fuel thing. If you want to add something that checks for planets, please do!
×
×
  • Create New...