Author Topic: how to transmit float via uart  (Read 19924 times)

0 Members and 1 Guest are viewing this topic.

Online IanB

  • Super Contributor
  • ***
  • Posts: 11898
  • Country: us
Re: how to transmit float via uart
« Reply #50 on: August 02, 2016, 11:15:34 am »
It is, probably, a sign that something has gone a bit wrong when you start using floating point calculations on a little microcontroller for basic arithmetic.

For instance, if the speed of sound in water is 1500 m/s, then a signal will travel 1500 m in a second, or 1500 mm in a millisecond, or 1.5 mm in a microsecond. So you can just measure the time interval in microseconds, multiply by 1.5 (trivial in binary arithmetic), and you have the distance in mm.
 

Offline mzdenkovTopic starter

  • Regular Contributor
  • *
  • Posts: 82
  • Country: hr
Re: how to transmit float via uart
« Reply #51 on: August 02, 2016, 12:37:21 pm »
Thank you guys. snprintf works... as it looks like sir " suicidaleggroll" found other mistake in seting TX as output.
After 20 times of sending random numbers ... i see what i need to see... FLOAT as ASCII on TX line.
To Solder or not to solder, that is the question!
 

Offline mzdenkovTopic starter

  • Regular Contributor
  • *
  • Posts: 82
  • Country: hr
Re: how to transmit float via uart
« Reply #52 on: August 02, 2016, 12:52:41 pm »
One more thing, i have some time to calculate values:

Mesurements are started in interval of ~ 1 sec with timer... other is happens in interrupts like on flow chart
To Solder or not to solder, that is the question!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf