Series Hybrid with Hubmotor

Discussion in 'Electric Bicycles' started by skyl4rk, Aug 9, 2008.

  1. skyl4rk

    skyl4rk Guest

    I am going to use this thread to work out some ideas for a series hybrid hubmotor system. I saw an example on this forum by Denny and I am just trying to work out the idea and maybe it will actually become a reality.

    I am starting out with a Wilderness Energy brushed hubmotor:

    http://wildernessenergy.com/index.php?cPath=24

    I have had this kit for a few years on a Giant Sedona. I am running 36V 12aH lead acid currently.

    The goal is to build a Series Hybrid.

    http://en.wikipedia.org/wiki/Hybrid_Vehicle_Drivetrains#Series_Hybrid

    A gas motor powers a generator which can be turned on to power motion and charge batteries. The motive force comes from an electric hubmotor which is powered by batteries or by a combination of batteries and generator.

    So basically this is an electric bike with an add on gas powered generator that can be turned on to increase range.

    The hubmotor is a 600W motor. The motor probably uses 600W only when starting from a stop uphill. At full battery charge (about 37.5V) the motor would draw 16 amps (600W / 37.5V) at full load. At 50% discharge (36.6V) the motor would draw 16.4 amps at full load. Note that cruising along at the normal top speed of 17mph will likely use much less than 16 amps, 16 amps is a short term, peak load.

    Currently I use 3 batteries to reach 37.5V full charge voltage. I would like to increase this to 4 batteries -> 50.6V full charge voltage. I have heard good reports that the hubmotor and controller can handle up to 72V and remain reliable.

    In order to choose an output voltage for the generator, I will look at the maximum recommended fast charge voltage, which is 2.45V per cell. With 4 batteries each with 6 cells, I get a fast charge voltage of 58.8V. This is my target voltage for the generator.

    http://www.batteryuniversity.com/partone-13.htm

    My next goal is to specify a gas motor and dc generator to provide about 58.8V and to be able to power a peak 600W, more or less, which is what the hubmotor is rated for. Note that average power use will be less. I also want to specify a lightweight generator system.

    http://cgi.ebay.com/ws/eBayISAPI.dl...rkparms=algo=CRX&its=S%2BI&itu=UCI%2BSI&otn=4
    If link doesn't work search on BOSCH 1/2 HP 120V DC WIND GENERATOR MOTOR MILL LATHE

    This dc electric motor has the following ratings:

    120V at 10,000 rpm's
    640W
    5.5 amps
    Continuous Duty

    Voltage and rpm's are roughly linear, so I would expect 58.8V output at 4900 rpm's. (12V per 1000 rpm)

    The amp rating is lower than I would like, so it is possible that this motor will not provide enough power. However, in short term high load situations, the batteries will act as a buffer and will provide additional power beyond what the motor can put out, so I am hoping that the 5.5 amp value will provide more than the average current draw while riding the bike. At 58.8V, 600W of power would result in just over 10 amps peak load, so I may be OK with 5 amps for average load. If not, I might need to move to a 5 battery system at 73.5V. If 73.5V are needed, I would expect to measure 73.5V at about 6125 rpm.

    So the generator is rated at 640W and it needs to run at about 4900 rpm to produce 58.8V. Now a gas motor is needed that will produce more than 640W at about 5000 rpm.

    The Honda GX35 four cycle motor is rated at about 800W at 4900 rpm and about 950W at 6125 rpm. The power rating is adequate and the maximum torque for the motor is in the desired rpm range. This means the gas motor will be running efficiently.

    http://www.honda-engines.com/engines/gx35.htm#per

    The motor and generator would be connected with either a flexible or solid coupling. The motor throttle (idle screw) would be adjusted until the generator produced the desired voltage, which is 58.8V for a 4 battery system and 73.5V for a 5 battery system. To start the generator, a double pole double throw switch would connect the dc motor to the battery voltage and would also break the ground to the motor shut off, allowing the motor to run. The dc motor would start the gas motor by turning it. The gas motor would fire up and produce voltage to charge the batteries and power the hubmotor.

    In operation, the bicycle could be used as a battery powered bike until it is noticed that there is a reduction in power due to batteries starting to discharge. Then the motor could be turned on either full time or during heavy loads such as starting from a stop or climbing hills, depending on how much additional range is needed. For long distance travel, the motor could be run full time.

    The benefit of a series hybrid is that it works well for extending range and provides a guarantee that you will make it home if you travel further than your battery range. It is less suited for long distance travel but may work using full time power generation. Adding a gas powered generator turns the electric bicycle into a plug in hybrid vehicle. My current range with the 36V 12 aH battery is about 10 miles. Adding additional batteries would likely extend this range to about 14 miles. The gas generator system should at least double the range and perhaps would be powerful enough to provide as much range as the fuel tank allows.
     

  2. SimpleSimon

    SimpleSimon Active Member

    I like that. You obviously know much more about the engineering details of such a system than do I, but it is pretty much what I have envisaged in a couple of prior posts, including the Gas/Electric Hybrid thread. It just seems to me to give a lot of benefits. Certainly there are trade-offs (there always are) in terms of straight mechanical efficiency,overall weight of system, etc, but they seem to me to be outweighed by the advantages.

    Not least is the ability too, at need, effectively run silent on pure electric power, and to tune muffler/exhaust systems to the lowest attainable sound output levels at the desired rpm range. Ive been looking lately at how one might go to a computer based system management regime in a small hybrid vehicle, with inputs from sensors on the throttle, brakes, and vehicle power system. It seems doable, relatively cheaply, utilizing something like the sub-laptops or expanded PDA's now available.
     
  3. mac66

    mac66 New Member

    The problem with adding a gas engine and generator is the added weight and where are you going to put it on your bike?

    If you saw this thread...
    http://www.motoredbikes.com/showthread.php?t=13517

    I am working on a similar system, but a pusher trailer, based on Denny's idea.

    I am using an 36v/350W electric scooter, a Homelite 25cc gas trimmer engine and the Bosch wind generator motor. This will all be combined to make a pusher trailer.

    The problem I have right now is that I took the scooter apart and disconnected all the electronics. I eliminated everything but the key switch, and throttle and tried to wire it all back to the controller. Unfortunately the scooter controller jas a number of auxillary functions built in and I can't get the controller to recognize the key switch and throttle. Plug everything in and the motor goes full speed. I am going to have to figure out a way to open the controller and rewire it or get a another basic controller.

    I am open to suggestions as to what other controller I should try. I really only need one that has on/off and throttle.

    As far as the gas engine and generator motor are concerned, the issues are coupling the shafts together and figuring out a way (bracket?) to mount the whole thing to the frame of the trailer.

    Shaft coupling is tricky in that the shaft from the generator is slightly larger than the shaft of the gas engine. You have to make sure they line up and center on one another. I did find a shaft coupler online that can have two different diameters and will center each shaft but is it $33+. I will probably order it since it really it the right way to do it despite the cost.
     
    Last edited: Aug 10, 2008
  4. skyl4rk

    skyl4rk Guest

  5. skyl4rk

    skyl4rk Guest

    It looks like the GX35 only comes with a clutch, I need one with a shaft. Will have to call smallenginewarehouse.com .

    ???
     
  6. skyl4rk

    skyl4rk Guest

  7. ibdennyak

    ibdennyak Guest

    skyl4rk and mac....I am honored at your interest. Crude as it was, mine worked surprisingly well. The split couplings are the way to go from a dependability point of view. Sky, your take on the engineering is dead on....and on mine proved out pretty much as expected. Using a PM motor, you could use an engine with a governor to control voltage. On my *new and improved* version I went with a Honda GX25 with the idea that it was governed, but it wasn't. The GXH50 apparently is.

    I ran mine for nearly 800 relatively trouble free miles until the Alaskan climate got in the way. I ended up getting moisture inside the hub, and blowing the controller. In a drier climate, it would probably still be going.

    My other objection was hill climbing ability. Juneau is kind of stuck to the side of a mountain. With 48 volts, and the kind of loads I carry, hills can be a problem. Under less abusive conditions, it would work fine.

    Anyway, thanks for the recognition, and good luck. Hope it works well for you

    Denny
     
  8. skyl4rk

    skyl4rk Guest

    Here is my theory for motor control:

    Use an Arduino programmable processor to "sample" the voltage level every second or two. The Arduino would then control a servo attached to the throttle of the gas motor/generator. Under load, when voltage is below target voltage, throttle up. If voltage is above target voltage, throttle down. That would be a pretty simple programming job on the Arduino, although it might take some finesse to stop motor pulsing.

    http://www.arduino.cc/

    There might be some value in knowing the no load battery voltage as well but at first I would just check the operating voltage every second and adjust the throttle accordingly.

    I could probably use a relay to let the Arduino turn the gas motor/generator system on and off but that is something I would rather control manually, at least at first. I don't want the motor to start up when I don't expect it.

    I'm waiting on a new carb for the weedwacker motor, then I can start ordering some more parts to make it happen, assuming I can get the weedwacker to run.

    By the way, I was looking at scaling the concept up for a little more power, and there don't seem to be too many permanent magnet dc motors or generators in the 1kW and up range. Plenty of 3hp four cycle gas motors though. Their rpm range is not as wide as the GX35 so there might need to be some gearing between gas motor and dc motor/generator to reach the right rpm to generate the required voltage.

    Maybe the cheap and easy solution is to use multiple 500W dc motor/generators, geared appropriately. For now I will just work on the bicycle series hybrid system and not try to scale it up to a streamliner or velomobile application.
     
  9. skyl4rk

    skyl4rk Guest

    Progress Report:

    I have upgraded the system to a 48V 12aH lead acid system with powerpole connections. There is a battery tray in the rack so the rear rack is free for the generator.

    I have not been able to get the weedeater motor to run for more than about 20 seconds. There appears to be some fuel supply problem which I think is in the gas filter. I put a new carb on it with the same results. So maybe next weekend I can get it working? Got to find parts, nobody around here seems to have the right fuel line and filter.

    Pics will be posted soon.
     
  10. skyl4rk

    skyl4rk Guest

    Pics....................
     

    Attached Files:

  11. skyl4rk

    skyl4rk Guest

    Progress this weekend:

    Finished painting the battery tray and reassembled so I now have a complete and functional 48V 12aH lead acid BD36 Wilderness Energy kit.

    Using leftover batteries which were "worn out" last year, I ran 5 miles at wide open throttle on a track, which brought voltage down to 47V (normally I do not want to go below 48V). 48V is more fun than 36V. It was fun leaning into the turns.

    I got the Weedeater to run by putting a new fuel line and fuel filter on it. After adjusting the carb a bit, it now seems to run pretty well. It is all cleaned up. I am trying to figure out how to mount it, will need some type of angle or channel aluminum. I have to look at it awhile. I would like to get rid of the Weedeater plastic housing but it includes a reed valve and cover for the crankcase as part of the housing, and the housing is probably is needed to direct cooling air. I may end up keeping the motor in the housing if I can find a way to mount the motor. It would be nice to find a quieter muffler for the thing.

    The Weedeater has a shaft with a 5mm x 5mm square hole in the middle. A flexible shaft was inserted into the square to power the weed whipper. I may try to grind down the threaded end of the Bosch permanent magnet motor to fit the square opening. If that doesn't work I can still use a flexible coupling.
     

    Attached Files:

  12. skyl4rk

    skyl4rk Guest

    I ground down the shaft end of the dc motor and it fits into the 5mmx5mm opening in the gas motor shaft. I also ordered a flexible coupling kit which is probably the better way to go.

    I tried to get a weed whacker conversion kit but apparently I have an odd motor, no parts available. I was going to get the 3" mount from here:

    http://www.wackerengines.com/Ryobi.htm

    But no dice, the kit does not fit my motor.

    So instead I took a look at the plastic housing and cut it down to open up the head and muffler for better cooling. I think I can make a mount by bolting the plastic housing to a board and then installing the motor into it.

    I think I am going to be able to make this thing work, at least I can finally see how to mount it. It will take some work to get the gas motor and dc motor lined up right. I still have a long way to go.
     
  13. skyl4rk

    skyl4rk Guest

    Today I spent time on cutting and sanding the plastic weedeater housing to allow me to screw on aluminum angle to make a motor mount. The mount is pretty straight and stable, I think it will work.

    For the dc motor, I cut out a mount from 1/8" aluminum plate scrap that I had in my garage. It will be fitted to some aluminum angle as well.

    All this was done with a hacksaw and file, and an electric drill. I don't have good metal working tools, mostly just hand tools.

    I still have to bolt a lot of stuff together, align it and mount it to a piece of plywood. Then add a gas tank, electric switch, servo and controller. I still have to program the controller, I may just start out with adjusting the throttle and holding it in one position at first.
     

    Attached Files:

  14. skyl4rk

    skyl4rk Guest

    Motor Control Theory

    Gas motor rpm is tied to voltage output of the dc motor. There is a linear relationship. In order to control voltage, it may be possible to hold voltage within ranges by controlling the gas motor throttle.

    There are two conditions to consider regarding motor control: 1. No Load and 2. Max Load. An example of No Load would be while standing still waiting for a stoplight with the motor running. Max Load would be at start up from a stop while using full electric hubmotor throttle.

    It is possible that the system would work adequately with a static throttle position. However, the throttle would have to be set so that the target voltage is achieved at No Load condition. Under Max Load, the actual voltage would likely sag. There may be some optimization to achieve by increasing gas motor throttle under load.

    No Load

    The goal at No Load is to hold but not exceed the fast charge rate voltage. For my 48V lead acid system, the target voltage for fast charge is 57.5V. This is based on lead acid battery chemistry. I do not want to exceed this voltage in order to avoid battery damage. I want to maintain the target voltage to maximize charging into the battery system. No Load gas motor throttle position -> Target Throttle Position -> TTP. TTP is the throttle position where the generator system provides 57.5V.

    Max Load

    Assuming TTP at Max Load, the electric hubmotor draws current and voltage sags. Initial power used to power the electric hubmotor comes from the generator system. However generator power is limited and is less than the electric hubmotor load. Generator voltage will sag until battery voltage (about 51V, depending on charge level) is reached, and batteries would then provide power. As voltage continues to sag under load, gas motor rpm will be reduced due to the load. Voltage would continue to sag under battery power until available battery current and electric wheel power "equalize".

    If it were possible to increase the gas motor throttle to work against the voltage sag under load, the power draw from the batteries would be reduced and range would be increased. Any time that the generator voltage remains above battery voltage, battery charging is occurring. This allows a longer run time under electric power only, no gas motor, meaning the gas motor might run for less time.

    While the generator is operating, generator and battery systems are at the same potential (voltage). A controller could be designed to measure the generator voltage and adjust a servo to increase gas motor throttle when the generator voltage drops below the fast charge voltage.

    The programmable Arduino is a kit that is intended to help people learn about electronics, but is also robust enough to be used in real life applications.

    The Arduino can measure voltage from 0V to 5V and will provide a reference number for control of other devices. The Arduino can be programmed to control a servo of the type used in RC (hobby remote control) applications.

    In order to measure voltage, a voltage divider could be used to reduce system voltage (about 50V - 58V) to Arduino sensor voltage (between 0V and 5V).

    See: http://en.wikipedia.org/wiki/Voltage_divider

    Voltage Divider Calculation

    The Arduino requires very little current to measure voltage. A voltage divider will alway draw a certain amount of current to the ground. For the hybrid bike system, I would accept about 10mA of loss for the voltage divider.

    58V / 10 mA = 5800 ohms (total voltage divider resistance)

    My target voltage for the Arduino is 3V (roughly midrange 0V - 5V).

    3V / 58V * 5800 ohms = 300 ohms
    5800 ohms - 300 ohms = 5500 ohms

    About 300 ohms of resistance would have to be on the ground side of the Arduino sensor, and 5500 ohms would have to be on the generator positive side of the Arduino.

    Actually I would probably use a 10k ohm potentiometer, which would allow me to fine adjust the voltage level, at least at first. When an optimal resistance is found with the potentiometer, I would then measure the resistances and use resistors instead of a potentiometer in order to prevent voltage creep due to vibration or bumping the potentiometer.

    The result of the voltage divider would be to provide an approximate 3V to the Arduino sensor, with the voltage varying together with the generator output voltage. The Arduino changes the input voltage to a reference number. In the case of 3V, the Arduino reference number would be about 615. As the reference number rises and falls, a servo can be controlled through the Arduino programmable interface.

    Arduino Servo Control

    Below is an example servo control script for the Arduino. It allow the user to move the servo by adjusting a potentiometer. This script has not been changed to control a gas motor throttle based on sensor voltage, but it could be modified to do so.

    Code:
    
    // Generator Servo Voltage Control
    // Sample voltage, adjust throttle with servo to regulate voltage
    // Futaba FP-528, pulse range 250 to 2300 milliseconds, over 180 degrees throw
    
    // Static variables
    int servoPin = 2;     // Control pin for servo motor
    int minPulse = 250;   // Minimum servo position
    int analogPin = 0;    // voltage sensor pin, between 0V an 5V
    int refreshTime = 20; // the time in between pulses, servo speed adjustment
    
    // Dynamic variables 
    int pulse = 0;        // Servo pulse holder, adjusts servo angle
    long lastPulse = 0;   // the time in milliseconds since the last pulse
    int analogValue = 0;  // the value returned from the analog sensor, 0 to 1023
    
    // Calculated values and adjustments
    // Adjust the throw angle as shown in the pulse line below
    // Adjust the servo motor speed with the refreshTime variable above
    // Voltage at analogPin 0 changes analogPin value, 
    // at 0V -> 0, 1V -> 207, 2V -> 408, 3V -> 615, 4V -> 822, 5V -> 1023 
    
    void setup() {
      pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
      pulse = minPulse;           // Set the motor position value to the minimum
      Serial.begin(9600);
    }
     
    void loop() {
      analogValue = analogRead(analogPin);      // read the analog input, 0 to 1023
      pulse = (analogValue*2.0) + minPulse;     
      // 2.0 is a value that gives about 180 degrees throw on the Futaba servo
      // Reduce 2.0 value to reduce throw, also can recalculate 2.0 value:
      // 1023 * X + minPulse = maxPulse, where X = new 2.0 value in above line
      // and maxPulse is the pulse value that gives the desired max throw angle 
      
      // pulse the servo again after refresh time (20 ms)
      if (millis() - lastPulse >= refreshTime) {
        digitalWrite(servoPin, HIGH);   // Turn the motor on
        delayMicroseconds(pulse);       // Length of the pulse sets the motor position
        digitalWrite(servoPin, LOW);    // Turn the motor off
        lastPulse = millis();           // save the time of the last pulse
    
    // Print pulse and analogValue to screen
    
        Serial.print("pulse: ");
        Serial.print(pulse);
        Serial.print("; analogValue: ");
        Serial.println(analogValue);
      }
    }
    
     
  15. duivendyk

    duivendyk Guest

    If you run a motor as a generator the internal IR drop + other losses subtract from the induced voltage,while as a motor it is added to the emf to equal the supply voltage,(the induced voltage is proportional to rpm) therefore running at the same speed, the output in the generator mode can be significantly lower than the motor supply voltage depending on how inefficient the device is.So you'll have to be running at significantly higher rpm,to have the same output voltage.Assume for instance a 0.9 ratio and you end up with an increase of 25% in rpm (1/0.81) and even more at peak 10 Amp load, it could be 35-40 %
     
    Last edited by a moderator: Sep 7, 2008
  16. skyl4rk

    skyl4rk Guest

    I made some more progress this evening. The flexible coupling came in today. I did a horrible job of drilling out the coupling hubs to the right diameter for the shafts. The hubs are very wobbly now. But I hammered them on and tried to tap them into a reasonable alignment. Next time I will ask to have someone drill the hubs out for me or get a drill press for my shop so I can do it right myself. However, this flexible coupling is really the way to go. Even though I messed it up, I think it will still work. Hubs are only a couple of bucks each so I haven't lost too much.

    I hacksaw cut the dc motor axle down to about an inch and a half in length. The gas motor and the dc motor are bolted down to a plywood base, which is reinforced/straightened from warping with angle aluminum. I built a housing out of plexiglass around the axles and flexible coupling and over the dc motor. I installed the 20 amp switch but no wiring yet. Installed the gas tank on top of the housing.

    1. I need to get a longer fuel line.

    2. I need to do the wiring.

    3. I need to get a choke cable to control the speed or mount a servo and start in with servo control (might actually be easier that way).

    Then I can do some bench testing.

    I tried to run the dc motor under 12V but it did not have enough power to turn the gas motor over without a spark plug. 24V did turn it over quite nicely but still did not have enough power to turn it with a spark plug in it. I hope 48V has enough power to kick it over with the spark plug in it.
     
  17. skyl4rk

    skyl4rk Guest

    Today I put everything together and got it running.

    I tried some different things to set up a throttle and ended up using a bicycle spoke with some bends in it, hooked into a washer with a hole in it and a nut that allows adjusting the throttle level.

    The fuel line was easy, I put it inside some plastic conduit to protect it.

    I did the simple wiring system, no servo or control. A switch connects the generator to the battery system. I added a shut off to ground the magneto of the motor when turned off.

    36V does a good job of turning over the motor. I played around with the carb adjustment and finally got it to fire up.

    With some throttle on it, it was putting out well over 50V. I didn't do that very long since I had a 36V battery pack. I still need to do the testing, I just put it together today and got it running. I have to add a good way to connect a voltmeter to it for adjustments.

    Maybe I will take a break tomorrow and clean up the workshop and come back to the motor when well rested and thinking clear.

    The thing is loud. I will have to put some kind of additional muffler on it.

    I still have to build a mount to fit it to my rear rack.

    If I find it is easy to set a certain rpm -> voltage level, I may try it out on the bike with the current throttle set up. Or I may try to set up the controller system before trying it on the bike.
     

    Attached Files:

  18. Bigwheel

    Bigwheel Member

    Sometimes it is good to step back for a bit for sure. Keep up the good work though, it looks like you are almost there!
     
  19. skyl4rk

    skyl4rk Guest

    It Lives!

    Got everything installed on the bike, did a little carb adjustment, took a spin around the block. Its a little too rainy to do much more, but it is alive! woooohoooooo!

    The idle screw is all the way in, which seems to keep the voltage around 54 to 60V with a lot of swing in the voltage. The motor seems to like the rpms. It did not run as well at 44V when I was trying it out with my old 36V battery pack. 48V works much better with this setup, at least so far.

    Haven't done too much testing but I made it around the block and everything seemed to be working right the whole way.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     

    Attached Files:

  20. skyl4rk

    skyl4rk Guest

    Too rainy to ride today.

    I cleaned up the wiring a bit.

    I added a voltage divider.

    Positive (50 to 60V)
    19520 ohms (measured)
    Tap
    970 ohms (measured)
    Ground

    At about 50V input, I measured 2.42V at the tap. This will be a good voltage source for the controller to measure.

    I will spare you the math, but when I work out the tap voltage for my target voltage of 57.5V, I get 2.78V. And the reference number for that voltage is about 570 on the Arduino scale of 0-1023 over a range of 5V.

    So here is an Arduino script that I think will run the servo to try to keep the voltage around 57.5V.

    Code:
    // Generator Servo Voltage Control
    // Samples voltage, adjusts throttle with servo to regulate voltage
    // Futaba FP-528, pulse range 250 to 2300 milliseconds, over 180 degrees throw
    
    // Static variables
    int servoPin = 2;       // Control pin for servo motor
    int analogPin = 0;      // voltage sensor pin, between 0V and 5V
    int startPulse = 1800;  // Starting servo position
    int refreshTime = 20;   // the time in between pulses, servo speed adjustment
    int offset = 0;         // the difference between target voltage and measured V
    
    // Dynamic variables 
    int target = 570;       // adjust this value to achieve desired voltage output
    int startup = 0;        // initialize startup value
    int pulse = 0;          // Servo pulse holder, adjusts servo angle
    long lastPulse = 0;     // the time in milliseconds since the last pulse
    int analogValue = 0;    // the value returned from the analog sensor, 0 to 1023
    
    
    // Calculated values and adjustments
    // Voltage at analogPin 0 changes analogPin value, estimated
    // at 0V -> 0, 1V -> 207, 2V -> 408, 3V -> 615, 4V -> 822, 5V -> 1023 
    
    void setup() {
      pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
      pulse = startPulse;         // Set the motor position value to the minimum
      Serial.begin(9600);
    }
     
    void loop() {
    
      analogValue = analogRead(analogPin);  // read the analog input, 0 to 1023
      offset = target - analogValue;  // voltage difference from target voltage
      
      // the offset amount will affect the acceptable voltage range
      // the pulse increment value will affect how fast the servo steps
      if (offset < -15) pulse = pulse + 10;
      if (offset > 15) pulse = pulse - 10;
    
      // adjust throw angle with minimum and maximum pulse numbers
      if (pulse > 1800) pulse = 1800;
      if (pulse < 800) pulse = 800;
    
      // pulse the servo again after refresh time
      if (millis() - lastPulse >= refreshTime) {
        digitalWrite(servoPin, HIGH);   // Turn the motor on
        delayMicroseconds(pulse);       // Length of the pulse sets the motor position
        digitalWrite(servoPin, LOW);    // Turn the motor off
        lastPulse = millis();           // save the time of the last pulse
    
    // Print pulse and analogValue to screen
       Serial.print("analogValue: ");
        Serial.print(analogValue);
         Serial.print("; offset: ");
        Serial.print(offset);
        Serial.print("; pulse: ");
        Serial.println(pulse);
      }
    }
    
    I'm not sure I even need to use a controller, it may be enough to let the motor run on high idle. However, the throttle is very responsive, and if I can get more power under load, then it will be worth it. It may also allow the motor to idle at a slower speed when under a no load condition. So I am just having fun trying this out, maybe it will work, maybe it is overkill.
     
Loading...