[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I'm trying to send data from an arduino via USB to a PC
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 9
Thread images: 1
File: double-digital-ldr.png (173 KB, 993x1270) Image search: [Google]
double-digital-ldr.png
173 KB, 993x1270
I'm trying to send data from an arduino via USB to a PC program which will read the data points.

The question I have is relating to how much precision I can get from sending a given number of bits from the UART port.

Since the data I'll be writing to the UART port will be variables of type double, and I send 2 bytes of data per data point to the PC's program, I wanna know how much precision I can achieve.

How are double and floating-point values represented in binary? I assume some bits of data will be used up to indicate the position of the decimal in the number, right? So how much precision for variable of type double can be achieved with 2 bytes of data sent?

thanks, /g/
>>
>>55173226
>how are double and floating point values represented in binary
IEEE 754
>>
this sounds like actual technology and not linux
>>>/anywhere but here/
>>
Why do you have to use 16 bit floats? Anyhow if your data can be unsigned you could probably get 2x as much precision.
>>
>>55173226
>sjwuino
>>>/reddit/
>>
thanks, /g/
>>
>>55173274
don't you mean signed?
sorry if it's a stupid question but doesn't unsigned require extra for representing it?
>>
>>55173226
You cannot send a 'double' value in 2B, because a double is by definition 8B (64 bits). You can send a so-called half-precision floating point value (as opposed to double-precision) in 16b.

Floating point values are generally represented by a sign bit, a number of bits for the exponent and the rest (largest part) for the "fraction" or "mantissa", google it for a proper explanation on the format and the precision you can expect.
>>
Just use 8bit blocks for sending data.

If you use PySerial, you can easily set it. The UART comms doesn't know anything about signed or unsigned or lengths, so when you receive the data from your microcontroller you have to keep polling the port, and interpreting it correctly when you have the next n amount of bits.
Thread replies: 9
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.