EcoModder Forum Paul and Sabrina's Cheap 3 Phase Inverter (AC Controller) with Field Oriented Control

Register Now
 Remember

 07-29-2017, 10:38 AM #3141 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts Computing Kp and Ki ahead of time without having the controller search for it: Kp = 2000 * pi * L * 8192 * 1702 * LEM / (Voltage * 2048) Ki = (2000 * pi) * R * 8192 * 1702 * LEM / (Voltage * 2048 * 10000) Voltage is in units of voltage. haha. LEM means current per 0.625v rise in output of sensor. The LEM Hass 300-s for example goes up 0.625v for every 300amp, so "LEM" in that case would be 300 (that's why I called that variable LEM). The Kp and Ki that results would be the biggest I would use. it might be better to even cut both of them in half. But it would work. Note: R above means the resistance of 1 of the phases. L either means stator inductance or "mutual inductance" or something like that. But you don't need to compute Kp using that formula. All I do is find Ki, and then Kp is about 60*Ki (50 to 100 would be OK). That's because the inductance and resistance ratio is always about the same for all motors because the more copper you wind, the bigger the inductance. For using a potentiometer rather than hall effect throttle, you would need to populate R2 with maybe 1k? And then populate R1 with about 4.7k. The BOM calls for R2 to be empty and R1 to be 47k, but that is for the case of the hall effect throttle. Try this: After changing those resistor values, set it to max throttle, and then type config (noting where raw throttle position is). Then, set it to min throttle and hit config. I haven't tested anything with a pot rather than hall effect, but maybe thingstodo has. I would set the throttle max and min variables based on what you see when you do that test. __________________ kits and boards
 Today Popular topics Other popular topics in this forum...
Master EcoModder

Join Date: Sep 2010
Posts: 1,488

Ford Prefect - '18 Ford F150 XLT XTR

Tess - '22 Tesla Y LR
Thanks: 747
Thanked 565 Times in 447 Posts
Quote:
 Originally Posted by MPaulHolmes Try this: After changing those resistor values, set it to max throttle, and then type config (noting where raw throttle position is). Then, set it to min throttle and hit config. I haven't tested anything with a pot rather than hall effect, but maybe thingstodo has. I would set the throttle max and min variables based on what you see when you do that test.
If you set your pot to minimum, type config and write down the number
Set your pot to maximum, type config and write down the number

Let's guess that you get 500 for minimum and 700 for maximum (based on your description). I'd change these numbers

max-regen-position=0042
min-regen-position=0339
min-throttle-position=0539
max-throttle-position=0837

to these numbers

max-regen-position=0042
min-regen-position=0510
min-throttle-position=0539
max-throttle-position=1023

For testing, you would get a small amount of reverse, only the part from 510 down to 500. If I guessed wrong and your numbers are different, give yourself about 10 counts of reverse that you can get to just to show that it works.

You still have a deadband where the motor does not turn, from 510 to 539. It needs to be big enough that you can easily get the motor speed to 0

I doubt that your reading will go up to 1023 so you will get less aggressive acceleration for your testing, but you won't be able to get to max speed.

Have fun!
__________________
In THEORY there is no difference between Theory and Practice
In PRACTICE there IS!

 The Following 2 Users Say Thank You to thingstodo For This Useful Post: MPaulHolmes (07-29-2017), shaggythegangsta (07-29-2017)
 07-29-2017, 11:51 AM #3143 (permalink) EcoModding Lurker   Join Date: Mar 2016 Location: italy Posts: 40 Thanks: 5 Thanked 2 Times in 2 Posts [/QUOTE] For using a potentiometer rather than hall effect throttle, you would need to populate R2 with maybe 1k? And then populate R1 with about 4.7k. The BOM calls for R2 to be empty and R1 to be 47k, but that is for the case of the hall effect throttle. Try this: After changing those resistor values, set it to max throttle, and then type config (noting where raw throttle position is). Then, set it to min throttle and hit config. I haven't tested anything with a pot rather than hall effect, but maybe thingstodo has. I would set the throttle max and min variables based on what you see when you do that test.[/QUOTE] First off all thanks for fast response and thanks also for explaning the PID tuning part.. it would help me tuning the system response.. But for th throttle mapping part i could not find the R1 and R2... in the schematic files that i have resistors involved in throttle part are R51 AND R52. take a look at that part of code https://ibb.co/jvFKvQ
 07-29-2017, 11:53 AM #3144 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts I forgot you have a different board. haha. Whichever resistor is connected to +5v I would use 1k. __________________ kits and boards
 The Following User Says Thank You to MPaulHolmes For This Useful Post: shaggythegangsta (07-29-2017)
