How can I get information from a bike

Hello everyone, I wanted to use a bike as a game controller for a unity game I'm working on. I need to get the bike's handlebar rotation and rear wheel rotation(or speed) in real time. Later I might consider adding new features to this "controller" (I'm thinking some kind of feedback from the game) but for now that is about it. I initially considered getting the handlebar rotation with a pot and getting the speed of the rear wheel with an accelerometer on the inner side of the wheel that turns with the wheel. But I am not sure how I can do that without the cables getting tangled and twisting as the wheel keeps spinning. I know I can probably do it with a bluetooth module or something but, basically, I have never used an Arduino before and I don't know too much about electronics.

My question is, which arduino model should I buy? I know that 101 has an accelerometer and bluetooth but, what should I do if I want to place the Arduino somewhere close to the pc or somewhere static so that I can add more things to it later? Then how can I get the accelerometer values from the wheel to the arduino?

Or maybe there is a better way of getting information about the wheel's speed that I haven't thought of(using a reed switch won't work since the rotation/speed needs to update more than once per one full rotation).
Anyway, I hope someone can be of assistance.

Thanks in advance :slight_smile:

The potentiometer should be fine for the steering.

I reckon a better way to get the wheel speed is with an optical sensor and some blobs of white paint on the tyre. Get the Arduino to measure the time between the pulses. I suspect 2 or 4 pulses per revolution (or maybe even just one) would be sufficient. That way there is no need for an electrical connection to the moving wheel.

I am using a QRE1113 reflective object sensor and it should be suitable if it can be located about 1mm or 2mm above the surface.

...R

Thanks Robin.

I thought about using something like that for the wheel speed but I am afraid that it will not update fast enough for the game. With that method, I will be able to calculate its speed but only once it has already seen the white paint. Also I want the person riding the bike to be able to use the brakes to slow in the game, and I don't think it would work well when the brakes are used and the wheel stops while the optical sensor is between two white spots.

My main goal is to create an experience as close to actually riding a bike as possible. I'm planning to keep the bike mostly intact with only the rear wheel not touching the ground and the bike stuck in a balanced position. I might later make it so that the game can change gears on the bike or use brakes in order to simulate going uphill, for example.

Thanks again :slight_smile:

If it stops between spots, you will not sense pulses, and your program will know it's stopped.

Am I misunderstanding something?

I record the time between two pulses(or calculate it) and then divide the distance(that the wheel would have made if it was on the ground) by the delta time to get the speed, which I then apply to my character in game. The speed I calculate is applied to the character after a pulse is detected.

If I'm mistaken about this then please correct me but if I am not, then there are some problems with this.

Firstly, I only get to know the speed of the wheel after I get the first two pulses, which means while I slowly start to pedal, the character isn't moving for a little while.

Similarly, I don't know whether the player has stopped or just slowed down when I don't detect a pulse for a while, considering it is entirely possible to ride a bike such that the wheel spins at 5 RPM.

So the problem is basically that, I only 'detect speed' because I average the speed between two pulses. And even then I don't get to apply this speed to my character until the end of this duration of which I'm averaging the speed in.

If I am wrong and I misunderstood the method in which we can calculate speed in this way, then I am sorry and I would be happy to hear how to calculate speed such that it is always accurate.

But I think I need a more accurate way of getting the speed from the bike so that the player's immersion isn't broken.

Thank you :slight_smile:

Stick more white dabs on the wheel...youll get more "resolution" then.

Of course braking something that has bugger all inertia will be totally different to reality, so youd probably want a weighted wheel.

If you need more pulses maybe you need to have a small jockey wheel running on the tyre and detect the time pulses from it.

Don't worry much about getting the theoretical ground speed accurate.

You can get rotary encoders that produce lots of pulses but I can't see the cost being justified for your project.

...R

Get a bicycle generator light, the old incandescent light type, and see how voltage changes with speed. I've burned out a 9V bulb in a 6V rig going downhill.

Robin2:
If you need more pulses maybe you need to have a small jockey wheel running on the tyre and detect the time pulses from it.

The hub turns as fast as the rim. Most hubs have spoke holes all the way around.

GoForSmoke:
The hub turns as fast as the rim. Most hubs have spoke holes all the way around.

What has that got to do with my suggestion of using a jockey pulley that rotates very much faster than the bicycle wheel?

...R

If you need more pulses

The wheel hub generally has plenty of perfectly spaced holes.

A small wheel against the tire, I've seen that suggested before too.

The opto sensor is the way to go , the more reflective spots the better the resolution , you could run the pulse in measurement on an interrupt and get very accurate speed calculation,

other options would be a break beam optical, or a hall effect sensor

As for the handle bar position a simple pot would work , but would need some calibration . the main problem here would be that your only going to have half a turn at most. use a lin pot , not a log

If I increase the number of reflective spots by a lot, and move my character based on the distance instead of speed, I might be able to get some pretty accurate movement. I will have to change some other things but that is fine.

So now my question is how many pulses per second can I detect with an optical sensor? I looked up on some sites that sell them near me and they had no information about that.

By the way, does it matter which arduino I get for this? I haven't bought anything yet since I wanted to make sure that this was possible to make.

Thanks.

If I understand the QRE1113 datasheet its rise and fall times are each 20µsecs which suggests it can detect a pulse every 40µsecs.

I suspect that is a relatively slow device - I chose it because it is physically small. Sparkfun sell it on a breakout board. If you decide to buy one be sure to choose the analog version in spite of the confusing name.

...R

with a good optical sensor you will be able to detect hundreds (if not thousands) of steps per second

number of steps per second will give you speed signal
number of steps divided by the number of reflective spots will give you the number of wheel rotations
number of wheel rotations X diameter of the wheel will give you distance travelled

if you have not already got an arduino for the project , I would suggest a mega 2560 as interrupts are tied to the timers and the mega has more , so it will be a bit more flexable

You could use a gear tooth counter on the front chain ring. Then only feet movement would be counted. You wouldn't need the back wheel or chain or brakes. Coasting along would need a function but that is all. Brakes and shifters would only activate sensors.

A bicycle sim would need to tilt and feel acceleration forces to turn. Please, not a bike sim as it would not teach the right things.

GoForSmoke:
A bicycle sim would need to tilt and feel acceleration forces to turn. Please, not a bike sim as it would not teach the right things.

Haha, don't worry. I may be a newb in electronics but I understand game design (or at least I think I do).

Well I make games for Oculus (more like presentations), and there are a lot of problems with using a contoller. Like the motion sickness(that depends mostly on how the controls are handled, but a lot of things about using a regular controller makes it easy to get motion sick). Often I will have to present a game to someone who hasn't ever experienced VR before, or sometimes to people who haven't played many games to begin with. It is just weird to ,after someone has put on the headset, awkwardly handing them the controller, and then awkwardly trying to explain the controls(since they haven't used many controllers in their lives, they have a hard time pressing buttons when they can't see them).

That is why I thought it would be better if I was able to use a controller that more people who don't normally play games are more familiar with, as well as a controller that lets you control your speed and direction more precisely, hopefully without causing motion sickness.

In retrospect, I should have mentioned I wanted to use this for VR games while I was writing the initial post. I seriously don't know why I didn't.

That is why the accuracy of the speed is so important for me, because if what the player sees and feels don't match up, it is bound to cause some motion sickness.

Then you only need the pedals and chain ring (to count teeth), and steering wheel so far.
If you use 2 sensors and Gray Code, you can read forward from reverse.

The car sick is from inner ear not matching perceived motion and varies by user.
I used to play combat flight sims and know that there are people who could not due to that.

Is there anyone there working with any kind of treadmill?

Do you know how Saitek senses stick angle with Hall sensors? They don't need cleaning or lube, they don't wear out, you only need to handle dithering. The only pots to match them cost a whole lot more.

If this is going to be a VR game,then there will need to be variable pedaling resistance with speed and terrain. Depending on how the rear wheel of the bike is coupled to the resitance unit, you will have the opportunity to pick up the wheel speed from a smaller roller or shaft which will turn several times for every wheel rotation. With multiple sensors or an encoder on that unit, you can have all the precision for rear wheel rotation speed that you want.