Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:16 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Maths question

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 02:45am 25 May 2016
Copy link to clipboard 
Print this post

This is probably easy for someone experienced but to me I cannot figure it out.

I have an anemometer that gives a voltage output depending on the direction of the anemometer and the reference voltage

Each degree gives a voltage of 0.0091666666666667V
so for example 10 degrees would be 0.091666666666667V
176 degrees would be 1.613333333333339V and so on

I need an easy way to convert the reading into a decimal degree ie 1 - 360
It's a "simple" maths equation I believe but I cannot figure out how to express it.

I "could" do it by using a lookup table of 360 voltages but thats a lot of wasted code space

I already have the code written to display the wind direction as NNE, NE, E, ESE, SE, S, and so on.
But I'd like to also be able to display the decimal degree position so that it can upload an accurate wind position to one of the weather servers

Any suggestions on how to "phrase" the calculation?
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2949
Posted: 03:00am 25 May 2016
Copy link to clipboard 
Print this post

GDay Lew,

Wouldn't it be as simple as

Angle = MeasuredReading / 0.0091666666666667

I think that level of accuracy couldn't be read on the analog inputs maybe you should stop at say 4-6 decimal places?

Kind Regards,

Mick

Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:21am 25 May 2016
Copy link to clipboard 
Print this post

Just divide your voltage reading by 0.0091666 then round the result with the CINT function.

i.e.
DIM AS FLOAT degrees, volts
degrees = volts/0.0091666

then to round it;
degrees = CINT(degrees)

You'll need to do a couple of 'sanity' checks on the raw voltage reading too no doubt, like test for negative voltages or voltages outside the 360o range (360x0.0091666). Also you'll probably need to average several readings over whatever time period is appropriate for you and remove any fliers in the averaging set.

Greg

Edit: Mik beat me to it, same same, and yes anything over four or five significant figures doesn't gain you anything.
Edited by paceman 2016-05-26
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 04:23am 25 May 2016
Copy link to clipboard 
Print this post

Thanks everyone
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 02:37am 13 Jul 2016
Copy link to clipboard 
Print this post


EDIT: Deleted the question because I managed to sort it and got it working
Edited by lew247 2016-07-14
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025