I started working on the code. I have to find a cable to hook the board up. I ordered one from seeedstudio today but that will take several weeks to arrive, so I'll probably rig something up temporary before that arrives.

The code I'm working on takes a master key to program the micro to accept other keys. Could use a different master key for master reset to erase all keys, or could use some other technique.

I've been working on the code when time permits. This code uses the Wiegand interface mode which means it will work with lots of available scanners. I ordered one from ebae that is potted and waterproof and ruggedized. The Seeedstudio scanner is just a board and very fragile wire pickup coil, whereas the commercial scanners are more substantial and the cost is about the same, less than $20. It all depends on what you have room for. On the Borg I want something to hide under the existing covers so the Seeedstudio unit might be the best, and possibly epoxy it to the cover, or to a thin PC board that is placed against the cover. On the mountain bike a pre-potted unit might be easier to place somewhere, or perhaps pot my own to make it small and light. It might make sense to put the electronics inside the controller case proper and just have the pickup coil mounted outside the controller, perhaps on the controller.

The Wiegand interface is a three wire interface with ground and separate clocks for zero and one. It is very simple and fairly timing independent. It can be run through a very long cable between the scanner and decoding microprocessor, though that is hardly needed on an ebike. There are often a few other wires on the commercial units for LED indicators and a buzzer. Using this interface opens up a lot more hardware compatibility as the commercial systems use it. The other option with the Seeedstudio board is serial. There is a jumper to select between them on the board.

There are two easy ways to put keys into the software of the micro. One is to type in the number printed on the key and compile that into the software. The other is to scan the key and have the software store it in the nonvolatile memory in the processor. I'm setting up my software to have options for both techniques.

At this point the software is using about 4K of the 32K code space available in the small Arduino. This makes it suitable to fit in an 8 pin ATTiny85 CPU if needed. The Arduino is an easier development platform and allows me to have an LCD display for debugging. The final system won't really need a display, one LED should be sufficient.

Another feature I put into the software is a "running" timeout, after a few hours it shuts off the controller. This is useful in case things get left on accidentally. It resets each time the power is cycled on. I set it for four hours, but that could easily be changed. I never operate my ebike in one session for that long, the batteries won't last that long anyway if the motor is consuming more than 350 watts on my 1.4KWH pack. It would also be easy to add an LVC shutoff to this design. Since it is controlling the master power switch it might be a good place to do that. Not to replace the CA functionality, but to back it up. The CA will cut off the throttle, while this can cut off the power to the controller and other loads to preserve the battery.

Received a USB reader from eBae, this really makes it easy to put the codes for the keys into the software. When you swipe a key it types the code and a carriage return in. These USB readers are cheaper than the others, too.

It also allowed some testing of key range. The cards had twice the range of the keyring fobs, not surprising since the antenna coil can be larger.

Also received a pack of 10 key fobs from eBae, they were an experiment to see what $2 for 10 looked like. They appear to be well made and all scanned perfectly. Lots of low cost keys for these 125 khz RFID readers!

I tried to read the ID badge from work into the Windows USB RFID reader but nothing happened, so apparently it is not 125 khz.

Input/output (bike main battery) voltage 30 to 110V (may require some adjustment over the range)
Output current 300 mA (to power controller or enable Main Power Control board)
Quiescent current less than 1 mA (after 10 second unlock window)
RFID interface: power out (40 mA max), Wiegand in 1/0, ground (4 wires)
Controls 5V power to the RFID transceiver board, turns on for a limited unlocking time window
Output: connects to one of:
Master Switch board or Motor Controller Logic Power input or Battery Management Board (future)
Useable in different configurations for versatility

Design Plan, subject to change

+ battery feeds input from Kill switch when set in "operate" position
use FET pre regulator (shown earlier in this thread)(linear)
secondary regulator low quiescent current 5V
microprocessor attiny44/84
output via latching relay
micro outputs power to Wiegand RFID reader and reads codes back for a limited time at power-on (10 seconds)
re-cycle power off then on to enable RFID reading again
if proper RFID code detected micro enables relay outputting +battery
micro powers down RFID and itself after the 10 second window
If bike is powered on, after 4 hours micro powers bike off (use timer to minimize micro power consumption)

