adrian_sm
1 MW
Update: Brain Box - Musings
Now that I found a cheap Arduino board with a USB connection, I have rethought the need to make my own board in the long run. As this little device seems to have everything I want, at a very reasonable price, and most of the external wiring doesn't require a lot of extra components to work.
My current thinking is to just use the Arduino Nano linked above, programmed and wired up to my specifications ready to run, as the Brain Box. It would come complete with shunt, wheel sensor, PAS sensor, temp sensors, throttle inputs, etc., in an protected enclosure.
But then I want to give the ability for users to adjust some of the settings. Of course I could just hook up a display (with associated cost and hassle), but didn't want this to be required for reprogramming. I'll leave this as a future upgrade option and stick to my bare bones minimal approach.
So rather than share the "sketch" / code, I will just allow the user to communicate to the brain box via USB and a terminal program/serial monitor. This let's me protect my base code, ensures people don't tweak things beyond what I deem acceptable for the drive, and could be locked down to be faithful to the local laws.
It would work something like this.
1) hold down the throttle button & connect the brain box to the computer via USB
- this will enter the device into a set-up mode that starts communication over the USB
- then the user will need to start terminal or the serial monitor in the Arduino software, and set it to the correct baud, port etc.
2) Then the user will be presented with a number of set-up options, one after the other, like:
- Min speed (rpm)
- Max speed (rpm)
- PAS (On/Off)
- Throttle type (1=button, 2=pot, 3=hall)
- Throttle logic (1, 2, 3, 4, ...)
- Battery type (1=LiPo, 2=LiFePo4, 3=...)
- Battery voltage (0=auto, 1=1s, 2=2s, 3=3s, etc)
- LVC (per cell voltage)
- Max Power (watts)
- Ramp up rate
- Ramp down rate
- etc.
All settings would be stored in the EEPROM, so I could get it to show what the existing setting is, and if people don't want to change it they just hit enter.
I guess I could also implement a service menu that is password protected, to open up more options like convert it between unlimited,EU,AU,USA legal modes.
If I need to get people to update the base code themselves, and I still don't want to give away the Arduino sketches, I might be able to actually compile it myself into a hex file, and give instructions on how to program the brainbox using avrdude, which is what Arduino uses in the background.
This overall approach seems like the best compromise at the moment, uses more off-the-shelf hardware, gives user programmability with a simple usb cable and terminal program, plus the ability to update things in the future if needed.
The downsides I see are that if I release the HEX files, people can just build their own hardware and use my software for free.
And even if I don't release the HEX files, people can still reverse engineer the code if they buy the brain box and are tech savvy. Maybe I can program it via Arduino then set the fuses to stop people from reading the code. Hmmm will have to check that out. But if I do it right, and get the price right it will just be cheaper/easy/better for people to buy the complete brainbox from me, than stuff around sourcing all the bits and pieces, working out the right schematic, wiring it up, programming it etc.
What do people think of this overall approach? Sounds like it might work to me.
- Adrian
P.S. Just thinking about it a bit more I could get the Brain-Box to record same basic info too that is displayed when connected in setup mode. This is the sort of summary data a CA or display would usually show/record. It would require a lot more code, but it could record trip & total stats like:
Last Trip Stats
- peak power
- average power
- % assist
- wh/mAh used
- distance travelled
- assisted distance
- wh/km during assist
- wh/km overall
- Max amps
- Min voltage
Life Stats
- # rides
- total distance
- total wh
- .....
Now that I found a cheap Arduino board with a USB connection, I have rethought the need to make my own board in the long run. As this little device seems to have everything I want, at a very reasonable price, and most of the external wiring doesn't require a lot of extra components to work.
My current thinking is to just use the Arduino Nano linked above, programmed and wired up to my specifications ready to run, as the Brain Box. It would come complete with shunt, wheel sensor, PAS sensor, temp sensors, throttle inputs, etc., in an protected enclosure.
But then I want to give the ability for users to adjust some of the settings. Of course I could just hook up a display (with associated cost and hassle), but didn't want this to be required for reprogramming. I'll leave this as a future upgrade option and stick to my bare bones minimal approach.
So rather than share the "sketch" / code, I will just allow the user to communicate to the brain box via USB and a terminal program/serial monitor. This let's me protect my base code, ensures people don't tweak things beyond what I deem acceptable for the drive, and could be locked down to be faithful to the local laws.
It would work something like this.
1) hold down the throttle button & connect the brain box to the computer via USB
- this will enter the device into a set-up mode that starts communication over the USB
- then the user will need to start terminal or the serial monitor in the Arduino software, and set it to the correct baud, port etc.
2) Then the user will be presented with a number of set-up options, one after the other, like:
- Min speed (rpm)
- Max speed (rpm)
- PAS (On/Off)
- Throttle type (1=button, 2=pot, 3=hall)
- Throttle logic (1, 2, 3, 4, ...)
- Battery type (1=LiPo, 2=LiFePo4, 3=...)
- Battery voltage (0=auto, 1=1s, 2=2s, 3=3s, etc)
- LVC (per cell voltage)
- Max Power (watts)
- Ramp up rate
- Ramp down rate
- etc.
All settings would be stored in the EEPROM, so I could get it to show what the existing setting is, and if people don't want to change it they just hit enter.
I guess I could also implement a service menu that is password protected, to open up more options like convert it between unlimited,EU,AU,USA legal modes.
If I need to get people to update the base code themselves, and I still don't want to give away the Arduino sketches, I might be able to actually compile it myself into a hex file, and give instructions on how to program the brainbox using avrdude, which is what Arduino uses in the background.
This overall approach seems like the best compromise at the moment, uses more off-the-shelf hardware, gives user programmability with a simple usb cable and terminal program, plus the ability to update things in the future if needed.
The downsides I see are that if I release the HEX files, people can just build their own hardware and use my software for free.
And even if I don't release the HEX files, people can still reverse engineer the code if they buy the brain box and are tech savvy. Maybe I can program it via Arduino then set the fuses to stop people from reading the code. Hmmm will have to check that out. But if I do it right, and get the price right it will just be cheaper/easy/better for people to buy the complete brainbox from me, than stuff around sourcing all the bits and pieces, working out the right schematic, wiring it up, programming it etc.
What do people think of this overall approach? Sounds like it might work to me.
- Adrian
P.S. Just thinking about it a bit more I could get the Brain-Box to record same basic info too that is displayed when connected in setup mode. This is the sort of summary data a CA or display would usually show/record. It would require a lot more code, but it could record trip & total stats like:
Last Trip Stats
- peak power
- average power
- % assist
- wh/mAh used
- distance travelled
- assisted distance
- wh/km during assist
- wh/km overall
- Max amps
- Min voltage
Life Stats
- # rides
- total distance
- total wh
- .....