Inexpensive Motor controller next phase

Getting ready to move from the scope only testing to the next phase so mounting it wiring it, cooling it. For cooling the 2 controllers I ordered some 5030 fans from Zyltech

That is on the inside where the 5030 fan will mount the bottom half thereabout will go over the fins of the heatsink I probably mount anohter one on top where the other half of the fan blows

Thats a peek from the top the 2 BTS7960 mount with 4 m3 bolts or maybe some 1/8 in or 3mm wood screews threaded directly in the plastic - havent made up my mind yet for now I undersized the holes if I want to cut a thread in or if I go nuts and bolts I can drill them out to size. Openings to each side for versatility for the wires and some holes to allow to manage them with Zip ties. Needs a lid yet but that is last. You can see there is a horizontal ridge besides the vertical reinforcements and that is to prevent the wall from warpint and also provides a mounting ridge.

Next wire it to an actual motor. As there are 2 I will make a connector to connect the 2 motors to each other so they can “fight” each other to simulate a load. Initially for a low load test I will just run one motor the other freely and then start breaking motor2 to increase the load on motor 1 etc.


1 PC Board (I get about 6 out of some bigger one I bought for 95c ea in bulk so 0.20
2 ea BTS7960 from ali express with shipping 10 for 29.80 so $4 ea so $8 total
1 ea Arduino nano clone also ali express bought 10 inc shippin $29.64 so $3 ea

there still will be some wires and some connectors and wire management things pluss the plastic for the box so I believe it will up way below $20 more in the $15 range to control 2 CIMS. Which brings the cost for that controller down to <$10/per motor.

Each motor can take 2 limit switches either active high or low,
1 encoder (either quadrature or rotary like on the bosh motor
and looks like the current control is working too.

I punt the 2 PWM signals on PINB and turned a pin interrupt on for them As the arduino turns off PWM if you read the state of the pin I read the TCNT1 register- as they run on timer 1 instead. The limit switches and encoders are on the other boards with the PIN interrupts turned on for them. So that avoids the overhead of checking for the state of the lets say encoder pins constantly. So you only have a
read pin flags → if set → inc Counter - if target reached - turn off motor. Which is again just setting a pin state. I only tie 1 of the quadrature pins to the interrupt (its also the rotary enc pin) and use the B signal of the quadrature to determine direction to determine increment or decrement of the counter.
Limit switch needs some test when I get some of the “switch kind” RN i only have optical ones.

Still quite a bit of work to do but I am confident as all the hurdles so far have been passed - at least on the bench

Oh there still is the “hooking it together part” That will happen over I2C


If you want a faster encoder, it might be worth looking into STM32 based boards. Those have hardware encoders that can read into the MHz without affecting your control loop. I forget what encoder you’re using right now though.