Here is a quick layout of the RFID Keyswitch board, not final, needs some tweaking and parts adjustment.

Size is 1.6 by 1.9 inches, a bit under 3 square inches total.

Connectors:

J1 connects to the Kill Switch
J2 to the bike main battery
J3 is used to program the onboard microprocessor
J4 to the SeedStudio RFID transceiver board or equivalent
J5 connects to the Main Power switch board
J6 will connect to the future Battery Management board

One of the problems with an RFID subsystem is that it needs to come on first, before anything else is turned on. So there is only the bike battery at 36, 48, 72, or 104 volts to power it (readily available). I don't like to play games like tapping lower voltage out of the battery, so I need some way of dropping the voltage.

I found one linear regulator chip that will take 100 volts, but it can't handle much current since it would get too hot. For example, a regulator dropping 100 volts at 10 milliamps will be dissipating 1 watt! The RFID circuit needs up to about 100 milliamps peak, so a linear regulator is not a good fit. Presently that's what I have on the board design, and it probably will work, but it is not great and it might get fairly hot for a short time. Workable, but can we do better?

I started doing some searches for simple switching regulators for 110 volts to 5 volts at 100 milliamps. I found one new part from Linear, an LTC3639 that will do up to 150 volts and 100 milliamps and has very few external parts! However this part is apparently too new since no supplier has any, and the cost per chip is fairly high.

Back to the search engines, turning up the National LM5009 which is good to 100 volts and 150 milliamps and is available and costs a couple of dollars. More like it, though it won't quite do 24S. But it will do up to 20S which is good enough for lots of ebikes, so maybe I'll try that to start with.

If anyone has better suggestions, let us know! I've not done that much searching yet, surely there are more parts out there. I'd like to cover the range 30-110 volts DC and 100-150 milliamps output at 5 volts. Minimum external parts count, low quiescent current and cost, yadda yadda.

I'm finding lots of 100V switching regulators: LM5019, LM5018 and LM5017. These differ in the amount of current available. 0.1/0.3/0.6 amps respectively.

These are synchronous (no diode required) and need about a dozen external parts (R, C and L). The earlier LM5008 series requires an external diode in addition to a similar number of external parts. Both parts are about two dollars in small quantity. The 5019 series is a bit harder to solder with a central power pad. None of these parts are available in through-hole styles.

Arlo1 wrote:I just got a RC522 for setting up a Key switch with this. I am not sure of the rest I guess I have a lot of reading to do.

Hi Arlo. The RC522 is a Mifare system which is different from the one I'm using. It appears to have several protocols for talking to it. The board I'm working on will probably be able to work with it but it will require different software at least.

The LTC3639 switching regulator is really a good fit for this application, up to 150V max input, up to 100 mA output at 5V. It only requires about 3 external parts to work, a coil and a couple of caps. For some reason no one has any stock though. Lots of suppliers list it, and the part came out awhile ago, so I'm wondering if there was some problem with them? Searching hasn't turned up anything about that yet.

The other parts I've found are mostly 100 volt max and require more external parts.

For this project we need around 50 mA for a short time, and really low quiescent current when not operating the RFID. The LTC3639 has a low quiescent current of 12 uA! We should be able to get close to that when the micro and RFID transceiver is shut down. At 12 uA it would take 9.5 years per amp-hour to drain the batteries. So leaving the kill switch on after the bike is shut off would not matter much.

A question for folks following this thread. How long after turn-on should the RFID shut down the bike? For example, if you turn the bike on, ride somewhere, and forget to turn it off, how long should it stay on? The RFID doesn't know whether the bike is in use or just sitting, so this timeout would be blind. Unless we added a motion sensor to the RFID board, or a current or throttle sensor so it could detect "in use". I was thinking of making this timer 4 hours, but it would be nice if it was smarter or could use a shorter timeout. I suppose the RFID board could monitor the system voltage and look for change there as an indication the bike was in use, but is this good enough?

