Getting starte: My first project: Cruise control for ebike

PaulS:

After all, why carry an additional display, when I already have a perfectly good one.

OK. That's fine. I presume, then, since you are using it as a speedometer that you know how to get data into the phone, and how to manipulate that data to produce the visual effects that you want. Adding more data, and more manipulation to produce more effects, should be trivial.

It's not that simple. I have an app that can do those things. It uses the GPS signal and calculates those values. So unfortunately I cannot take credit for that.

If you can recommend a nice weather proof display,

Is your phone weatherproof?

No, it isn't, but I don't leave my phone mounted to my bike, wherever I go. Whereas if I had a dedicated display I would mount that to the handlebar permanently.
And yes, when it starts to rain, I'll put my phone in my bag so it doesn't get wet.

Deus_Ex_Machina:
A readout of the speed and then cranking the throttle up slowly until that speed is reached would be perfect, but the problem is, how to control that. Because the controller would have to understand not only the current speed, but also the acceleration, so it accelerates at a more or less constant rate up to the target speed.

That's easy enough to do, if your Arduino knows the current speed. Do you have any way of knowing the speed?

A readout of the speed and then cranking the throttle up slowly until that speed is reached would be perfect, but the problem is, how to control that.

Many ways to do that. PID would be an approach for example.

The key, seems to me, would be to find a way to interface with your bike: read off speed, and change throttle, at the minimum.

I can install a magnet in one of the spoks and maybe get a hal-sensor on the fork, hell, I could install multiple magnets in the spokes to make the readout more accurate.
Multiply the amount of peaks per minute with the circumference of the wheel, and we have the current speed.
That should be easy enough, if I know what sensor to buy.

Knowing the bike's speed is only half the equation. How do you effect the throttle?

The throttle is a 0V-5V signal, which I can input either with a twist grip or a thumb throttle.

Here's a link to technical info for the controller

So, where do I start guys to get the first bit working.
Let's start with the most simple function and take it from there.

I would start with the throttle. Get a sketch going that will generate a desired analog output based on a variable.

From there, I would implement the pid or whatever control scheme you wish. This will drive the throttle variable based on speed target and actual speed.

Then I will write a piece to actually measure the speed.

From there, the display and input routines.

I would start with the throttle.

I disagree. I think you should start with the parts that won't kill you. Learn how to access the bikes speed, the switch input, the brake lever input, etc. BEFORE you try to actually control the speed of the bike.

Lest you think I'm being overly harsh, please realize that I have ridden motorcycles over 500,000 miles. My current two bikes and the 2 of the 4 I no longer own have all had cruise control from the factory. I have ridden less than 10 miles with cruise control engaged in all those miles. There are just too many things that can go wrong when YOU are not operating the throttle, even when it is fast and easy to override the cruise control.

The big problem with cruise control on a bike is that it lets you do other things while the computer is controlling the speed, when what you should be doing is devoting your full time and attention to operating the vehicle.

Those 10 miles? Less than a tenth of a mile at a time, while I adjusted a vent or a mirror on the right side.

Thank you guys for your answers.

As much as I would love to play around with the throttle right away, I agree, that the first thing would be to get a readout on sensors and display them. Then I could expand on the parameters I can manage. And once I have the parameters I need to change something else, we'll approach that.
Henry, I'd be happy to accept any help in programming so I can take a first look at what code actually looks like and see someting very basic that actually works before I try to expand on it.

