ArduEbike - Arduino Ebike projects

Alan B

100 GW
Joined
Sep 11, 2010
Messages
7,809
Location
San Francisco Bay Area, USA
I see a lot of folks mentioning using an Arduino on their ebikes. I haven't seen many actually do it, but I'm sure they are out there.

Some folks are wondering, what is an Arduino? Why is it interesting for the ebike?

Arduino is an open-source small microprocessor hardware and software system for hobbyists and prototyping small systems. There are many vendors making low cost hardware and free software for this system. It is designed to make it simple to program and use. The development tools are cross platform and run on Windows, Linux and MacOs.

So what would one do with Arduino on an ebike? A typical Arduino (the Uno) has a half dozen Analog Inputs and 14 binary input/output pins of which 6 can output PWM. The analog inputs have 10 bit resolution (0..1023). Most projects involve reading some sensors or other inputs and generating some outputs, or logging information for later review. Measuring voltage, current, temperature, tilt, multi-axis acceleration, compass heading, GPS position, speed, time, hall sensors, switch, button or rotary encoder inputs, throttle input, RFID tag readout, etc. can enable various functionality to be implemented. Numeric, Alphanumeric or even Graphical displays can be interfaced. The excellent Cycle Analyst is one example of what one could do with Arduino. While there is no reason to merely duplicate the CA, one can imagine a customized version that has other features and functions. Another use is to capture the output of the CA via the serial stream and implement other functionality while using the CA.

The processors generally run at 16 mhz and have various amounts of reloadable flash memory for program storage from about 16K to 256K. There are smaller boards and larger boards to fit various project needs.

The programming environment is simple to install and use. There are lots of examples and help files and helpful forums on line to answer the inevitable questions that arise. The programming language is C with a little C++ if creating libraries. They have boiled it down and given lots of examples to look at that makes it a lot easier to get started.

The programs load into the board over a serial link which is a USB connector on most of the newer boards. But you don't worry about the details, just click on the download board button and the programming is automatically compiled and loaded into the board. The tools use the Gnu C compiler which generates very good, fast and small code for these microprocessors. So you can fit a lot of code in there if you need to.

There are many plug-in boards that have additional functionality to tailor the Arduino for your project. These are called Arduino "shields". Some are mostly solder pads for user customization while others have various displays, buttons, small motor drivers, sensor inputs and more. Some are designed to be sewn into clothing. Search ebay or the internet for Arduino to see more examples.

The Arduino project has generated some new terminology that is not instantly familar to most, but the ideas are simple and the implementation clean. Once a few terms are understood their documentation makes a lot more sense. For example a program is called a "sketch". They probably are trying to make it simpler, but it adds a little confusion when you first read about it.

Links

www.arduino.cc
www.sparkfun.com
www.adafruit.com
www.ebay.com
www.amazon.com
many more...

Thread Table of Contents

to go here later...


So, what are folks already doing with Arduino on their ebikes? Might be nice to see some photos of Arduinos on Ebikes.

What are folks planning to do??
 
Just noticed this - Call to post, will get into some of my Arduino projects here and post the code up to google code or sourceforge for all - including the dual controller management system I use for off road (since winter is coming) all wheel drive hub systems... While I can't offer a ton of time supporting any of these projects - I do put pretty damn good comments into my source, it should be straight forward enough for anyone...

When I call out an Arduino mini or x,y,z shield - I'm only prototyping, after that it's off to Protel Designer 99 SE for the schematic recreation, virtualization, board layout and then CAM files export to a board manufacturer I've used for years for prototype PCBs... Followed by an order from usually two of the various electronics superhouses - digikey.com, mouser.com, etc... for the raw Atmel chips (Smt where possible) which I then populate on arrival and load my final code..

The beauty of sheilds - it's like capsula, erector sets, heck bionix legos too.... plug and play working electrical sub systems to piggy back onto a primary Micro Controller and who knows what else... turns an idea into functional testing within hours if not minutes and then allows a consistent schematic package and board design in a CAD package to turn the prototypes into one offs but suitable for semi commercial production.

The one thing about arduino prototype boards (and using sketches) is that some resources are used by the "runtime", they could and in some cases are critical to our needs in "SUPER CONTROLLER CONTROLLERS", "ECM", logging, etc...

Well enough until I grab together some code and post...

Regards,
Mike
 
One interesting place to go to for some arduino stuff is http://adafruit.net ; there are forums there with some interesting projects, some of which are bicycle-related (plus things like the SpokePOV whcih are interesting for other reasons).
 
mwkeefer said:
Just noticed this - Call to post, will get into some of my Arduino projects here and post the code up to google code or sourceforge for all - including the dual controller management system I use for off road (since winter is coming) all wheel drive hub systems... While I can't offer a ton of time supporting any of these projects - I do put pretty damn good comments into my source, it should be straight forward enough for anyone
...
Hey Mike, why not just zip it and post here as an attachment? I did here
 
I use these to teach some of my undergrad students the basics of control and embedded system concepts (they are comp sci students with little-to-no electronics knowledge). Not particularly robust, but they make up for that in cheapness.

Im about to use one with a bluetooth shield (a cheap 10 quid job sourced from China I think) as a wireless immobiliser and to set the max motor power depending on whether my phone is within range or not.

Although quite capable of designing an application specific pcb, I probably won't cos I can never be bothered...