This switching regulator is surface mount, but the rest of the parts are thru hole.
The earlier design has linear regulation, but I'm concerned about overheating of the linear reg, so I am looking for a different solution.

They have a couple other units which are either discontinued, or going to be, so the Grove unit is the one that will apparently remain.

Ebae also has units like this in the $5-15 range. Power requirements vary, some require 12V and the current levels vary. This is a problem as developing much current at 5 or 12V from the 30-110V bike main battery is a bit difficult. Linear regulators develop a lot of heat, and we want low quiescent current as well. The board-level products are probably the best choice for low weight and power requirements, but they are a bit fragile and will require some packaging for the ebike environment.

Here's one on Ebae that is small, low power, low cost, and weather sealed that may be good for eBike use:

Search for Mini Wiegand26 Weatherproof RFID Reader 125KHz if the above link doesn't work. This unit takes 20 mA at 12V which is a nice low current, but it is an extra voltage that needs to be generated.

There are several types interfaces to these boards that the micro needs to be able to talk to when reading the tag code. The three I've seen are Wiegand, Serial (UART), and I2C. All of those are possible with two wires (Serial/UART takes only one wire). Serial/UART type devices require a calibrated clock, Wiegand and I2C do not. I'm leaning toward Wiegand since calibrating the clock is not something everyone can easily do. But with minor code changes one board can handle all these modes.

I need to measure the current the little Seeedstudio RFID boards require. They operate at 5V so don't need to generate another voltage. If their current demand is low enough the circuit as designed with linear regulators may work, but the time the RFID is active will have to be short as the linear regulator cannot deliver 50 mA for long - that is 5 watts of heat on a 100V ebike!

If the switching regulator chip is the only surface mount part, folks might be able to solder it with a small pencil. It adds some challenge, but it is not impossible. Still, the difficulty, complexity, and low availability of this switching regulator chip are concerning.

I'll look further into the regulator situation. It is the biggest holdup on this board, though some system choices also need to be finalized so I can determine the connectors and pinouts. The present design is all through hole (see rendering above), with 2 stages of regulation.

Here is the new version, slimmed down, simplified, all through-hole, and with linear regulation. KISS = Keep It Sweet and Simple.

Board is about 1.5 by 1.6 inches, and 2.4 square inches.

J1 is power in from Run/Kill switch at full battery voltage (only on when running)
J3 is programming jack, used to load software into the micro, just pads (no actual connector)
J4 is RFID receiver, 5V up to 40 mA, Wiegand or Serial/UART
J5 is Power Out (when unlocked) to Main Switch Board, or power the controller (logic only), up to 200 mA at battery voltage
J6 is dry relay contacts SPDT (no power, etc, just direct to the second set of contacts on the relay)

Output is Relay DPDT dual coil latching type, so once the key is "open" the relay is latched and does not require power to stay there. The micro will power down and very little power will be consumed after the initial search for the RFID key.

Microprocessor is ATTiny 24/44/84 family in DIP package (2K/4K/8K flash memory size), and there are 2 unused pins on the micro at this point.

The way this will work:

1) Turn on the Run switch, this applies power to the board
2) Micro wakes up, opens relay, powers up RFID receiver and looks for keys
3) Swipe the RFID key within the time window (say 10 seconds)
4) If key is good relay closes and applies power to bike, if not it keeps listening
5) After unlocking or timing out micro shuts down RFID and itself to minimize power consumption

Power consumption when Run/Kill switch is off is zero
Power consumption when Run/Kill switch is on is high for the time window, 50 mA = 5 watts on a 100V bike (depends on RFID receiver power, may be less)
Power consumption after window (running or locked) is low, depends on a few things but should be less than 1mA, possibly a lot less