kureigu
Member level 2
- Joined
- Jan 14, 2013
- Messages
- 49
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Scotland
- Activity points
- 1,779
I'm still relatively new to VHDL and I'm having trouble working out how to implement trigonometric functions.
I need to implement the following function in VHDL to determine the angle from an inclinometer, and any advice on how to do this would be much appreciated.
Converted to deal with change in bits, rather than voltage:
The result that I get out of it preferably needs to be in degrees with a resolution of 0.1 degree. Arguably it could be scaled by a factor of 10 so that, for example, 39.4deg becomes 394. I'd like to display it on a 4x7seg display at some point too.
The value that I need to feed into the function is an 11bit unsigned value from an ADC at present.
What would I have to do to implement such a function with the accuracy I require? Would I need to know how to use floating point too or can I manage with fixed point?
I should stress that my VHDL experience so far has only really covered digital interfacing (SPI, I2C), driving some 7 segment displays, and straightforward arithmetic functions and assignments.
I need to implement the following function in VHDL to determine the angle from an inclinometer, and any advice on how to do this would be much appreciated.
Code:
alpha = arcsin( (Vout-Offset)/0.035 )
[Offset = 2.5v, Vout = 0 to 5v]
Converted to deal with change in bits, rather than voltage:
Code:
alpha = arcsin( (Data-Offset)/14.336 )
[Offset = 0x3FF, Vout = 0 to 0x7FF]
The result that I get out of it preferably needs to be in degrees with a resolution of 0.1 degree. Arguably it could be scaled by a factor of 10 so that, for example, 39.4deg becomes 394. I'd like to display it on a 4x7seg display at some point too.
The value that I need to feed into the function is an 11bit unsigned value from an ADC at present.
What would I have to do to implement such a function with the accuracy I require? Would I need to know how to use floating point too or can I manage with fixed point?
I should stress that my VHDL experience so far has only really covered digital interfacing (SPI, I2C), driving some 7 segment displays, and straightforward arithmetic functions and assignments.