Could you guys give me a shopping list of what to get?
Maybe we could start with the basic hardware for the Arduino (I don't even know which one or which kit to get)
a display (if android readouts are too difficult for the beginning)
and some sensors (temperature, hal sensors for speed and crank cadence, maybe a photo sensor to automatically switch on the backlight when it's too dark)

Maybe we could start with the basic hardware for the Arduino (I don't even know which one or which kit to get)

There are not that many things you need to be monitoring. I'd start with a UNO. It has 20 IO pins, which should be plenty to get started with, and is not too big or expensive.

a display (if android readouts are too difficult for the beginning)

There are two basic types - character based and graphic based. If you want to just show numbers, character based is fine. If you want to draw pictures, you need a graphic based model.

There are serial displays, which use just one pin, SPI models that connect to the SPI pins (11, 12, and 13 on a UNO), and those that use more pins. Price is generally inversely proportional to the number of pins used.

and some sensors (temperature, hal sensors for speed and crank cadence, maybe a photo sensor to automatically switch on the backlight when it's too dark)

Some of these (the photo sensor is a nice idea) may or may not already be present on your bike. (Perhaps you could tell us about it.)

I think that you'll be happier, in the long run, learning about the Arduino and how to connect it to the bike, of you start with safer projects. Take care, whatever you do.

Well, the cruise control is the thing I set out to accomplish and that is the mid term goal.
I understand that there are other smaller goals that need to come first.

As it stands now, I have no sensors on the bike.
The motor and the controler are still underway. The bike is still a regular 28" trekking bike with only non electric gadgets, apart from an insane 30W LED, which I'l exchange for a more reasonable bike light.
So, we're actually starting from scratch.

The controller used in the bike, will be a KU63 as sold by BMS battery. I posted a link of a description.
To start out, the conversion of the bike will be the installation of a 12s 5Ah LiPo battery pack, a fuse, the KU63 controller, a Cute Q100 motor in the front wheel (with hall sensors connected to the controller), a thumb throttle as the only throttle input and two Magura reed switches for the brake as kill switches for the throttle. So once I move any of the brake levers, the power to the engine will be cut...
So far so good.

What I would like to measure and implement:

  • Temperatures (ambient, motor, battery, controller)
  • Cadence (front wheel and crank)
  • foto sensor (for backlight on the display and later the bike light. My rear light already has such a sensor and a motion sensor that switches on the rear light when the bike moves and it's dark, so maybe we could hook it up to, so the flow of current is measure and once the light is on, and the current increases, we know it's dark or we just implement a foto sensor)
  • voltage from battery
  • current through the controller
  • Voltage and current USB port (I bought a DCDC stepdown converter to get 5V 3A from the 12s batteries to power my phone)
  • compass
  • calculate trip time (moving time)
  • average speed
  • distance
  • barometric sensor (elevation)
  • Ah consumption per km

I've drawn up a little picture in powerpoint of what I would like the interface to look like in the end

I am envisioning that the 9 fields are customizable.
In the settings you should be able so select which values the specific fields cycle through if you click them, say the "voltage" on the bottom right, could cycle through USB voltage, battery voltage, average curren and ambient temperature, while the one to its left would cycle only through current (now) and maximum current.
You can select any option for any field, making it completely modular for anyone to set up as they wish with all the sensors and values they have connected. Fields that have only one fixed setting like speed, could but used as switches when clicked, such as cruise control (which would make sense with the speed) The the speed would show the current speed and the target speed in a little corner.

As you can see, it's not the lack of ideas, that's stopping me, it's just that I lack the skills to implement it. A rugged 5" android device could be the killer device for any bicycle geek.

But let's start small.

http://www.ebay.de/itm/Arduino-Uno-R3-ATmega328-Microcontroller-Entwicklungsboard-USB-Cable-/230828847676?pt=Wissenschaftliche_Geräte&hash=item35be78b23c

Is this, what I should buy? With all the sensors and android interface that I will definitely want, is this the right one, or should I maybe get a set or some other things aswell. I'd rather have everything I need to start out and not start buying more stuff in 2 weeks. I don't know, maybe there is a set of sensors. Can this Uno handle all the sensors and outputs that I want to do, or would I need something bigger for that?

The purpose to start in my sequence is so that you can build on what you have done: see if you can output a voltage; see how that voltage tracks speed errors; and see how you will pick up speed information and feed it to the PID controller; etc. It doesn't need to be tried on a real motor. But allows your process to be otherwise functioning.

Is this, what I should buy?

Yes.

I'd rather have everything I need to start out and not start buying more stuff in 2 weeks.

Where are you? Sometimes, it is better to buy stuff locally, if that is possible. You will probably change your mind on sensors more than once during the project. Waiting 2 or 3 weeks for stuff to be shipped to you can be frustrating.

Can this Uno handle all the sensors and outputs that I want to do, or would I need something bigger for that?

That depends almost entirely on the LCD display that you get. With a serial model, the UNO should be adequate. With a multiple wire model, it probably won't be. If that is the case, a Mega is what you'd want.

I live in a small town in Bavaria, no chance I could get any of the equipment locally.
I always have to order things online so.
If I want to get a good deals on things like tools, I even have to order abroad.
I have a Leatherman Surge and a Charge TTI and a Micra for the Mrs coming from the US, also some Nike running shoes and Maxpedition pouches.
Just figure: I paid $50 for a pair of shoes that retails 120 Euros over here. (I got three pairs :wink: )
Shipping inside of Germany takes a maximum of 2 days. I bought some LiPos from the Hobby King warehouse in Hamburg. Took 3 days, which was odd. So, there's no way around it
If I buy for more than 40 Euros online, I can return any item for free within 2 weeks. I don't even have to pay the return shipping.

On the subject:
I'll have to see how much more expensive the Mega is. I'll probably be wanting one anyways.
Is Saintsmart the company that makes them or are there other options?
It's kinda hard searching on ebay because I get a ton of results for Aruino Uno or Mega, which are shields and other accessories.
So, I can't really figure out, how much they should be.

What do we do displaywise? Do we directly try for a readout on the android phone? Or should I buy a display? If I buy a display, it would be nice to make it one that is large, flat and rugged enough so I could use it on the bike's handlebar for readouts to see what's happening.
I would also like to have some sort of a keypad to be able to have some user input. Can you recommend anything there?
Sensors shouldn't be too expensive. I'll have to get some thing wire to hook them up though (smallest I have here is 2.5mm²)
Are there a so many options for hal and temperature sensors?
This is one of the stores, we have here:

I don't particularly like it because it is too expensive, but the things they have, I can find cheaper elswhere.

Actually, reichelt.com is nicer. You can even save your shopping cart there and share it with other people and they're overall cheaper. I'm going to order some banana sockets from them anyways.

So, what else should I get to start out?

@ Henry. Besides a multimeter, how can I see, if it worked? I see the point of the appeal to be able to use the keypad and output a signal with that. I think both can be pursued at the same time. Right now, the most important thing is to get the basic hardware together so I actually have a chance at success. Without bricks and mortar you can't build a house.

These are two arduino display options I found.
http://www.ebay.de/itm/1-8-128X160-SPI-TFT-LCD-Modul-Display-PCB-Adapter-SD-Card-Socket-fur-Arduino-/170923463903?pt=Bauteile&hash=item27cbd514df

http://www.ebay.de/itm/2004-Character-LCD-Module-Display-Anzeigen-20X4-20-4-204-Zeichen-For-Arduino-NEU-/120972740250?pt=Bauteile&hash=item1c2a89869a

This looks similar to what I want to do in the beginning.

http://www.ebay.de/itm/Neu-SainSmart-Mega2560-Board-Sensor-shield-Module-V5-For-Arduino-UNO-R3-Robot-/221127739226?pt=Wissenschaftliche_Geräte&hash=item337c3d875a

Is this the correct one?

Is Saintsmart the company that makes them or are there other options?

No. They are made by Arduino. The design is open source, so other companies can make clones, but, legally, they must be advertised as such. I wouldn't buy a clone that was not clearly advertised as a clone.

Actually they didn't advertise it as such.
I just thought it was a brand name thing like HTC and QTEK acutally being the same company.

I take it the Arduino Mega 1280 is only half as good as the 2560? :slight_smile: