Who am I, when I'm not being me?

hi all,

I live in South Australia, Australia, and am trying to teach myself Arduino/XOD so I can use it to make a “special” bike computer.
I have never had any ‘formal’ training but can wire up most simple circuits, but trying to get my head around Arduino is like a fish being in the boat, trying to hook me!

My project is going to have a digital display of the gears I am using, so for the 28 gears, I have labelled the front gears A B C D, and the rear gears 1 2 3 4 5 6 7.
In gear 1(G1) PNP proximity switches light up A & 1 and show a 1 on an LCD, and gear 28 (G28) lights up D & 7 and shows 28 on the LCD.

How do I use XOD to graphically get this to translate to Arduino?

Thanx in advance
PeterT

There are various XOD nodes for LCD. You will need to find the one that works with your LCD hardware.

There is probably a formula you can use to calculate gear. One would need to know the shift pattern to determine what the formula is. Worst-case, you can brute-force it with 28 “and” nodes feeding cascading if-else nodes (or feeding a large select node). Each proximity switch will use a digital-read or button node to pull proximity switch state into XOD. Here is an example showing brute-force with just gears 1 & 28 completely wired:

If LEDs are not just for debug & you want to include them, just tie LED nodes directly to proximity switches (so each proximity switch is wired to one LED and several “and” nodes).

1 Like

Welcome to XOD, take it slow, one step at a time.

1 Like

Can you please show me how you connect G1 and G2, as I have tried to connect it working from G28 backwards to “and1”, and the moment I try to connect to “and1” I lose the connection between Prox A and Prox1.
G1 = pA + p1
G2 = pA + p2
etc
G8 = pB + p1
G9 = pB + p2
etc

Each “and” node is for one gear. It links to the 2 proximity sensors that need to be on when you are in that gear. This means the “and” for gear 2 would be linked to A & 2. The proximity switch for 7 would only link to the “and” for gears that use it (7, 14, 21, 28).

Now that you’ve provided the gear pattern, it would be easier to use a formula. If A is value one, B two, etc, The current gear is front * rear.

There are probably many alternatives for converting proximity switches to values. This uses if-else (select is a little more compact than this; not sure which uses less Arduino resources):

1 Like

Hi,
Sounds like a great project! One of my favorite resources to introduce me to a new Arduino peripheral or programming system is DroneBots Workshop. He has only two regarding XOD, but I’d like to recommend you view the first. He is much better than a XOD tutorial in that he just learned XOD himself and is very in touch with its use.
It deals with the hard and easy ways to connect the hardware and control it so you text it.
This is similar to your project wanting to deal with hardware and then present it [graphically].
I loved it, dove right in, and see the advantages he also appreciates of XOD over regular Arduino IDE! I know where it (slightly) fell short for purposes.
If I would offer you un-asked for advice, I’d include:

  • You can do this in XOD if you don’t do too much graphics (like on a 128x128pix Oled).
  • Staying on an LCD display (like 16 by 2 line display is fine)
  • I’d keep gearFront and gearBack values as integers (0-3) and (0-6), respectively, for the front and back gears to be kept. You could also do it with each value being a char value, and then when multiplying, ‘A’ - ‘D’ get replaced with 1-4. And ‘1’-‘7’ values with 1-7.
  • You read your switches and use each to set a front or back value.
  • Make sure when you calculate the gear number, you first add 1 to the gearFront and gearBack values.
    The DroneBot intro video is especially good for you since at the end, when he embellishes the project, you get to see the fast turnaround time and ease with which a non-trivial feature can be added in XOD.
    https://youtu.be/L_FkrZTduVc
1 Like

DroneBot was how I heard about XOD :wink:

I spent all of last night retyping my calculations from back in 2011, and finally got them to make sense again, my project is way bigger than just the gear position indicator, that’s just the bit that has been bugging me the longest. (9 years longest!)

My “bike” has an 12V windscreen motor driving through all the 28 gears, so I will need to have a part of the Arduino program that says that if the rpm of the motor is > than 0, then the motor rpm gets printed on the LCD.

I then need to work out whether a reed switch or an IR sensor is the best for detecting rpm of both the motor, and the front gears.

So then the LCD needs to be able to show both motor rpm, and pedal cadence, as well as calculated speed and actual speed, gears, and the obligatory GPS speed, so there is no question about what speeds I can get it to.

So I am wanting the LCD to look something similar to this

Motor RPM Calc Spd

Cadence RPM Actual Spd

GEAR GPS

with a real time/date display as well

BUT…

baby steps first :wink:

I’ll print the calcs here when I can get my son to show me how to screen capture again

I see. Overall about a 6.8:1 difference from lowest to highest gear.

I think you’ll have it a lot easier if you make the whole display always “live”, always showing all information. (If motor RPM is zero it displays 0.0)

