Advice on POT logging

Hello Arduino World! Before I ask my question I want to thank everyone in this forum for all the help you have already given me and don’t even know it :slight_smile:

I’ve been spending quite a bit of time reading posts and learning from you all so thank you very much!

As for my question I could use some advice in what direction I should go for this specific project. I’m looking to log the movement of the shifter cable on a bike. As you can see in the picture I have the base of a linear POT attached to the bike and the wiper attached the the cable. The goal is to be able to track when the rider shifts gears.

Questions…

  • First questions is, should I even be using a POT for this or is there another electronic component that I should look into using?
  • Logging should happen when the gear is shifted. I’m going to need some advice on how to add some padding into the system so that it does not miss trigger
  • Logging is to only happen when the gear is changed and not continuous

Help with these questions would be great and allow me to get started. There is quite a bit more to the project, but no need to get into all that until I can get the basics working.

Thank you all!

First questions is, should I even be using a POT for this or is there another electronic component that I should look into using?

The pot might work but is quite sensible to dirt. If you need an alternative you might use a rotation encoder on the derailleur. That might be easier to keep clean. Or attach a magnet to the switcher cable and mount reed sensors at the position of every gear. Might be quite difficult because the gears are usually quite close to each other.

Logging should happen when the gear is shifted. I'm going to need some advice on how to add some padding into the system so that it does not miss trigger

Try to create a sketch that does what you expect. If it doesn't work, post it here and explain what failed. We can try to help then.

Logging is to only happen when the gear is changed and not continuous

Once you found a way to detect the chosen gear this additional requirement is quite easy to implement.

Hello RGMTB,

In your photos it looks to me like you only have 1 wire connected to the pot, is this really the case or is it not obvious from the photo where the other 2 wires are?

My concern with using a pot attached to a bike frame like that is the first time you go out in wet weather it's going to get soaked in water and mud and that will be the end of it.

I suggest you connect the end of the pot to +5v and 0v respectively and the wiper to an analogue input. Write a short program to read the values from the A2D and send them to the serial monitor. This will give you the expected values for each position of the gear shift. Take the values mid way between the values you get and use these as the boundaries for detecting each gear. In your logging program look for events where the values from the A2D move from one range to another and log these events.

You’ll need to find the approximate ADC readings associated with each gear and then allow a range around that expected-center reading.

For example:

if (ADC >=100 && x<=200)
{
     Gear = 1;
}

if (ADC >=300 && x<=400)
{
     Gear = 2;
}

2.Logging should happen when the gear is shifted. I’m going to need some advice on how to add some padding into the system so that it does not miss trigger
3.Logging is to only happen when the gear is changed and not continuous

You’ll need to keep track of the previous gear so you know when it’s changed.

The logic would be somethin like this:

If (Gear != PrevousGear)    //Gear has changed.
{
    PreviousGear = Gear;    // Save new PreviousGear
}

You may also want to add some “timing” so you know the gear has stabilized for several seconds before logging.

Thank you all very much for your replies. As I mentioned, there is a bit more to the project but I didn't want to muddy the water to much up front. Apparently since I'm a first timer asking for help I should have added more details HAHAHA!

Posts around the pot getting dirty. You are all totally correct! I was just sticking this on the bike for testing, but since I didn't mention that to you I can completely understand why you mentioned the issue around dirt. The end result will be a 3D printed enclosure that actually moves this up to the handle bars and puts this inline with the shifter and the cable. This will help move it out of the way and also make it a lot more adaptable to other bike types.

Yes, I did have this wires exactly as mentioned in the post regarding connecting the POT to the Arduino, it is just not picture that way right now.

I think, based on what I'm learning here, next steps should be for me to actually put something more solid together and post my code and concerns. I'll work on that this week.

The main reason for this post was to see if a POT was out of the question for this project and from what I'm reading it should do the job if properly implemented.

Thank you all for your help and support! I'll have a more solid example up shortly

RGMTB:
Thank you all very much for your replies. As I mentioned, there is a bit more to the project but I didn't want to muddy the water to much up front. Apparently since I'm a first timer asking for help I should have added more details HAHAHA!

As a first timer you need to understand the need for accuracy.

The main reason for this post was to see if a POT was out of the question for this project and from what I'm reading it should do the job if properly implemented.

No, to be honest. Even if you do some 3-D printing you won't get the pot water proof, so your solution is an indoor-only solution.

An O-ring on the shaft would do a pretty good job.

Does your shift cable travel around any pulleys that could be converted to digital encoders?

Paul

Paul_KD7HB:
Does your shift cable travel around any pulleys that could be converted to digital encoders?

If a slide pot can be added, attaching an encoder should also be doable. OP, is it important to know which gear we're in or just that the gear has changed?
bike cable.png

bike cable.png