How the PedalPC Works
11 Nov 2019 - Jim Gregory - ~11 Minutes
The PedalPC is composed of six parts:
- desk frame
- control board
- power sockets
- single-board computer
Each part is described below, followed by a brief description of the software that controls the desk.
The desk frame is made mostly of 1”x2” / 25x50mm anodized aluminum rectangular tubing. I chose this material because it is rugged, lightweight, rustproof, and doesn’t need painting.
I tried several different seating positions, from fully upright (like sitting on a bicycle) to fully recumbent. I found a semi-recumbent, chair-like seating position to be the most comfortable for typing and pedaling at the same time.
Sitting for long periods while pedalling can be uncomfortable, especially when your hands can’t be used to help bear your weight like on a traditional bicycle. I tried more than half a dozen commercially-available bicycle saddles, but never found one comfortable for this application. I ended up making my own, patterned roughly on a recumbent exercise bike I found comfortable. I sew each seat using (what else?) a treadle-powered sewing machine.
The frame folds up to make it easy to move from one location to another. Wheels on its rear legs allow it to be rolled on the floor when in the folded position. The machine weights about 54 lbs, and can be carried by one person if necessary.
The generator I’m currently using is a modified Bofeili 36V 250W mid-drive electric bicycle motor. Six Schottky power diodes mounted on the control board rectify its unregulated, three-phase AC output to DC.
(Unfortunately, Bofeili appears to have gone out of business. I’m currently evaluating other generators.)
Any permanent-magnet motor will generate electricity when it is driven; the challenge is getting it to spin fast enough to generate usable electricity. Most people pedal at a relatively slow cadence (40-80 RPM) when using a bike desk. Most motors, however, need to spin much faster (usually > 3000 RPM) to generate significant amounts of electricity at a useful voltage.
Electric bicycle motors are designed to rotate at a speed much closer to a bicyclist’s cadence. They are rugged, efficient (usually > 80%), relatively compact, and brushless (which reduce noise and maintenance). For this reason, I have mostly used electric bike motors for the self-powered desks I’ve built.
There are two types of electric bike motors, hub motors and mid-drive motors. Hub motors are built into the front or rear wheel hub of a bike. Mid-drive motors are built into the bicycle’s crankset, in the middle of the bike (hence the name). Both work well as human-powered generators.
Hub motors usually cost 1⁄3 to 1⁄2 the price of a mid-drive motor, but when the cost of the extra hardware required by a hub motor (bottom bracket spindle, cranks, chain, and sprockets) is included, the cost difference isn’t as significant. A hub motor generator requires more space, since the motor and cranks are separate units. It also needs to be enclosed to prevent electrical cords getting caught between the chain and sprockets. (I speak from experience!)
Earlier PedalPC versions used a hub motor; later versions used a mid-drive motors to make the desk more compact and portable.
A mid-drive motor requires some modifications to be used as a generator, since due to the way it is built, its cranks won’t drive the motor.
A mid-drive bike motor has five parts: the crankset, motor, two freewheels, and drive hub holding the chainwheel. Since the chainwheel isn’t driving anything when the motor is used as a generator, the chainwheel is removed.
As you may recall, a freewheel is a mechanical device that transfers rotary motion in one direction only, either clockwise or counterclockwise, depending on the direction it is mounted. One of the bike motor’s freewheels connects the cranks to the drive hub. The other freewheel connects the motor to the drive hub.
Here’s how the parts work together on an electric bike. When the bike’s motor is on, the motor freewheel is engaged and drives the drive hub, while the crank freewheel disengages the crank. This allows the motor to propel the bike without the cyclist needing to pedal.
When the bike’s motor is off, the crank freewheel engages the cranks with the drive hub, while the motor freewheel disengages the motor. This allows the cyclist to propel the bike without the added drag of the motor.
Notice if the motor’s freewheel was engaged, then the cranks would drive the motor via the drive hub, allowing it to function as a generator.
There are two ways to achieve this. I have tried both. Both methods work.
The first and easiest method is to mount the mid-drive motor assembly backward on the frame, so the right side is now on the left. This reverses the direction of engagement for both freewheel relative to the direction of crank rotation. Now, the drive hub will drive the motor when the hub is rotated in the same direction as the cranks. However, since the crank freewheel has been rotated, too, the cranks will no longer drive the drive hub! A simple fix for this problem is to mount a pin externally on the drive hub. When the cranks are pedalled in the forward direction, the left crank will strike the pin and rotate the drive hub.
The second method is to disassemble the motor assembly and weld the sprocket on the motor freewheel’s hub to prevent it from freewheeling. This method is necessary when there is no easy way to mount a pin on the drive hub.
A buffer is required between a pedal-powered generator and its load. That’s because a pedal-powered generator’s power fluctuates with each pedal stroke, and also because the power demands of the equipment it supplies fluctuates, too.
The PedalPC uses a 12V lithium-ion phosphate (LiFePO4) battery wired in parallel to the generator for its buffer. I chose a LiFePO4 battery because it is safer and more rugged than a lithium-ion battery, and smaller and lighter than a comparable lead-acid battery. It also has a long lifetime, maintaining up to 80% of its capacity over 2000 discharge cycles. (The battery on the machine I am currently using is over 3-1⁄2 years old.)
The battery has a rated capacity of 120 Whr. This means it can store enough energy to power a 12 W laptop for about 120 Whr / 12 W = 10 hours, or a small 5W modem + web server load for 120 Whr / 5W = 24 hours. These are theoretical values; actual values are probably somewhat less.
The length of time required to recharge it depends on how much surplus power you are producing. I usually produce about 20 W of surplus power while I’m working on my computer, so it takes me about 120 Whr/ 20 W = 6 hours to fully recharge a dead battery.
The control board manages the power flowing from the generator through the battery, power sockets, and cooling fan.
The generator is connected to the board through a relay, a type of electrical switch. When the battery voltage nears its upper limit, the relay opens to prevent damaging the battery and any loads connected to the PedalPC.
The power sockets and cooling fan are connected to the board through power MOSFETS, another type of electrical switch that uses less power than a relay. If any device plugged into a power socket draws too much current, its power MOSFET turns off to prevent damage. If the battery voltage drops too low, all the the power MOSFETs are turned off to prevent draining the battery.
A bicolor LED built into the front of the desktop provides a simple indicator of the board’s status. When you are charging the battery, the LED is green. If you pedal too slowly to charge the battery, it turns orange. If this continues for more than a few seconds, it starts blinking red to alert you to pedal faster. If you pedal too fast, it rapidly blinks an alternating green and red pattern.
If you stop pedalling entirely, it slowly blinks once every 10 seconds to remind you the battery is draining. In this state, the battery’s state-of-charge determines the blink color.
The board is constrolled by a Microchip PIC 18F45K42 microcontroller. Sixteen of the 18F45K42’s analog-to-digital (ADC) converters measure current and voltage. Power is calculated is from these measurements.
Device current is calculated by measuring the voltage drop across eight current sense resistors (one for the battery, one for the cooling fan, and one for each of the six power sockets). Since current is conserved, the generator’s current output is the net sum of all the measured currents.
I solder each board by hand using a portable soldering iron. The soldering iron is powered by batteries recharged using the PedalPC.
The PedalPC’s power output is fed out through four 5V DC USB power sockets and four 12V DC automotive power sockets.
There is an additional header on the control board for supplying power to a personal cooling fan.
The PedalPC has no built-in AC power sockets. To power a laptop or other piece of equipment, an adapter is usually required. The adapter is plugged into the socket, then the device plugged into the adapter.
The reason I designed it this way is because a human being can only produce a limited amount of power, and each time power is converted from DC-to-AC or AC-to-DC, some of that power is wasted.
Most equipment capable of being powered by the PedalPC (laptops, phones, modems, printers, etc) actually use DC, not AC. The DC is supplied by an AC-to-DC adapter (aka “wall wart”). To get the most power out of the PedalPC, it is best to bypass these adapters and power the equipment directly from DC.
Many modems, monitors, and battery chargers requiring 12V DC input can be from the PedalPC’s power socket. No adapter is necessary, just a 12V DC power cord. Equipment that operates at other DC voltages will require a DC-to-DC adapter, usually sold as “car adapters”. Laptops, for instance, usually operate at more than 12V DC and will need a laptop adapter. USB-powered devices likes phones and tables operate on 5V DC and can be powered from the USB sockets. Other equipment that require 110V AC because they lack an external power adapter can be powered using a 12V DC-to-110V AC inverter.
A low-power single-board computer (SBC) connected to the microcontroller’s serial port generates a dashboard you can view using a web browser. The dashboard is accessible from any computer or phone on your local network. If no network is available, it creates a wifi access point to which you can connect instead.
The dashboard displays the current power output of the generator and each device connected to the desk, current session statistics (elapsed time, total energy generated, and approximate calories burned), battery status, and the average power output and total energy produced for each of the past 7 days. It also plots a minute-by-minute graph of each device’s power consumption, to easily see how much energy each device uses and how it changes over time.
You can also turn devices on and off via the dashboard and control how long they will remain powered if you stop pedaling.
Reading and displaying this data imposes minimal overhead on the SBC. This allows the SBC to be used simultaneously for other tasks if desired, making them human-powered as well. These could include a web kiosk, NAS device, VPN gateway, Nextcloud host, or a self-hosted web server. (The web site you are viewing now actually came from a web server running on my SBC through a CDN).
I actually used the SBC as my desktop computer for several months while designing the latest version of the PedalPC. I used it to design the CAD drawing for the desk, layout the PCB, write the server software, and write and flash the microcontroller firmware. It performed these tasks adequately well, but does poorly on complex web sites and streaming videos.
The firmware on the 18F45K42 is written in Great Cow BASIC, an open-source implementation of BASIC for Microchip PIC and AVR microcontrollers. The program was compiled each time directly on the SBC from the command line and flashed to the microcontroller over the SBC’s GPIO pins using Darron Broad’s excellent Pickle ICSP software.
If you have any questions about the PedalPC or are interested in one for yourself, please contact me.