Motorboard Controller Source Code (Open Source)

From Motorboards
Jump to: navigation, search

Programming the microprocessor

PICKit 2 connected directly to PIC16F73, additional board not used

The PIC16F73 can easily be programmed by use of a PICKit 2 package available on ebay for about $40. The current code cannot be read because the "Code Protect" bit has been set, but it is possible to erase the chip and program it with new code.

The following pins should be connected from the PICKit 2 to the PIC16F73

  • VPP (blue) to MCRL/Vpp (Pin 1)
  • VCC (yellow) to VDD (Pin 20)
  • GND (green) to VSS (Pin 19)
  • PGD (red) to RB7/PGD (Pin 28)
  • PGC (black) to RB6/PGC (Pin 27)
  • PGM (white) not connected

The PIC16F73 contains a a USART which is currently unused, but could be connected to a PC for diagnostics messages.

Software Overview

The Motor Controller

  • Monitors the throttle position
  • Controls the motor speed using PWM based on throttle position
  • Monitors batteries voltage level:
    • Provides battery low voltage cut off to increases efficiency and battery life.
  • Monitors motor speed
    • Provides "Kick-to-Go feature", prevents power to motors until 3mph has been achieved.
    • Adjusts PWM for to providing enhanced acceleration
  • Turns the LEDs off and on
    • Indicate power on
    • Indicate low power warning condition
    • Indicate low power cut-off condition

Detailed Operation

LEDs Indicators (Battery sense)

When you turn the motorboard ON, the green light goes on then off, then the yellow light goes on then off then the red light goes on then off and then the green light goes on solid. Then the operator pushes to go.

When the battery gets low, the YELLOW light will illuminate. When the battery gets critically low, the RED light will illuminate. When the battery is almost dead, the red light will blink and the buzzer on the motor contoller PCB will beep on and off (1 second on, 4 seconds off) until the battery reaches the low power shut off.

The motorboard has an automatic low power shut off. If low power is detected the red LED will blink, and power will be shut off completely.

The low battery indication (YELLOW and RED) can also occur if the motors become disconnected from the Motor Controller. If the charge indicates GREEN, but the throttle indicates YELLOW or RED, check for a broken or loose connection.

Speed Control

The advertising literature says the Pulse Width Modulator (PWM) operates at 10,000 times a second. Actually it operates at 7813 Hz (measured). The motor operates at a logic "0", and ranges from 20% (minimal speed) to 100% (full speed) depending on the position of the throttle. The speed is controlled linearly, and no attempt is made to maintain a given speed for a given throttle position.

Chopper

The controller monitors the speed of one of the motors (the one with a optical wheel "chopper" attached to an elongated motor shaft). If the speed of this motor is less than 3mph, no power will be provided to the motors. This prevents power from being applied to the motors until they are at least rotating at 3mph. This saves significant amounts of battery power and prevents the motorboard from starting accidentally.

The motor makes approximately 12.75 turns for every turn of the wheel. Since there are eight optical slots on the chopper per turn, this means 100 optical pulses per turn of the wheel. One turn of the wheel is at best 100 inches (39.26cm), so there is approximately 1 optical pulse per inch of travel. 3mph translates to 53 optical pulses per second, less than this amount, power will be cut from the motors. The Roth motorboards "maximum" speed of 18mph translates to 317 optical pulses per second.

Because there is no indication that the motor is moving less than 3mph, if the optical wheel fails for any reason the motorboard will assume that 3mph has not yet been reached. The motorboard will not function and there will be no indication as to the cause of failure.

Application Notes

The following application notes are available at the MicroChip website

The following application note is found at the solutions-cubed.com website:

Compilers

Source Code

TBD