EcoModding Lurker

Join Date: Mar 2016
Location: italy
Posts: 40
Thanks: 5
Thanked 2 Times in 2 Posts
Quote:
 Originally Posted by thingstodo If you set your pot to minimum, type config and write down the number Set your pot to maximum, type config and write down the number Let's guess that you get 500 for minimum and 700 for maximum (based on your description). I'd change these numbers max-regen-position=0042 min-regen-position=0339 min-throttle-position=0539 max-throttle-position=0837 to these numbers max-regen-position=0042 min-regen-position=0510 min-throttle-position=0539 max-throttle-position=1023 For testing, you would get a small amount of reverse, only the part from 510 down to 500. If I guessed wrong and your numbers are different, give yourself about 10 counts of reverse that you can get to just to show that it works. You still have a deadband where the motor does not turn, from 510 to 539. It needs to be big enough that you can easily get the motor speed to 0 I doubt that your reading will go up to 1023 so you will get less aggressive acceleration for your testing, but you won't be able to get to max speed. Have fun!
Thanks sir i will give a try update you guys.. thanks again for helping

EcoModding Lurker

Join Date: Mar 2016
Location: italy
Posts: 40
Thanks: 5
Thanked 2 Times in 2 Posts
Quote:
 Originally Posted by MPaulHolmes I forgot you have a different board. haha. Whichever resistor is connected to +5v I would use 1k.
And R51 AND R52 same values as indicated on the schematic?

 07-30-2017, 12:19 PM #3147 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts same values as indicated on what schematic? __________________ kits and boards
EcoModding Lurker

Join Date: Mar 2016
Location: italy
Posts: 40
Thanks: 5
Thanked 2 Times in 2 Posts
Quote:
 Originally Posted by MPaulHolmes same values as indicated on what schematic?
I mean here https://ibb.co/jvFKvQ
I already tried this configuration.. i get 4.7volt to 5volt
Adc values from 962 to 1020.. and throttle mapping just does not work..

Then i connected the potentiometer to anlaog input getting raw_throttle from 0 to 1023...
Now in the middle i have 0 throttle.. then it goes to max negative and max positive. So i think the throttle mapping now it ok.
But the motor turns only in one direction is it normal? When the throttle values is negative it should not be changing the rotation direction?

Other question is how can i set the maximum rpms? Because now it goes up to 4000rpms when thw throttle is maximum

And thanks guys for helping

EcoModding Lurker

Join Date: Apr 2010
Location: Cali
Posts: 35
Thanks: 3
Thanked 4 Times in 3 Posts
Quote:
 Originally Posted by MPaulHolmes Hello! I don't think there's a difference between PMAC and brushless DC. Well, I think sometimes PMAC wants a pure AC waveform for best results, and brushless DC wants trapezoidal? But I'm not sure. Also, both motors work fine with an AC waveform. If it's a permanent maget motor, and you have an encoder, you shouldn't need different firmware. You might just have to set the number of pole pairs, motor type (permanent magnet with encoder) etc. That would be absolutely awesome to go through the whole tuning process and everything. That's something that I should have done and never got around to doing.
Hey! Long time no join this conversation. Finishing my computer engineering degree, looking for a job has had me busy.

You're correct on the differences between PMAC and Brushless IF the PMAC is single-phase. Just a difference of optimizations for field-to-field contact, should be pretty small in differences too.

There are PMAC motors that are three-phase and will run MUCH less efficiently wired in single-phase or PWM. Due to mismatched PM-field to AC-field alignment in timing. If it's a motor they bothered to do such optimizations for, anyway. Unoptimized designs I wouldn't be surprised if they don't account properly and act like single-phase anyway.

Exact optimal waveform for PMAC is typically sinusoidal. BLDC... vary. I've seen a few list triangular, some trapzoidal, some CLAIM square(but we well know true square waves are a pipedream). Trapizodal seems the best assumption though since it makes the most physics sense. (I've seen triangular on fine motion motors, nowhere else.)

Been great watching this controller become a thing.

 08-01-2017, 01:49 PM #3150 (permalink) Master EcoModder     Join Date: Aug 2012 Location: northwest of normal Posts: 25,886 Thanks: 7,294 Thanked 8,118 Times in 6,658 Posts When I try to figure this out, there is a set called 'polyphase DC'. Is that a thing?