Jump to content

Wakestrap

Members
  • Posts

    7
  • Joined

  • Last visited

Reputation

4 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hey, A few friends and I recently decided to design and build our own KSP Controllers. We were planning to build it based on @zitronen SerialIO plugin and while checking out the SerialIO post, I discovered @DrMarcel had written EthernetIO and his own companion App. EthernetIO offered a communication interface that would allow for as much separation between the PC running KSP and the controller as I wanted. The ability to set it up in my living room to play with my daughter while my PC is downstairs in my office (streaming to the living-room TV) was really appealing. I'm a hardware engineer with a fairly limited software background but I know just enough to be dangerous. I quickly settled on using a Nucleo STM32F746ZG development board for the embedded controller for two reasons. 1) I had one laying around and 2) they are cheap, easy to get and have a ton of IO. The mbed online IDE also allowed for really easy development. If you can use an Arduino, you can handle mbed. The current version of the firmware (v0.01) is very basic. Once powered on and connected to the network it will automatically start looking for the UDP messages being sent out by DrMarcel's EthernetIO plugin. Once found, it will connect to the KSP EthernetIO TCP server and begin exchanging messages. As I haven't started the physical controller build yet, the code just looks for the USER BUTTON on the Nucleo board. If you hold the button while in flight, SAS will turn off and RCS will turn on. Opening a console window (Serial Port available via the boards USB programming port, 9600 8N1) will show basic connection status followed by Apoapsis, Altitude, and Liquid Fuel remaining once in flight. It's just to show that the hardware is working. Once i get the controller designed and built and write some hardware interface libraries, I'll publish it all here. If you're familiar with the SerialIO Arduino code, then this will look very familiar, it's basically a straight port with some changes made for connection handling. There is still some of the original Arduino code commented out in places. Requirements: You need EthernetIO Plugin installed see here: You'll need a Nucleo STM32F746ZG dev board (~$35CDN\$25USD) https://www.digikey.com/product-detail/en/stmicroelectronics/NUCLEO-F746ZG/497-16282-ND/5806779 Also available from a ton of online electronics distributors Binary file can be downloaded from here: https://drive.google.com/file/d/12JZAYZDFbZub-VGDeYezi0fjspw-ufea/view Project source code can be found here: https://os.mbed.com/users/wakestrap/code/KSPmbedIO/ To program the board, you can drag and drop the BIN file to the drive labelled NODE_F746ZG that is created when you connect the dev board to your computer. The attached programmer will then program the primary MCU with the BIN file. For more advanced users, I suggest getting the STM32 ST-LINK Utility from ST Micro. I'll provide examples, tutorials and better commenting once I get the hardware controller built. Cheers, Wakestrap
  2. We now have a working shell. VesselData and Control Data are flowing smoothly between KSPServer and my MCU dev board. I can now control everything without issue. The only controls I've got implemented in this first release is pressing the User Button on the dev board deactivates SAS and activates RCS. You can enable outputs to the debug console by enabling the macro OUTPUTENABLE. It'll print AP, Vsurf, Vessel Sync and a couple of other variables to the console. Once I had all the pieces working with test code, I had started to write the full code from scratch but when I released how quick it would be to just port the SerialIO arduino code over to mbed, I decided to go that route. mbed has some strange quirks that including no byte type support (char is the usual substitute) and it (like many embedded compilers) pads structs, so I was having major issues with byte alignment when trying to memcpy from byte array to struct and visa versa. I ended up just writing a disgusting amount of code to just manually pull the vessel data from the packet buffer and stuff the Control Packet, it's ugly and I'm sorry. The handshake packet worked fine because it's all the same data type so no padding problems. Fixed this issue by using pragma pack. I'll update you again when I actually get a controller built. I wanted to get the core code out now in case anyone else wants to play with it while I'm working on the rest of the hardware. Thanks again @DrMarcel for writing the EthernetIO plugin and @zitronen for writing the SerialIO code. I hope this adds to the project in some way. I'll try to get a youtube demo video published when I get some controls hooked up. Cheers, Wakestrap mbed project link: https://os.mbed.com/users/wakestrap/code/KSPmbedIO/ Tested on: Nucleo STM32F746ZG Dev Board https://www.st.com/en/evaluation-tools/nucleo-f746zg.html Edit: Added a connection management loop to allow for automatic reconnect, fixed struct padding issue and fixed a watchdog timeout issue. Moved my dev to it's own thread
  3. Hey @DrMarcel! So I've got all the pieces working. I'm sending valid control packets. I can adjust throttle and orientation but I'm having some issues with the variables that shared with the VesselData packet. In particular I can't get SAS controls working. What is the relationship between the NavballSASMode variable the plugin sends me and the NavballSASMode variable I'm sending back to the plugin? Who's the master in the relationship and does MainControls just act as a master disable for SAS?I assume I just resend the vesselsync variable back to the plugin? Thanks so much! Once I get this last bit sorted, I just have to actually design the actual controller and we're good to go. Edit: Scratch that! I'm good, had a look at the SerialIO code. I'm all set.
  4. UDP Broadcast discovery works, handshaking works and VesselData reading works. Control Packets are next and given that I've got all the fundamentals working, should be pretty straight forward.
  5. Awesome! Thanks for taking care of that so quickly! I'll give this a test later tonight. I will 100% release everything here! The code might make you cringe but it should get the job done. I realized I had an STM32F746ZG Nucleo development board laying around, so that's what I'm developing on. https://www.st.com/en/evaluation-tools/nucleo-f746zg.html Tons of IO, relatively cheap at ~$25USD and plenty powerful. I've got the TCP receive handler working, so I can connect to your server and get vessel data without issue. Next up is packetizing the control data and sending it back. I'm leaving the UDP broadcast read until the end as it's only a few lines of code. My work life has me pretty flat out so I've only gotten a couple of hours to pick at it but so far so good. Luckily your code is easy to read so I haven't had any issues reverse engineering the client side. Cheers!
  6. Doesn't look like you implemented the Watchdog disable in your PacketHandler code. I've just cranked up the timeout, but it makes debugging a pain when I haven't written my sender yet. lol.
  7. Hey! I'm about to start work on a KSP controller and I think I may end up using your plugin and building the hardware around an STM32, haven't decided which MCU yet but either an F4 or F7. I'm a hardware engineer by trade, and my software skills are passable. I might be bugging you with some help but given that it's a raw TCP feed, I should be ok (famous last words). I'll keep you posted.
×
×
  • Create New...