Cheers,
Chris
 
Because zipping and attaching would loose any contributions if not in some src repository of code, trust me... Been doing this > 20 years (open source and shared common development codebasea).

Plus as I've tried to elude to, many of my projects run on arduino platforms but don't use sketches, just raw c++ code :)_

Finally - it will require me to sit at my desktop for about an hour to collect all the bits and projects and post em, a tad difficult from the iDevices ive been on since I noted the post :)P

Regards,
Mike
 
Alan B said:
Amberwolf, you might post a link in this thread to your adafruit thread on the ebike project you were considering. Lots of good ideas in there, even though it was not Arduino it certainly could be.
Sure:
http://www.adafruit.com/forums/viewtopic.php?t=7346#p36056

Also, some non-arduino stuff that could turn into ebike goodness with some work:
http://endless-sphere.com/forums/viewtopic.php?p=338620#p338620
and a non-arduino dev unit that could be useful at only $15:
http://www.st.com/internet/evalboard/product/252419.jsp?wt.mc_id=enews_dec11_stm32f4discovery
 
mwkeefer said:
Because zipping and attaching would loose any contributions if not in some src repository of code, trust me... Been doing this > 20 years (open source and shared common development codebasea)
...
Thanks Mike, it makes sense if the code is complex, has many different contributors or wanting to maintain a history of code changes.
 
I have some code for RFID.. but no one needs RFID.. :roll:

I posted a thread a while back on collecting ARduino code in one place and working together to write new code, but that didn't take off because no one cares or has time.

Thanks mike for offering yourself up. I'd like to see what you came up with for the 2WD especially..
 
Could someone use Arduino to create & control a self balancing rear wheel direct drive hubmotor ebike that could a wheelie at the touch of a button?

That's something I'd like to see (and ride!)
 
Gyro will work best... But will not account for curvature of earth... Or change in grade of the road. Not really a big deal ... Just bad idea starting a wheelie up hill...

Accelerometer would be nice for error correction over shorter intervals.

In feb I will try to work on this... But it's not as hard as people think (try it yourself) to write. Main issue is trying not to burn out your motor... Once u are in balanced mode you need to have indicators to show how much load you are contributing by leaning the wrong way... I envisioned a row of LEDs that functioed similarly to the manualijg balancing indicators in skateboard video games.

Lots of torque would be needed, and I imagine this would work best above 10mph when the motor isn't as much of a space heater.

It would be nce to lean back and let motor initiate the wheelie, especially on heavier bikes or bikes with a large tire diameter, where it is very difficult to control or initiate a wheelie. I was planning on zeroing the throttle at balance point so that the speed could be controlled while maintaining the wheelie

Safety first
 
eBike Controller Programmer

DSC_5557.JPG
 
eBike Controller Programmer Progress Report

I have written and debugged the user interface and parameter calculations and management code for this project. The code to write to the controller is mostly written but not debugged, and the interface cable has not been constructed.

The code is taking about 30% of the flash program memory on the chip, so there is room for more features, though I'm keeping it simple. This is an impressively small footprint considering it has floating point calculations included - these Atmel processors are very efficient and the compiler generates very small code. It has 10 nonvolatile memory sets for holding sets of motor parameters, and it is simple to change a parameter or reset a memory to defaults. So far it only has one controller configuration, but I plan to put in a few for controllers that I have.

The setup consists of a Robot LCD/pushbutton shield, an Arduino UNO, and I will be adding a Proto Shield to connect the programming cable to. The three boards stack together for easy and compact assembly. There should be no need of the usual pushbutton in the cable for programming as the CPU can detect the controller's off state and then turn the 5V and I/O signals to the controller on, do the programming and then turn them off.

Credit goes to people and information here on ES about how this programming works, and in particular to Anpaza's XPD for a working example. This program uses no code from XPD, but it does use some of the conversion factors to convert from raw values to voltage and current.
 
Ebike Programmer Progress

Expanded the code to handle 10 different sets of controller parameters, and 25 memory slots for parameter sets. Now using 9K of the 32K program memory. Source code is about 700 lines.

Next is to flesh out the serial interface and programming code and make a cable.

edit - added the serial library, now up to 12K of available 32K.
 
I just got another arduino to do all my motor temperature monitoring and water cooling flow/fan rate adjustments. One of the things I want to be able to do is to simply store temperature data. I know this can be done with things like the drain brain... but this is more optimized and possibly cheaper. Just need an interface to an SD card OR I could just buy a small netbook and get tethered serial stream through the GUI.. It'd be nice if I could do that through my iPhone or iPad..... I think there's a small memory bank on the UNO, correct? One that you can write to for simple logging?
 
There is 1024 bytes of eeprom in the Uno that can be used for logging. That's what I'm using for parameter storage. It writes a byte in about 3.3 milliseconds.

There are SD (and microSD) card interfaces and libraries.

There are EEPROM memory chips with more space and I2C interfaces.

The SD (or microSD) card interface might be the way to go. Be easy to pop out and read elsewhere.
 
yeah... if I log at 1Hz then I will be able to use my chip for around 280 hours. that's not bad. I'm going to be up late I guess. :mrgreen:
http://tronixstuff.wordpress.com/2011/03/16/tutorial-your-arduinos-inbuilt-eeprom/
 
Back
Top