Flash e-bike Part 6 (Eggrider)

In part 1 of the series, I introduced the background of this particular exercise, and why we're embarking on it. I disassembled the bike and identified the major pieces of its systems in part 2. And in part 3 we looked at the mainboard, figured out what its primary components were, and how they worked. We reverse engineered the BMS, in particular the communication protocol, in part 4. In part 5, we discovered the make and model of the ESC, and figured out our plan for moving forward with the project.

Now, we've received our EggRider in the mail, and it's time to give it a shot. Ideally, we can work out a complete test of all the systems without completely reassembling the bike. To that end, I re-assembled all the pieces on the floor of the garage; near the bike, but not in the frame.

Testing anything that makes use of the motor is tricky because the hub motor is necessarily built in such a way that the center of the hub is not only the stator, but it's also where the wires are routed. If the center of the hub isn't secured, and the perimeter of the wheel isn't free to turn, you're going to have a bad time. For this reason, the only safe way to test the complete system is to utilize the bike.

Eggrider testing

Eggrider provide three connector options: male and female Julet connectors and a weird screw-type version for Rad Power Bikes. As the Flash bike uses Julet connectors elsewhere, I decided to get that variant. If we remember back to parts 2 and 5, the ESC is wired directly into the Mainboard using the round connector at the ESC harness. This connector isn't the same as the other Julet connectors, and I'm not sure what exact kind it is.

Image of the ESC to controller connector, at the ESC end.

I elected to reuse the cable between the ESC and mainboard that came with the bike. The other end of the original cable was the 2x8 pin JST connector. That connector, while appropriate for the mainboard, isn't going to help us with the Eggrider. Luckily, it's pretty easy to get 5-pin Julet extension cables online, and shipped next day.

I cut the end off the purchased Julet extension cable, and terminated it with my typical Amphenol 0.1" header connectors. Then, I used the connector pinout from the Eggrider website and a multimeter to identify which wire in the extension cable went to each pin on the eggrider.

Image from the Eggrider website that shows which pin in the connector is connected to each signal type

I did the same with the original ESC data cable, as mentioned in part 5. Using breadboard jumper wires, I connected Rx/Tx, ground, enable, and B+ between the Eggrider and the ESC. I once again shorted the brake loop.

Testing the eggrider.  The 0.1" header has breadboard jumper wires stuck in it.

To my surprise and delight, the Eggrider powered right up after pressing the power button. The Eggrider is supposed to detect the communication protocol on its own, but in my case I had to tell it "ASI TX/RX swapped" via the app. Their nomenclature about swapping TX/RX was a little odd, as I'm used to connecting TX to RX and vice-versa (as one device transmits to another device's receiver). I think it's likely that this goes back to Eggrider's business strategy, where they assume end-users are their customers. Presumably their customer would just connect wires with the same names together.

Once the Eggrider was booted and connected to the ESC, I could change some settings in the app. These included:

  • Current and max speed for each of the nine assist levels
  • Maximum power
  • Maximum motor phase current
  • Field weakening percent
  • Regen percent
  • Etc...

Not all of these I fully understand (such as field weakening), but it was straight forward enough to get the motor spinning from both throttle and pedal assist!

Custom wiring harness

Now that we've proven the Eggrider works, let's make up a quick wiring harness and try it out. We can simplify the entire mainboard down to a few wires and some heat-shrink. The image below is the existing configuration of the bike, as it's built at the factory. The red "x" marks are where we'll cut the factory cables for the new harness.

Diagram of the wiring before the operation.  The ESC cable goes into the mainboard, along with the brake loop.

I mentioned in the last post that we no longer need the factory cable from the ESC to the mainboard. We can use this cable as a donor, and cut it near the end with the JST connector. Meanwhile, I used the Julet 5-pin extension cable I bought as another donor and cut it in half. Finally, I cut the JST connector off the brake cable. With these three cables cut, stripped, and tinned, I was able to combine them into a single wire harness that completely obviates the need for the mainboard.

Diagram of the new wiring harness.  The communication wires go from the old ESC harness into the new Julet extension cable, and the brake wires from the ESC go to the cut brake cable.

To begin, I gathered the brake and the power ground wires from the ESC cable. These were then soldered to the two wires remaining after cutting the original connector off of the factory brake cable.

The order of these wires don't matter. The brake loop works by having a single wire go to one side of the normally-closed switch on one handle, then from that switches other side to the other brake handle, and back to the connector. This is a safety feature, and ensures that if the brakes are disconnected the motor is inhibited.

