I'm trying to create a code that will allow me to use my Arduino board and magnetic rotation sensor to count the rpm of a flywheel used for exercise bikes. The magnet can be attached to the axle which isn't covered however I am new to Arduino and was wondering if anyone could help?
Ideally I want to gain data such as power, velocity and acceleration by using an inertia value gained from flywheel weight and diameter. The main data point i want to achieve is the angular position of the magnet based on a 0-5v scale. I would like to use the angle position to calculate other metrics but any help with the coding would be appreciated to give an output which can be logged onto a spreadsheet.
The board is an Uno and the Sensor is an AS5040 12bit model.
You may start posting what you have already, and describe where you get stuck.
Also a link to the data sheet of your specific sensor; a quick Google search on that type told me this are 10-bit resolution absolute rotary encoders. You say you have a 12-bit version.
Hi wvmarle
I am attaching the sensor booklet as found on the internet.
I can wire the sensor and arduino board up etc but in terms of a code I am lost as I have not had any experience in the field. The main objective is to calculate the magnetic angular position of the magnet attached to the flywheel axle.
My mistake that the sensor is in fact a 14-bit resolution encoder.
AS5047D_DS000394_2-00.pdf (816 KB)
in terms of a code I am lost
Start with the simple examples that come with the Arduino program development software. Learn to blink an LED, read a switch or a battery voltage, time a process, etc.
That way you learn the language and the special features of the Arduino.
For specific projects, use searches like "arduino measure motor rpm" to see what other people have done.
If you want someone to write your program for you, post in the Gigs & Collaborations forum section and be prepared to pay.
For the encoder, the data sheet you link to is the AS5047D. In OP you mention AS5040. Which one is it, really?
Also that's just the chip, not the mechanical part of the encoder. There has to be more to it: the device that produces the ABI signal pulses as the wheel rotates (A and B for the location/direction, I a zero position so the encoder know where to start counting).
You need the correct disc magnet to go with those sensors, and you need to mount it with a tolerance of
1mm or better coaxially with the chip, and you need to mount it clear of iron/steel parts nearby. That's quite fiddly to achieve.
The model of the sensor is definitely an AS5047D 14-bit.
Link to sensor: AS5047D | ams
I will look at the beginner tutorials regarding the coding, just wondering if anyone had done something similar as I needed to calculate using arduino the angular position using the magnet for readings.
I do have the magnet to attach to the axle and also a plastic casing which attaches to the structure of the exercise bike whilst keeping the magnet and sensor in close proximity.
UnoProject:
Does anyone have any past experience or know how to:
A method to save the results of the angular positions from the serial monitor?
Save what, how, where?
produce these angles as a voltage value?
What voltage? What relationship to the angle? Won't that just produce a sawtooth wave?
Easiest way to produce a voltage from Arduino is PWM output + low pass filter.
Incorporate an RPM count alongside the continuous angle position reading?
Just time how long it takes to take one rotation, or how long it takes for each pulse, and you can directly calculate rpm.
I have the flywheel diameter, weight etc of the exercise bike therefore a way to calculate the velocity and power and time taken?
Sounds like basic physics to me but your requirements are too ambiguous.
A simple W=2pif would calculate angular velocity but a way to code that?
Seriously?
float W = 2 * 3.14157 * f
I have the flywheel diameter, weight etc of the exercise bike therefore a way to calculate the velocity and power and time taken?
I think you are missing the most important aspect of an exercise bike which is the resistance to the flywheeel rotation at a constant speed. There is always some sort of resistance to constant pedaling. Sometimes it is as friction band on the outside of the flywheel, sometimes it s felt pads rubbing on the flywheel, sometimes it a fluid turbine or fan, sometimes its magnetic or electromagnetic resistance.
If you don't know the the resistance you can't calculate power other than the accelerations.
I have made a watt meter for a fluid resistance trainer measuring the rpm of the flywheel, but I had a curve of power as a function of rpm supplied by the manufacturer.