If it were me, I’d choose a yellow or blue backlit 4-line LCD, definitely with the I2C controller chip snapped onto the back. You can turn off the backlight for daytime, power-saving use.
( https://www.amazon.com/Diymore-Backlight-Interface-Arduino-MEGA2560/dp/B01LC4Q056
or
https://www.ebay.com/itm/New-Yellow-Serial-IIC-I2C-TWI-2004-20X4-Character-LCD-Module-Display-For-Arduino )

Four lines will fit everything. Typical gotcha - make sure you write all fields completely (so no previous values shine through, say if you go from gear 22 to gear 8, make it print
“22” and " 8" ( each taking 2 spaces)

For sensing repeat events like RPM and pedal cadence, I would not use any reed relays. A magnet can be sensed with a simple coil that the magnet comes in proximity to. (like bike computers do)
Alternatively, a photo interrupter like:


or

No mechanical switches, they bounce, wear out, have low top speeds, etc…

Unlike magnets, they can detect static positions, say of gear position(s).
If you’re good mechanically those second photo-interrupters are cheap enough to use 11 of them, one for each front or rear gear detection. Frictionless detection. You don’t even have to keep the interrupter LEDs on all the time, just every interval that you want to check for gear change. You can turn all those LEDs on and off together and use only 1 output pin.

I just checked the XOD libraries. They DO support the 1604 4-line LCD displays.

1 Like

Sorry I didn’t notice. You are getting great help!
Gweimer is the guy who graciously added the LCD library, recently extending it to “Specify Columns and Rows” so it supports the 4-line display, and adding nice features for clearing, etc.
Best!

1 Like

As nice and clean as this is, I think there is a slight error in the “simply multiply” algorithm.
For example, if you are in Gear B3, which gives a gear number of 6 (2x3), going up one gear in either front or back does not give you 7, but rather 8 (2x4) or 9 (3x3).

To correct this, I would change the values of the Front selections to be 0-3 and leave the Back gear selections to remain 1-7. The right calculation is then simply (Front x 7) + (Back).
Now Gear B3 is 10 (1x7 + 3). Bumping up one Back gear always bumps the total gear by 1, thus giving you Gear 11. (Bumping up the Front gear always bumps up by 7 giving Gear 17).

The great news is that the way gweimer has structured this, and with the power of XOD, it is very easy for you to change this by changing the Front conditionals so that the Front adder adds (0, 7, 14, or 21) and then changing the multiply block to an “add” block.
Now the Front gear increments by 7 and the Rear gear increments by 1, which corresponds to your matrices of gearing.

1 Like

The gears are as follows;
G1 = A1
G7 = A7

G8 = B1
G14 = B7

G15 = C1
G21 = C7

G22 = D1
G28 = D4

So Gear B3 is actually G10
Ok just saw your maths explanation

The IR sensors I am using for front motor and front gear detection are the two piece set of TX & Rx, held apart but aligned to shoot through a singular hole in the gears.
Currently the prototype is held in a toilet roll holder cut to fit across the 4 front gears, but out of the way of the chain.
The Proximity Sensors are the small sensors that will only go closed circuit, when the chain is present, and also get tucked in under the chain.

What are the little boxes called, just above the n-th input, please?

Found them :smiley: this like trying to learn a brand new language

got this much to look reasonable, but it won’t run the simulator, do I need to change some of the switches to positive/true for it to run the simulator?

The simulator cannot do hardware (buttons, LCD, etc.), so buttons/switches need to be replaced with tweak-* nodes (probably tweak-boolean in this case) and LCD with watch nodes. If you don’t want to program all the switches & if-else, you can just use tweak-number to feed nth-input. You can also just type the ratio values into the nth-input node rather than creating all the constant-number nodes (which way it “should” be done is just a matter of personal preference)

1 Like

Thanx for the help, at the moment I’m like a kid in a foreign restaurant, I’ll try anything once to see what it’s like :smiley:, cos I really have no idea what I’m doing, at this point in time

Actually, having a project to dig into, even if not mine, really helps me to learn the XOD way of doing things, especially with these veterans online! Variadics are great. Really simplify things.
I wonder if there are guidelines for how to move things around, i.e. what to optimize for.
(If you notice I keep editing it to better rearrange the lines)

Check this out; it’s all live. (Yeah, I’m a C programmer) I’ll share it with you to take it from there if you wish. (If that’s allowed)
Everything stems from the computed (1-28) Gear number. In order to easier recover the Front and Back gears, that number gets changed to (0-27), which lends itself to integer /7 for the Front and modulo 7 for the Back (after +1).

And with the motor drive ratios added, this one:
(I tried to better adhere to gweimer’s placement advice)


File: Bike Gears with motor.xodball (22.2 KB)

1 Like