I elected to use some abrasion-resistant braid to protect the length of wires to the brake connector. Each wire is individually heat-shrunk, then both of them are joined together and heat-shrunk together with the end of the braid.

close-up photo of the soldering joint for the brake connection

Next, the remainder of the harness is assembled. I soldered them together using the arrangement that I tested with jumper wires. Of course, they were each individually heat-shrunk, and only had to desolder one to put the forgotten heat-shrink on!

Completed soldered wire harness

Finally, I put some glue-lined heat-shrink over the whole thing. The gap between the battery and the side of the frame is pretty small, so while the heat-shrink and glue was warm and pliable I flattened it against the counter. The goal is to make it as small as possible. I thought I took a picture of this, but I must have forgotten.

At this point, we can assemble the bike and try it out!!

Success!

Now... this is the point where I notice that I also don't have any photos of me riding the bike, lol.

I do, however, have a photo of the Eggrider on the handlebar, powered-up, and ready to go. The display appears to be an OLED, so there are scanning artifacts with the rolling shutter of my phone camera.

Image of the eggrider mounted on the bike handlebar.  The display is active.  The display is almost certainly an OLED because you can see scanning artifacts on it.

Not only does the Eggrider work, it works really, really well. At this point, I've put almost 50 miles on the bike, and it's a blast to ride.

I do notice that the ASI ESC isn't tuned to the Bafang motor quite as well as my Rad Power Bikes Rad Wagon. That said, it feels much more nimble and quick because it weighs so much less. There's a noticeable 20khz switching whine from the ESC as well as some kind of commutation noise from the motor. My Rad Wagon doesn't have either of these. If you have a Flash with the factory configuration I'd be interested if your bike does this.

The battery life of the Flash isn't super. It's possible that my battery was damaged from misuse and deep, deep discharge, but it's presently only 30-ish miles of range. I haven't measured the battery life of my Rad Wagon, but I can typically ride 10-15 miles before the battery meter comes of the "full" mark, after which I plug it in to charge.

The Eggrider gives me battery capacity in percentage with single-digit resolution, so you can see smaller changes more easily. I rode it to somewhere approximately 10 miles away once, and I didn't feel comfortable riding it back until I could charge it for a few hours. It seemed like the battery would be dangerously low by the time I got home, otherwise.

While the Eggrider does have an app, it doesn't seem to require the cloud for day-to-day use; it configures the display entirely over bluetooth. I haven't dug into the details yet, but they have a notion of "activation" that is a one-time process of pairing your display to your purchase.

The Eggrider app is mostly a reflection of what's already on the display, but it does include one very cool feature. As you ride, the Eggrider will log your ride and allow you to investigate a handful of parameters. These let you check on your (and your bike's) performance, including things like "Watt hours per mile". It's interesting to compare the flash bike's 12-or-so watt hours per mile to my Hyundai Kona's 4 miles per kwh (or 250Wh/mile). This electric bike is approximately 20 times more efficient than my car!

Screenshot of the Eggrider app showing the Battery SoC, Voltage and Current, and bike speed and altitude

Next steps

We've finally gotten to a point where the bike is usable. A ridable bike was the primary motivation for this exploration. We discovered some interesting side quests along the way, though. There are a few that I still have on my list:

  • Eliminate the need for BacDoor
    • people should be able to convert their bike to use the Eggrider without having to get sketchy windows-only software
    • Figure out whether it's possible to brute-force crack the parameter access codes of the ESC
  • Figure out the protocol used for the head and tail lamps
    • My bike has holes where the lamps used to be because they're still useless
    • Ideally, I can use the existing, well-built, lamps for visibility and safety
  • Figure out whether there's a bypass or brute-force method to the pin code used to "secure" the flash bike
    • Understand the binary protocol of the LCD
    • Understand the I2C interface to the touchscreen digitizer
    • Discover whether there's an attempt counter for the pin
    • Figure out the duration of a pass code attempt
    • There are only \(6^5\), or almost 8,000 possible pins
    • If you can test a pin in less than 10 seconds, you could brute force them in less than a day

I'm definitely not promising to address all (or even any) of these. There's a good chance that I'll move on to other projects. I do have the work of another post complete, so you can count on it being published next week. Then I'll be at RustConf if you want to meet me there. Thanks so much for following along so far!

Keep reading


2021 Words

2023-09-04T16:27:08