Go Down

Topic: Getting starte: My first project: Cruise control for ebike (Read 9271 times) previous topic - next topic


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.


Oct 14, 2012, 12:59 am Last Edit: Oct 14, 2012, 01:04 am by PaulS Reason: 1
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.


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?


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 ;-) )
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.



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? :-)


Oct 14, 2012, 03:49 am Last Edit: Oct 14, 2012, 04:04 am by Deus_Ex_Machina Reason: 1
Could we use this one here?


or this one


the general development cycle is to develop on a large chip and the produce on the right chip.

for what you do, 8kb flash would be sufficient.


Oct 14, 2012, 01:02 pm Last Edit: Oct 14, 2012, 01:16 pm by Deus_Ex_Machina Reason: 1
so here we go:
This should be ok to start. Large enough LCD to play around with.
What do we do for button input?
What sensors will I get? Will any do fine that produce analog signals?


Apart from the touchscreen, is this any differen? I might aswell get this one so.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131