Electronics > Projects, Designs, and Technical Stuff

DC motor controller

(1/5) > >>

OM222O:
Hi
I'm working on a project where I need to control two motors. I need to implement a PID controller that sets the positions of the motors. I am currently using 2 arduino nanos and a 2 channel H bridge driver + High resolution encoders directly on the motors. The motors are geared down 51:1 which means the numbers get very big, very fast (4096 PPR encoders).

I think it's worth upgrading to a 32 bit micro controller running at higher frequencies, for example a teensy 4.1 which runs at 600MHz compared to 16 of the arduino and proccesses larger numbers better. I find that arduinos are also really glitchy and sometimes do weird things, but that might just be my code so I won't blame them for now. I wonder if there exist off the shelf motor controllers or if I should roll my own using a teensy and an H bridge shield (the current one really under performs so I'd like to design my own).

Also the arduinos are working via USB serial and getting position and configuration daat from a raspberry pi which is less than ideal as it uses many ports (there are other devices other than the motor controller, each taking up 1 USB port). Is there something more suitable? I know can bus is pretty popular but I have never used it before so I'm not sure where to start.

Any suggestions on how to go about this or possible flaws in my idea?

H.O:
What size motor is it you're using, voltage, current? What sort of interface do you want/need to actually control the position of the motor(s)? An analog input, step/direction, quadrature signals, or is it to be controlled by some high level host like a PC or PLC so you want some sort of bus interface which, in turn, can be anything from simple serial to something like EtherCAT?

Budget?

A microcontroller running at 600MHz sound like massive overkill for a basic motor control application, personally I've used the PIC18F2431. Key here is that it has a dedicated peripheral that handles the encoder counting so you don't have to use polling or interrupts for that. If you want to keep using the Arduino I'd look at offloading the encoder count to an external chip (LS7166 springs to mind but that might be obsolete now).

OM222O:
The motors are 12v 80 watts.

I already mentioned using raspberry pi amd usb serial for coomunication and the need for a simpler bus. CAN has a lot of features like CRC check, high immunity to noise, etc so I will probably choose that in the end.

I'm not sure which CAN transciever to use however so feel free to recommend some chips. I'm going through a few datasheets as we speak.

Budget is not important at all, can cost a few hundred £.

Yes a 600MHz micro is overkill but simplifies a lot of things and I need this ready by october, so I think throwing money at the problem here would be a good compromise. I was just wondering if there are better approaches (in terms of ease of use and robustness, not small things like interrupt handling or external chips for encoders), for example off the shelf controller modules (similar to O drive but for brushed motors) or dedicated controller ICs perhaps.

Siwastaja:
No, a more complex microcontroller is not going to "simplify" things, seeing you have issues writing stable code even on the AVR. All those "glitchy" "weird" things are because of your code, and changing into a more complex, more capable MCU increases the number of problems.

The higher-end MCU is not only faster, it has more traps.

And I'm 99% sure you won't need the speed. If you need large numbers, int64_t is fast enough on a 16MHz AVR. Say, approx a million of operations per second. You need maybe 10000.

If you only have time until October, the only way you can do it is to keep using what you are familiar with, i.e., that would be your current Arduino.

The performance of the 16MHz AVR should be definitely enough.

Start by looking at your code, debugging it, fixing things until you can figure out why it doesn't work properly. If the performance runs out, look why this happens and fix it. This way, and only this way, you'll be able to do this in a few weeks.

Zero999:
What you're proposing seems sensible. I echo the concens above about using a more complex MCU.

Are you looking for a different, more useable H-bridge? A quick Google found the VNH5180A, for which a cheap evaluation board is available from RS Components.
https://uk.rs-online.com/web/p/power-management-development-kits/8463452/
https://www.st.com/en/automotive-analog-and-power/vnh5180a-e.html

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod