beemac
1 kW
casainho said:I see the following disadvantages:beemac said:Have been thinking about how to manage the two codebases to keep features common with a minimum of legwork;
Idea was to refactor the existing motor controller code slightly - move anything hardware specific out of ebikeapp.c and into a hardware abstraction class that reads things like torque sensor or pas - then make ebikeapp.c part of common firmware... in other words separating all the hardware specific motor control code from the higher level functionality.
I was thinking the interface for motor.c should be simplified to just motor control parameters - such as:
target pwm (with corresponding ramp up/down in units/sec) OR target current (with corresponding ramp up/down in units/sec)
limits for pwm/current/rpm/power - rpm is new, and power may be unnecessary in addition to current.
So that would mean to move any code that adjusts motor current or pwm parameters based on torque or pas values out of motor.c...
1. 8 bits VS 32 bits microcontroller, meaning the old code is optimized (I mean all the code, not only the motor code) for 8 bits and that would be a limitation (in quality output) for the new motor controller.
2. The compiler SDCC for the old one is more limited and the code is a mess because of that, with all variables global.
1. Sure - but there's not much in the rest of the code right now that would benefit greatly from 32bit from what I can see.
2. True - but to refactor all the code wouldn't provide that many benefits right now and would probably be more work - and would lock out all the existing users from new functionality (or we need to maintain two motor codebases).
I think we should use as much of the old code as possible for now to get things working - using new 32bit code where it really makes a difference - e.g. the motor control code. Then if and when we want to improve other parts of the code we can replace those with new 32bit code.
Of course it's quite possible that once i start porting stuff across I might fed up with ifdefs all over the place