Hi,
Are you planning a 4.21 release for the plugin?
Hi,
Are you planning a 4.21 release for the plugin?
What do you mean by start? Arduino starts by plugging it to any energy source, like the USB port. Do you mean send a command to it for it to start something? If thatās it, use the Serial classā Write*** nodes. Check the OP for example images.
I donāt rush to it when a new engine version comes along because the source is on GitHub, so anyone can compile it. But there you go, buddy.
Thanks very much, appreciate it.
Hi
How do I send Hex values via this plugin?
Iām trying to use this to communicate with a FTDI device (USB device that converts into a COM port) It is a speed and heart beat reader for a thread mill.
Windows is connecting to it via COM3. 57600 baud. In Unreal I can connect to the device with this plugin, so everything seems fine.
The protocol for this device tells me to send 0x44 to start the device, then 0x36 to set the output sample rate, and 0x0A to set this rate to 10 samples /sec and then 0x38 to get it to start sending data.
The paper tells me what data to expect in return from these commands, also given in Hex.
It says I could send the decimal ekvivalent, eg. 68, 54, 10, 56.
What node should I use to send this? Write a Byte? Write Bytes? I have tried some of them, but donāt get the expected result.
A led on the device flashes when I send commands, so I am pretty sure I have a connection.
Any advice is greatly appreciated!
Thanks, Ole
You are assuming correctly. Each of those is a byte, so Write a Byte. Do use the decimal equivalents, because Unreal only understands decimal in its node fields.
Right after you Write a Byte, if you call Read Bytes, does the array comes empty? Did you try to delay before reading the deviceās answer? Maybe youāre just expecting the answer too soon?
Iād try it with a Read Byte on Tick for a while after sending a command. To see how long it takes to answer.
I recommend using Flush before sending a command, just to make sure thereāre no previous bytes in the read stream waiting to be read. Because that could look like a command answer, but would just be stuff that was sent before your command.
Thank you ever so much! I tried this, and it actually works!
I send 68 as one byte, then 54, 10 and finally 56. Then my device starts sending data! ( I also get some correct response bytes when sending the 3 first commands)
I have set up a Read Bytes - node in the Tick event. It seems to get the correct data back.
The device sends 16 bytes of data, including speed and heart rate. I can decide how often it sends this info, so now I just have to find a good balance of it sending the info and Unreal trying to read it.
And then teach Unreal to decode 3 separate bytes of numbers to a float that I can use in my application
Thanks again for the info! And thank you for maintaining this plugin!
Ole
3?? Thatās kinda odd.
Anyway, if you need to convert 4 bytes to int or float or from those into bytes, there are nodes for that in the plugin too. BytesToInt and IntToBytes. Same for float.
Yes, it is!
Here is the data string I now successfully receive (from the manual of the device):
"The data string/packet is 16 bytes long. The data string/packet
starts with 26 00 decimal (1A 00 hex) then 14 bytes of data.
Example : 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (hex)
Data string description (HEX):
1A 00 | 00 00 00 | 00 00 00 | 00 00 00 00 | 00 00 00 | 00
ACKā¦| Verticalā¦| Speedā¦| Run Timeā¦| Horizont. | Heart Rate
ā¦
SPEED: Speed of running belt in yds per second. 3 bytes. 00.000-99.999 Yards/Second.
00. 00 00 format. Example: 04 03 5B = 4.859 yds per second. 04.(03 5B). 03 5B hex = 859.
ā¦"
Itās the speed Iām mainly interested in.
You see it is coded in a non standard way with one byte before the decimal mark and two after.
So I have to take byte 6 to 8 and convert it in this way and make in into the speed of my camera in the VR simulation.
Iāll take a look at your nodes and the C++ behind it. I guess Iāll make my own blueprint node in C++ to do this. Since it is so ānon standardā there is no reason that you have support for this in your plugin. But it is really neat that we can play with small hardware devices in this way!
It is! Iāve used it to control lights and stuff like that from inside Unreal. Really cool.
Thatās a very interesting way to encode a float. The way I make my conversions in C++ wonāt help you with that, because it just breaks apart or put back together actual float/int bytes, in the way they are organized in memory.
I bet youāve already came up with some algorithm for that, but in case you didnāt, either in Blueprints or C++ Iād do it this way:
In Blueprints, Iād write that formula in a Math Expression node and convert it to a macro. That way itās easy to use it elsewhere and the Math Expression node makes it very performant.
EDIT: Actually, in C++ you can make that formula even faster: A + ((B << 8) + C) * 0.001f
Thank you for your suggestions!
I was not aware of the Math Expression node in Blueprint. That seems very usefull.
But I really liked your C++ bitshift version, so I guess Iāll make use of that!
Hello there.
Thanks so much for the plugin, I think itās going to be perfect for what i want to do.
Iām fairly new to Arduino and to Blueprints in Unreal. I was able to get your plugin up and running and iām sending data from a potentiometer into Unreal and using it to drive a attribute on a camera. Thatās all working great. Now iām looking at adding some buttons in Ardunio to change what attributes in Unreal iām controlling. So i have the issue of needing to send multiple items of data. In this case just two items, the āmodeā that the Arduino is in, and the values from the potentimeter. But my hope is to add some more items in the future.
So after reading through all the posts on this thread it sounds like iām dealing with the classic āprotocolā issue that you describe back in post #42. My issue is that your solution is a bit beyond my abilities at the moment. While Iāve done a fair bit of scripting in other languages Iāve never had to deal with bytes before so itās a whole new scary world.
However i came up with a different way if handling multiple bits of data all as a string. I know in your original post you say that this can freeze your game, but in my, albeit limited testing, i am not seeing any freezing. everything seems to run fine at 60fps.
In my Arduino code iām sending it out like this:
Serial.print(ām:ā);
Serial.print(mode);
Serial.print(āv:ā);
Serial.print(outputValue);
Serial.println(āeolā);
Then in blueprints iām using a serials of string splits to separate out the data. Iāve attached a screenshot. This seems to be working just fine. But iām guessing there is some very good reason why doing it this way is not such a great idea, but i donāt know what that reason is.
thanks
eric
Defining what you are sending and is expecting to receive is the more correct way of doing it, it will look cleaner and error checking is simpler. You will also save resources on both ends doing the more correct way.
Like @Lambdarevolution said, youād save resources by using bytes. Each character in a string is a byte by itself (plus the null one at the end to signal the end of the string). Besides the processing to process the strings, convert from/to numbers etc.
But, if you still want to use strings, replace ReadString with ReadLine. If you just ReadString, itāll read whatever is in the serial buffer, and youāll likely get half strings many times. Because Unreal and the Arduino are not in sync. So you might get things like āmodev:outpā in one frame and āutValueeolā on the next frame, because Unreal read while Arduino was still sending. Whereas if you use ReadLine, the reading will only end once it gets a line end, which youāre sending with Serial.println. It will freeze if Arduino takes too long to send another line end, so keep doing that in the loop as fast as possible.
Another thing you will want to do is use Flush after every ReadLine, to clear the serial buffer before the next frameās ReadLine. Otherwise, if Arduino is sending data faster than Unreal is reading, as each ReadLine stops in the next line end, it will potentially leave many other strings in the serial buffer, and on each ReadLine youād be reading only one group of commands, which would not be the latest one.
Thanks for the advice and tips
Itās not that I WANT to use strings, itās just the only thing currently within my current technical skills and knowledge. I just need to go off and learn how to use bytes as it does sounds like the better solution. Maybe after iāve done a lot of the other components for this project iāll come back to that.
thanks again for the great plugin.
thx-e
Can I use this plugin in my c++ project? I tried to include in the dependency in Build.cs and it does not work.
Hi,
is it posible to run with 4.22?
Thank you for this great tool
OlĆ” Rvilani, o plugin Ć© fantastico, qual a possibilidade de uma compilaĆ§Ć£o para a UE 4.22?
It was missing the UE4DUINO_API macro in the class declaration. Sorry about that! I only learned about it recently. I guess all the times I needed to use my plugins in C++, I got lucky by having that macro already unaware of what itās for. hahaha You can download the fixed source or the released version for 4.22 in the link above.
Youāre very welcome! It always was But if you donāt want to build it, the release is in the link above.
Obrigado! Bem possĆvel, eu diria. XD
Obrigado! !!! top