-
DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hello again dear machinists
As some of you know I published earlier this year schematic and firmware for a BLDC servo drive. http://www.cnczone.com/forums/open-s...-software.html
Don't get me wrong, that model is working just fine, but the 8 bit MCU used is somehow limited... So as many other suggested I am migrating now to a STM32 MCU...
Because the price and the fire power of that little thingy is amazing, I intend to integrate in the schematic a prebuild board: STM32F103C8T6 ARM STM32 Minimum System Development Module Board For New Arduino | eBay
Basic MCU specifications:
Model:STM32F103C8T6.
Core:ARM 32 Cortex-M3 CPU.
72MHz work frequency.
64K flash memory, 20K SRAM.
On-board Mini USB interface, you can give the board power supply and USB communication.
Size:53.34mm x 22.86mm.
So... So far I am developing on a STM32F4Discovery board, that has a more powerfull MCU, however I am waiting for the little ebay boards to arrive...
Things that I tested so far and status:
1. PWM generation works great, 16 bit timers are used. Also note that the STM32F103 has a 16-bit, motor control PWM timer with deadtime generation and emergency stop. For now I do not know how to configure it, so I am using timers in a classic fashion. (I will have to rewrite the mikropascal PWM library as it does not support motor control PWM)
2. Communication with the PC will be done using the USB port provided. The board will register as a HID device, no additional driver will be needed. The Servo Tuner program must be rewritten (not such a big deal)
3. External interupts also tested, very nice as they are plenty and they can be mapped on quite any desired pin.
4. ADC not tested yet, but I am pretty sure it works just fine...
5. Flash storing of the configuration parameters. The sample programs from mikroe seem to work just fine... It seems that those MCUs do not have a special EPROM section anymore, but there are instructions capable to write directly to flash part...
What I need to do for now:
- Build another 3 phase MosFET power driver. All that I previously built are in my CNC machine :p
- Build a dougther board for the STM32F4 discovery board, that will hold very few parts, only the optocouplers for the encoder, step, dir and enable signals, the power regulators and a few connectors.
I intend to add another parameter in the config and to allow user to select what kind of motor it wants: DC or BLDC. When using DC motors only 2 stages from the 3 phase power stage will be connected.
Please let me know if you have any other suggestions, requests for features and so on... It's better to think for them from now when there is no board designed, and there are virtually no limitations...
I will keep you informed on progress
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
i suggest use to265 mosfet or 3 phase stage or IPM
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
tivoidethuong
i suggest use to265 mosfet or 3 phase stage or IPM
Do you have some suggestions for some cheap IPM modules or some stuff like that. The IOR IRAMs look interesting but the price is ugly...
Thanks
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
-
1 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Thanks for suggestions. I will consider them...
However they look pretty expensive and way more powerful than our needs... I can build a 3 phase mosfet power stage with 3 irf2101 and 6 mosfets for less than 10 bucks.
Anyway... Here is the status of the project:
I am building the firmware and the Servo Tuner Software in parallel, here is a quick snapshot.
Attachment 294068
Status:
1. Communication with MCU over USB (board is registered as USB HID). Fast data transfers are possible, I made the soft to transfer a dummy Response from servo matrix, with 2048 int16 values, and it takes less than 1 second = Done
2. Storing and reading of servo parameters in flash = Done
3. 6 channel PWM generation = Done
4. 3 external interupts (Encoder A, Step / Enable) = Done
5. ADC = Not Done, Not Tested (but i guess it works...) :)
6. PID process is in place but can not be tested without hardware... :)
I will start building a power stage for testing this weekend, and an interface board with optocouplers and stuff that I can link with the power stage board and the STM32F4 Discovery board. (I am still waiting for the STM32f108 ebay boards, but I am sure that porting will be easy)
I am open to suggestions...
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
cool, i think 400w good for DIY machine
waitting you
-
1 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Good news...
The ARM servo drive project is rolling... Check out the progress so far:
https://www.youtube.com/watch?v=Xt3-MSbPQvk
Attachment 294508
Please note the PID frequency!!! 65 kHz :D (this is done with a stm32f4 discovery board that has a powerfull mcu (168 MHz) than the stm32f103...
Also parameters are now checked realtime with this software so you can know all the time what the status is, what is the error and so on...
Also firmware upgrade is now possible via USB (not with STLink) but directly with the usb cable used for servo tuning...
Status:
Encoder AB inputs and processing = done
PID algorithm in place and working but not optimized yet...
Current feedback in place and working = done
Tuning program = done, lots of new features, written in C#.
I will keep you updated...
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
mcm_xyz
Good news...
The ARM servo drive project is rolling... Check out the progress so far:
...
I will keep you updated...
Hello Mihai!
I found your threads (this one + AVR based) just a while ago. Very Impressive, thanks for sharing your designs! I've been working with very similar project for a while now. I have STM32F103 as well running on an ebay devboard and IR2101+IRFB3607 driver board. The difference is that I'm using HAL commutation at the moment, but I think I'll implement encoder or resolver interface when I receive some proper AC servo to try with. My initial setup is to have a simple PWM velocity input on my servo drive and have the encoder input + PID loop inside LinuxCNC, but having the full loop inside the microcontroller and having just step/dir or similar input would be more efficient I'm sure. But I'm taking small steps towards that. :)
One question raised when reading your threads. You mention at some point in the AVR development that you removed the sinusoid commutation tables and went to square wave (trapezoid) commutation. It was a bit unclear what was the reason behind this. Because when reading any papers about servo control, the sinusoidal commutation is always referred as the best method providing the smoothest torque. Did you see the opposite? Or was it just that the advantage from sinusoid commutation was not noticeable and it certainly is easier to implement the trapezoid commutation with limited resources like AVR.. I have implemented trapezoidal commutation myself as well, but I think I'll try sinusoidal at some point or even go to try some current based vector control. But your servo runs so nicely, so it's difficult to see the benefits of more advanced methods just now. But I'd be happy to hear your comments about this.
I'm planning to design a better driver PCB and probably a separate control board which sits somehow on top of the driver board. If you are going to share your software at some point, I'm eager to test it and of course if you (or anyone else) want to use my code or the forthcoming PCBs, I'm happy to share.
Pekka
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
roivai
Hello Mihai!
I found your threads (this one + AVR based) just a while ago. Very Impressive, thanks for sharing your designs! I've been working with very similar project for a while now. I have STM32F103 as well running on an ebay devboard and IR2101+IRFB3607 driver board. The difference is that I'm using HAL commutation at the moment, but I think I'll implement encoder or resolver interface when I receive some proper AC servo to try with. My initial setup is to have a simple PWM velocity input on my servo drive and have the encoder input + PID loop inside LinuxCNC, but having the full loop inside the microcontroller and having just step/dir or similar input would be more efficient I'm sure. But I'm taking small steps towards that. :)
One question raised when reading your threads. You mention at some point in the AVR development that you removed the sinusoid commutation tables and went to square wave (trapezoid) commutation. It was a bit unclear what was the reason behind this. Because when reading any papers about servo control, the sinusoidal commutation is always referred as the best method providing the smoothest torque. Did you see the opposite? Or was it just that the advantage from sinusoid commutation was not noticeable and it certainly is easier to implement the trapezoid commutation with limited resources like AVR.. I have implemented trapezoidal commutation myself as well, but I think I'll try sinusoidal at some point or even go to try some current based vector control. But your servo runs so nicely, so it's difficult to see the benefits of more advanced methods just now. But I'd be happy to hear your comments about this.
I'm planning to design a better driver PCB and probably a separate control board which sits somehow on top of the driver board. If you are going to share your software at some point, I'm eager to test it and of course if you (or anyone else) want to use my code or the forthcoming PCBs, I'm happy to share.
Pekka
Hello Pekka
Very nice to see your appreciation.
To answer your question quickly... those were old times... :) I was learning with the AVR Servo project about motors, and how to control them... So basically I started with a code that tried to move the motor freely... when no feedback there is no solution to make the motor spin nicely at lower speeds but to generate somekid of sinous signals, to make the trasition from one pole to another as smooth as possible... However when a PID process is used to control the output power, it will adjust the power very quickly and according to encoder position... Don't really know how to explain better... In fact if you would measure the output of a pid controller when motor is moving at a constant speed you would get a sinus... :D
So basically... When PID is in place for controlling movement sine commutation table is not a good idea...
I will publish soon the schematic and firmware... when I will make some tests with the STM32F103... for now I am testing with STM32F407 that is much faster...
You mentioned an ebay board with IR2101+IRFB3607... do you have a link? I just built one myself but such prebuilt boards could save time for me in the future...
Thanks!
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
mcm_xyz
Hello Pekka
I will publish soon the schematic and firmware... when I will make some tests with the STM32F103... for now I am testing with STM32F407 that is much faster...
You mentioned an ebay board with IR2101+IRFB3607... do you have a link? I just built one myself but such prebuilt boards could save time for me in the future...
Mihai
Thanks for your reply! Sorry, I wrote a bit misleading sentence. My driver board is home made as well, only the control board is from ebay ( Arm Cortex M3 STM32F103C8T6 STM32 Minimum System Development Board | eBay ). I have a possibility to mill prototype PCBs, so for me making boards myself is the easy part of this hobby. :) But like I said, I will design a driver PCB and have it manufactured somewhere and if it is something that you can use as well, I can make couple extra ones and send them to you.
I don't fully understand the drive method you have.. I may have a bit too academic approach because I haven't done that much in practice yet, just reading. :) But when you publish the software, I'll take a deep look and I'm sure I will learn a lot. Looking forward to that!
Pekka
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
thanks for sharing so much of your development. I was interested in the last one, but the use of daughter board makes this one a no brainer. Two questions:
1. Did I read right that you're still coding in MicroPascal? Any plan to port to C++?
2. Is the power stage the same as the last board?
-
2 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
S.A.C.
thanks for sharing so much of your development. I was interested in the last one, but the use of daughter board makes this one a no brainer. Two questions:
1. Did I read right that you're still coding in MicroPascal? Any plan to port to C++?
2. Is the power stage the same as the last board?
Hi hi hi...
My thoughts exactly...
The reason for not publishing till now is because I am moving to GCC ARM!
It took a long time for me to get familiar with the development environment (eclipse) and debugging and stuff. STM32CubeMX is really a nice tool that helped me a lot in generating the required configuration settings for my project.
What I can tell you is that so far I have implemented the following:
1. USB communication. The device is again a HID device, no drivers needed.
2. PWM generation. I've managed to start the Advanced TIM1 of the STM32F407. You can see in the oscilloscope bitmaps the signals, in perfect complement. Also dead time between HI and LO channels is configurable. (must check the IR2101 half bridge driver pdf for a good value) (see second picture)
3. EXT interrupts. We will still use EXT interrupts for the encoder, even if the STM32F407 can use it's second advanced timer for quadrature encoder capture. The reason for this is because STM32F103 (that is the final target for this project) has a single advanced timer and that is used for motor. Please somebody with more experience with STM32 check this: Can we use a standard timer for encoder capture?
4. Flash storage of the servo parameters.
Things not tested:
5. ADC conversion... but I am sure I'll do it... :D
Power stage remains the same with IR2101 and IRFZ44N mosfets (or what ever you want)...
So... This is becoming a truly open source project. In order to compile and flash you will need:
1. Eclipse with GCC ARM toolchain... (plenty of tutorials and things on the internet on how to setup, please do not even dare ask me how to do it... :) )
2. VS2015 Express (free) to build and modify Servo Drive Tuner app.
3. STLink utility and drivers...
I will keep you posted...
PS. STM32F407 has the bootloader in ROM. so no need to build and upload one, but STM32F103 does not. A bootloader will have to be compiled and uploaded to the cip if you want to use the firmware upgrade feature from the Servo Drive Tuner. But I think we can do it since the ST Bootloader code is free and can be compiled as it is...
Mihai
Attachment 294868
Attachment 294870
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
mcm_xyz
Hi hi hi...
My thoughts exactly...
3. EXT interrupts. We will still use EXT interrupts for the encoder, even if the STM32F407 can use it's second advanced timer for quadrature encoder capture. The reason for this is because STM32F103 (that is the final target for this project) has a single advanced timer and that is used for motor. Please somebody with more experience with STM32 check this: Can we use a standard timer for encoder capture?
4. Flash storage of the servo parameters.
Mihai
Hello! Thanks for your update!
Yes, you can use standard timer TIM2-TIM5 (General purpose timer as in datasheet) as well for the quadrature encoder capture. I've done it (with STM32F407, but works the same in STM32F1xx). Check chapter 15.3.12 in STM32F1xx reference manual.
Pekka
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
roivai
Hello! Thanks for your update!
Yes, you can use standard timer TIM2-TIM5 (General purpose timer as in datasheet) as well for the quadrature encoder capture. I've done it (with STM32F407, but works the same in STM32F1xx). Check chapter 15.3.12 in STM32F1xx reference manual.
Pekka
Many many thanks Pekka!!!
I've just stetted up the encoder counter on TIM2 (on stm32F407), this is a 32 bit timer... I will see if STM32F103 has 32 bit Timers... if no... Have no clue how to do it with timers... 16bit values are too small...
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Actually STM32F1xx has only 16-bit timers. But there is quite easy way to overcome that limitation. I have done it like this:
void getCount()
{
int16_t now = TIM3->CNT;
int16_t delta = now - oldcount;
oldcount = now; //oldcount is volatile int16_t global variable
count += delta; //count is volatile int32_t global variable
}
As you can see, here a difference between current value and the previous value is calculated and this is added to the 32-bit count-variable. Now you only have to make sure that the getCount function is called often enough that the actual 16-bit counter doesn't go more than 32k (15bit) steps between calls. So basically you call it in your PID loop and it works fine.
Pekka
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
roivai
Actually STM32F1xx has only 16-bit timers. But there is quite easy way to overcome that limitation. I have done it like this:
void getCount()
{
int16_t now = TIM3->CNT;
int16_t delta = now - oldcount;
oldcount = now; //oldcount is volatile int16_t global variable
count += delta; //count is volatile int32_t global variable
}
As you can see, here a difference between current value and the previous value is calculated and this is added to the 32-bit count-variable. Now you only have to make sure that the getCount function is called often enough that the actual 16-bit counter doesn't go more than 32k (15bit) steps between calls. So basically you call it in your PID loop and it works fine.
Pekka
Thanks for the suggestion! I think I will do it like this... In my latest tests with mikropascal I obtained with STM32F407 almost 200kHz for PID frequency... so it's damn fast... so I am pretty sure that it can make some additional calculations and still keep up the high frequency... and there is no interupt like this to disturb the mcu. After some tests I intend to move the PID update on a timer so it will execute at constant intervals... I guess 50KHz or even lower is enough...
Thanks again!
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hello guys!
Good news...
STM32F103C8T6 is the new core for my Servo drive...
Code is written in C and compiled with GNU ARM GCC, under eclipse. So far it's not really usable, current feedback is not present, external inputs for STEP / DIR / Enable are also missing. It's in the early stages. What is done so far:
USB Communication, Storing and Loading servo parameters in flash, PID process, Encoder Input (A and B are linked to TIM2 in encoder mode, Thanks Pekka!!!), PWM outputs are using TIM1 in advanced complementary mode.
PID Frequency is about 40kHz, with totally messed up code, at 72MHz... I am sure I can improve it in time... Movement is buttery smooth!!!, I presume because of the use of the complementary PWM channels...
enjoy!
Mihai!
Code and schematics really soon... I will not design a PCB because I do not intend to produce this for myself... So... show me your Eagle skills... :)
https://www.youtube.com/watch?v=6Pn04kHPXOk
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
mcm_xyz
Hello guys!
Good news...
STM32F103C8T6 is the new core for my Servo drive...
Code is written in C and compiled with GNU ARM GCC, under eclipse. So far it's not really usable, current feedback is not present, external inputs for STEP / DIR / Enable are also missing. It's in the early stages. What is done so far:
USB Communication, Storing and Loading servo parameters in flash, PID process, Encoder Input (A and B are linked to TIM2 in encoder mode, Thanks Pekka!!!), PWM outputs are using TIM1 in advanced complementary mode.
PID Frequency is about 40kHz, with totally messed up code, at 72MHz... I am sure I can improve it in time... Movement is buttery smooth!!!, I presume because of the use of the complementary PWM channels...
enjoy!
Mihai!
Code and schematics really soon... I will not design a PCB because I do not intend to produce this for myself... So... show me your Eagle skills... :)
https://www.youtube.com/watch?v=6Pn04kHPXOk
give schematic, i will layout
-
2 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hello guys!
Here is the schematic... I do think there will be no change in the pinouts of the STM32F103C8T6 MCU.
So far we have:
PA0, PA1 = Encoder A and B Inputs, used in TIM2 encoder counter
PA3 = ADC in
PB4, PB5 = STEP / DIR inputs, used in TIM3 encoder counter
PB6 = ENABLE input, used as EXTI
PA8, PA9, PA10, PB13, PB14, PB15 = TIM1 advanced motor timer outputs
PC13, PC14 = Error and Status Leds and outputs
THINGS already on the STM32 board, in case somebody decides to make a schematic with the MCU directly... will need to solder usb, oscilator, and JTAG(SWI) interface connector:
PA11, PA12 = USB
PD0, PD1 = OSC
PA13, PA14, PA15, PB3 = JTAG
Lets make this, guys!
Mihai
PS. Please feel free to change the schematics as needed. Like if you want to drop the VRegs... do it, and add connectors for 5 and 12-15V regulated inputs... and so on...
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
mcm_xyz
Hello guys!
Here is the schematic... I do think there will be no change in the pinouts of the STM32F103C8T6 MCU.
Mihai
PS. Please feel free to change the schematics as needed. Like if you want to drop the VRegs... do it, and add connectors for 5 and 12-15V regulated inputs... and so on...
Hello Mihai,
Nice progress again!
I've been working with my own version of the very same thing. I decided to divide my drive into two boards, driver and the controller. Mostly because I like the modular approach, I probably screw up something, so I do not need complete redesign / rebuild if I change something. :)
Anyway, I've started by designing the driver board. It is essentially equal to your schematic. I'm planning to mount my control board above the driver board. The driver board is only 5x10cm, so I think it's quite compact and PCBs with that size are super cheap. I also included some current sense amplifiers, so I can measure small currents and still use small shunt resistors. I included also phase current measurement for two phases if I ever happen to try current based position sensing.. But all those can be left unmounted if not used in the beginning..
Next I'll design the controller board and I will try to match your pinout so that your software would be directly compatible with my board. The difference will be at least that I'll include also support for HALL sensors as I'm using them for commutation at the moment. I will directly mount the STM32F103 to the controller board, as I own plenty of them already.
You can check my driver board from:
http://pekka.eu/cnc/bldc_driver_sch.pdf
http://pekka.eu/cnc/bldc_driver_layout.png
Pekka
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hi,
its possible to a isolated current sensor? There are some available for Arduino?
Thanks
Hans
-
2 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hello guys!
Here is the first (very alpha) version of the software. Does not have Enable input, and current sensing...
at 72MHz the PID frequency reached is around 60kHz...
Tools used:
1. eclipse Mars.1 Release (4.5.1)
2. gcc-arm-none-eabi-4_8-141002
3. eclipse plugin: GNU ARM C/C++ Cross Development Tools (filename: ilg.gnuarmeclipse.repository-2.9.3-201508190739.zip)
4. CoreUtils, Coreutils-090604.msi
5. OpenOcd 0.9.0
enjoy...
Mihai
-
2 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
It's me again... :)
Here is a better version of the firmware... has also current sense in place... and the enable signal input...
Code it's a mess, very little comments and very ugly written... Sorry about that... I am not a C developer... :)
The PID Frequency has decreased to 48kHz after adding ADC in interrupt mode... I do not think DMA mode ADC would do in out case as we need very little lag in measuring the current...
Anyway, it's pretty accurate... and 48 kHz it's really nice...
enjoy video...
Mihai
https://www.youtube.com/watch?v=3pDLmSwuHiU
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
mcm_xyz
It's me again... :)
Here is a better version of the firmware... has also current sense in place... and the enable signal input...
Code it's a mess, very little comments and very ugly written... Sorry about that... I am not a C developer... :)
The PID Frequency has decreased to 48kHz after adding ADC in interrupt mode... I do not think DMA mode ADC would do in out case as we need very little lag in measuring the current...
Anyway, it's pretty accurate... and 48 kHz it's really nice...
Thanks for publishing the code. And don't be too hard on yourself, your code was very readable and actually I'm impressed how simple the firmware actually is. I was able to compile it right away. I did not upload it to actual hardware as I don't have anything suitable on the table right now, but will do maybe tomorrow.
The tuner software is a bit trickier for me as I don't own a Windows PC at the moment.. :) I tried running the code on Linux with Mono (Opensource alternative to MS C# runtime libraries) and after a bit of commenting your code (had to remove the chart area and customprogressbar which seemed not compatible with Mono) I was able to launch the gui at least. But having no hardware I cannot say for sure if the USB connection works. I'll come back to you when I know.
Thanks for your hard work!
Pekka
-
Quote:
Originally Posted by
roivai
Thanks for publishing the code. And don't be too hard on yourself, your code was very readable and actually I'm impressed how simple the firmware actually is. I was able to compile it right away. I did not upload it to actual hardware as I don't have anything suitable on the table right now, but will do maybe tomorrow.
The tuner software is a bit trickier for me as I don't own a Windows PC at the moment.. :) I tried running the code on Linux with Mono (Opensource alternative to MS C# runtime libraries) and after a bit of commenting your code (had to remove the chart area and customprogressbar which seemed not compatible with Mono) I was able to launch the gui at least. But having no hardware I cannot say for sure if the USB connection works. I'll come back to you when I know.
Thanks for your hard work!
Pekka
Hmmm... The code for the tuner program uses lots of references to usb hid dlls from windows... I do not think they will work on Linux. However the app is simple... I bet there are already made programs for linux that can send simple texts to a usb hid device... The only thing that is not text is the servo response matrix.
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Yet another issue...
The STEP / DIR inputs are mapped right now to Ext Interrupts... From what I've read it's possible to configure the Tims in encoder mode and read a pulse + direction signal... strange but I did not managed to do that yet... all I can get in the tim3 register is the direction change...
I am working on that now...
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
hello Mihai
I am really impressed at your project, I'm sure it will be work perfectly. I have a question, do you plan add "step multiplier "option ? Sometimes if encoder resolution is to big the Mach3 will not be able send step signal as fast as need.
Kamil.
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
kamilkamil1
hello Mihai
I am really impressed at your project, I'm sure it will be work perfectly. I have a question, do you plan add "step multiplier "option ? Sometimes if encoder resolution is to big the Mach3 will not be able send step signal as fast as need.
Kamil.
Should not be a problem to add such feature... Also there are several modes to count encoder pulses... Right now we count all (both raising and falling on both A and B channels), but the encoder counter could be configured differently also...
Will add in the next version a configurable step multiplier. I guess 1 to 10 should do...
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hello Mihai,
in what kind of way can the controller check the rotorposition, when the controller is switch on the first time?
There are no inputs for hallsensors or similar.
Thanks
Hans
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
I've been investigating the bootloader embeded in the ROM of STM32F103 MCU. It only supports USART so it's not really useful since we already have USB. So I modified and compiled a USB DFU mode bootloader (taken from ST website: http://www.st.com/web/en/catalog/tools/PF258157) in order to have the USB firmware upgrade feature... The servo firmware was modified to be able to enter the new bootloader from program.
The bootloader code was compiled in IAR (I was too lazy to setup the project in eclipse...), but it is very little and I think you can compile in the Demo version of IAR.
Also we might add a jumper in order to put the device in the new bootloader mode (BOOT0 and BOOT1 pins can not be used because they put the cpu in the embeded bootloader)
I will come back with code, schematic and compiled firmwares...
Mihai
PS. I have in mind to set up a folder in some webserver folder and to add the "update from internet" feature to the Servo Drive Tuner program...
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
Holzwurm56
Hello Mihai,
in what kind of way can the controller check the rotorposition, when the controller is switch on the first time?
There are no inputs for hallsensors or similar.
Thanks
Hans
Power is applied to 2 inputs of the motor in a gradually mode on initialization. This will move the rotor to a known position. (yes, it's a minus but I do not really care because I always remake the HOME reset on my cnc on powerup)... From there the angle of the shaft is computed from the encoder position and the number of PPR of the encoder...
Check out function PWM_Init_Motor from unit pwm.
If some want to use hall sensors, the code in function PWM_Set_Duty must be changed. The values in p1, p2 and p3 must be taken from the Hall sensors and not my commutation tables... That's all...
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
mcm_xyz
PS. I have in mind to set up a folder in some webserver folder and to add the "update from internet" feature to the Servo Drive Tuner program...
If it helps, massmind.org is at your disposal.
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hello Mihai,
many thanks for your answer. You are a super software developer but It`s not possible for me to write one line of code. I want only know the prinzip of checking the rotorposition.
Thanks
Hans
-
3 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hello guys!
Here is the latest code for you!
It contains:
1. Bootloader code and binary file.
2. Firmware code and binary (debug version).
3. Servo Tuner Utility code and binary.
There is a new feature, maybe someone may want to add some jumpers to the schematic. If you link the pin PB1 to 3.3 V and reset the mcu it will enter USB DFU Bootloader mode. The program is capable of entering bootloader mode with the command "UPG".
Also there is a Step multiplier field as requested...
In order to flash the first time you will have to flash via StLink with the images: BootLoader.bin and F103ServoDrive.hex (order is not important). Then you can upgrade firmware from USB from the Servo Tuner Utility (Menu File > Update servo firmware)...
Please note that you will need dfu files in the Servo Tuner Utility. You can convert HEX files to dfu files using DfuFileMgr.exe utility included in ST app from link: STSW-STM32080 DfuSe USB device firmware upgrade STMicroelectronics extension: contains the demo GUI, debugging GUI, all sources files and the protocol layer (UM0412) - STMicroelectronics
Mihai
PS: I'm still waiting for a board... :) please... share your works...
If you compile in release mode you get a PID frequency up to 54 kHz...
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Quote:
Originally Posted by
tivoidethuong
Nice work... I can not tell I fully understand... Where is the USB connector? Why the 15 pin connector?
Anyway... I am waiting for someone to make a nice PCB for this project... I am interested in buying some... :)
The idea of to have 2 boards (one for low power logic and one for high power part) seems to be very nice... One on top of the other with some connectors between them...
It would be super cool!
Mihai
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
Hi,
I think the board will be createt with the minimum development board. Some hobby machinists or electronic are not able to solder smd parts. I thinks its a good idea to make a power pcb and a isolated controller pcb with a isolated current sensor. Maybe the power pcb with integratet bridge like IRAMX20xxxxxx and a control of the integratet thermosensor.
Thanks
Hans
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
May I make a suggestion on the PCB? One barrier to entry which will keep a lot of people from trying, testing, contributing to this project is the fine pitch SMT soldering required for that processor. If you could use an /existing/ development board as the basis for the PCB, assuming one exists, it would really help people to get involved. There is no reason why you can't /also/ layout a section for the actual processor, but providing an option to easily connect to an existing development board is an important step, in my experience. It could be as easy as simply providing well labeled "test points" so that a cable can be run from the dev board to the PCB in place of an onboard processor.
-
1 Attachment(s)
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
-
Re: DIY BLDC / DC Motor Servo Drive - ARM MCU (STM32F103C8T6)
I'm sure that could be made to work... but ideally, it should be something that can be directly soldered in place, and that one, with the pre-soldered headers, would make that difficult. I was thinking of this much less expensive one:
STM32F103C8T6 Arm STM32 Minimum System Development Board Module for Arduino DHU | eBay
Or at least of something like that one. Where the headers can be put on the bottom, and are simple straight headers.