Baby-O 18V25CS motor driver

I am using a Baby-O in combination with a 18V25CS motor driver in drive-brake mode, this makes the motor response very direct.
The motor driver is controlled with one of the M1A outputs connected to the PWMH. A jumper to PWML links the pwm together and allows me to use drive coast.

Drive coast is more efficient but has a disadvantage that it bleeds off rpm at a slower rate than in drive-brake.

I wondered if I could switch the drive-coast to drive-brake when the requested rpm is lower than the measured rpm and use drive brake in all other conditions.

I cannot make both M1A and M1B high as this is the output of a motor driver on the baby-O and the timer 1 cannot be used because I use it to cath the rx signal. I wondere wether I could use the M2A but am not sure if this can be used in sync with the M1A.

The only thing I can think of is to make an external connection between the PWMH and PWML by a transistor and use one of the baby-O outputs to control this.

Any other bright ideas are welcome.

Hello.

I think it’s not a very good idea to use the Baby Orangutan’s motor driver outputs as logical inputs to the high power motor driver. Why not use one of the Baby Orangutan’s many free digital outputs? The two hardware PWM outputs of Timer 1 are both available, or you could implement your own PWM outputs on arbitrary I/O lines in software using timer interrupts.

- Ben

I used the motor outputs for a large H-bridge, it works but the 18V25CS offers more functionality, has a better efficiency and is soo much lighter.

I’ll modify the pwm on timer 2 into something on two outputs, thanks for the tip


I have re-designed my application, the DC motor is running again, timer1 delivers a PWMH output on PB1 and PWML on PB2 so I can use the drive-coast and drive-brake on the motor driver.

I am using a Hall sensor to measure the rpm and a Rx for input signal.

In the previous version I used timer1 to count the time passed for a Hall passage and Rx pulse length, now with the pwm at 12 kHz I only have 1666 counts on timer1 which is not enough to count the time.
The Hall sensor is on INT0 PD2 and the Rx connected to PCINT PB0

A Hall passage is between 0,005 and 0,0005 sec
A Rx pulse between 0,002 and 0,001 sec

What is the best way to mesure the pulse length of the Rx signal using Timer2? Suggestions are welcome

If you’re not trying to stay away from using the Pololu AVR library, you could use the OrangutanPulseIn functions to measure the Rx pulses. The library uses Timer 2 as a system timer to maintain the number of ticks that have elapsed since the device was last reset (in units of 0.4 us), and the PulseIn code relies on this system timer to measure the pulses.

If you’re not using Timer 2 for anything else, the OrangutanTime and OrangutanPulseIn code should work fine. Note, however, that other parts of the library will conflict with the way you are using Timer 1, so you should avoid calling OrangutanBuzzer and OrangutanServo functions.

- Ben

I solved the problem by making a CTC counter from timer2, this allows me to have a free choice of resolution without sacrificing all resources for counting the time of the rx pulse. I’ll start with a count to 200 without prescaler, that gives me a number of 100 for full throttle with an accuracy of +/- 1% as I do not know when the overflow occurs.

Reducing the CTC value will increase the count number but as this overflow fires every overflow reducing the number too much will make other calculations slower.

Las week I picked up this project and did some rework on the interrupts.

My motor has 12 teeth stator and 12 magnets in NSNSNSetc. order, so each tooth is attracted by a magnet at the same time, in order to run properly my software needs to change DIR on the motor driver at every 1/12th turn. The motor has to be started with a flip because it does not know which way to turn. (somewhat comparable to a stepper motor)

Timer 0 overflow sets the motor outputs to zero when the motor is not running
Timer 2 is used as a counter to count a number between Rx input rising edge and falling edge on PB0
Timer 1 is used to put a pwm out to PWML and PWMH
A Hall interrupt on PD2 is used to signal that DIR has to change

The motor is running on 7400 rpm on a 3S battery and 8x4,3 GWS prop, the output of 70W is typical for such a small motor, efficiency looks good.

The most surprising detail is that the DIR change on the 18V25CS motor driver shows no sign of weakness at all when the motor is run without any load at 13000 rpm = 13000 * 12 teeth / 60 = 2600Hz