![]() ![]() I have an XY-axis joystick hooked up and plan to send the axes to map to the aileron and elevator, respectively, once I've successfully got data sent. As of now, I'm not trying to write to any specific property as I just wanted to check in FG to make sure that data was successfully even being sent (something I have not yet had). I've taken your advice of using an integer instead of float as well as your advice to send the whole numbers and factor afterward- thank you for that advice as I had no idea floats slowed things down.Ģ. I have updated the protocol file and it's posted lower in my response. Yes, the XML file is named 'hawdware.xml'. Let me address a few of your questions:ġ. Tom tom_nl Posts: 84 Joined: Tue 10:41 am Location: Netherlands OS: OS X Big Sur go on to getting into working with ethernet. As you already have the properties sending successfully by serial, try binding them to FG using that - change the 'udp' line to serial instead:Ĭode: Select all -generic=serial,in,/path/to/hardware.xmlThen once that's working. a factor of 0.002 ( 0.001) in the XML) can be applied to map this -1 to 1.Ī thought - do you absolutely have to use UDP? I've had all sorts of 'fun' with ethernet on Arduinos, so for my panel I use serial communications which I find much more straightforward. a line in the arduino code like this (elevtrimraw is the raw pot value):Ĭode: Select all elevtrimout = ((constrain(elevtrimraw, 11, 1011)) - 511) I set a limit on the pot values so they are constrained to read between 11 to 1011, then subtracted 511 to result in the pot reading -500 to 500 - i.e. Analogue reading in Arduinos goes from 0-1024, so I handled this in a different way which I think is more elegant plus should be less computationally demanding. However, I found this also introduced rounding errors. This is very easy by adding a to hardware.xml to rescale it:Īlso, if it's a floating point number, specify it as 'float' in hardware.xml. instead of mapping the value -1 to 1, map it to -1000 to 1000 instead, then do the rescaling -1 to 1 on the FG computer by multiplying by 0.001. There's a few ways to handle this.ġ) In the arduino code. One other thought - Arduino's don't like working with floating point numbers - they have to handle all this in software which takes a lot of cycles and can introduce rounding errors. You can then re-bind '/instrumentation/altimeter/arduino' to something you want to change (assuming it's something like altimeter pressure). path/to/hardware.xml to make sure FG finds the file.Ģ) What property are you trying to write to/change in the property tree? Bear in mind that the property '/instrumentation/altimeter/arduino' isn't actually bound to anything (unless you have some custom nasal code that reads it and does something) so even if it changes, it won't do anything! However it will still get updated - Check the property tree when FG is running to see if turning the pot changes that property. In theĬode: Select all -generic=socket,in,100,192.168.1.191,8888,udp,hardware line, change 'hardware' to the full absolute path to 'hardware.xml' i.e. ![]() I've done a lot of head scratching with arduinos and flightgear - the first time you try it it can be confusing.ġ) is the xml file called hardware.xml? because that's what the launch command is looking for relative to where you run the command. I am new to the forum so if I've uploaded anything wrong please let me know and I'll change it or add whatever information is needed. If there is anyone out there that has experience with this, I would greatly appreciate any advice. I'm receiving the data like so (that being said, I've tried float, integer, and string to no avail): ![]() I'm using the following XML file for communication:Ĭode: Select all -generic=socket,in,100,192.168.1.191,8888,udp,hardware ^ However, I still cannot get this to come through in the Debugger in FlightGear. Stickx = (analogRead(stickxio)/512.0)-0.998 //Calibration span and offsetīy uncommenting the lines of Serial.print, I've finally got the String value called "lat_stick" to display the actual value shown by stickx. GATHER THE VOLTAGES AND CONVERT THEM TO signals An EthernetUDP instance to let us send and receive packets over UDP Unsigned int UDP_Port = 8888 // local port to listen on SETUP THE ETHERNET CONNECTION (MAC ADDRESS & IP ADDRESS)īyte mac = It is simply taking in a potentiometer reading (analog input) and I'm converting it to be and then just trying to send the data.Ĭonst int stickxio = A1 //Define stick aileron (x) inputįloat stickx = 0 //Start aileron (x) central Using the information from this forum and others, I've written up an Arduino IDE code as shown below. I've been scratching my head for a while trying to figure out how to get my Arduino + Ethernet Shield to talk to FlightGear. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |