# DIY Controller for '04-'09 Prius A/C Compressor



## jyanof (Nov 11, 2008)

*Electronics/Control*

The electronics and sensorless control method kind of go together. I searched all over the internet about how to control a permanent magnet synchronous motor. There's the trapezoidal drive approach used by the hobby motor controllers, but some things I read led me to believe that sinusoidal drive would be better. Mostly, I came across this blog by a guy named Shane Colton who was playing around with scooter motors a while ago. He wrote a few papers for grad school about a less computationally intensive approach for sinusoidal field oriented control of pmsm's.

I found this particular post very informative for general stuff about motor control. 

Then there's his paper on flux based sensorless position estimation.

There's also this archive post and this page about all of his different iterations of controllers.

So full blown FOC would require measuring 2 of the 3 phase currents and using some trig to transpose those current vectors into the rotor reference frame. Then, use some control logic to figure out where the next current vector should be (still in the rotor reference frame) and use some more trig to translate that back to the 3 phases for the next PWM cycle. That last bit of trig is computationally expensive and requires some fast processors. 

Shane proposes to avoid that by separating the sensorless position estimation into a fast processing loop and the field oriented stuff into a loop that processes less often. The fast loop runs every PWM cycle and tracks something called the 'rotor flux linkage' for each phase as it spins. I'll admit, I'm still fuzzy on all this motor theory, but hey - it works. The rotor flux linkage for each phase is a sine wave that passes through 0 twice for each electrical cycle corresponding to the position of the rotor. The three phases are offset by 120 electrical degrees, so monitoring the 3 phases will give 6 zero-crossings (one every 60 degrees) in one electrical cycle. These zero crossings are used like hall effect sensors for feedback into the control algorithm for rotor position update. Then, in this slower loop, the current vector in the rotor reference frame is controlled by the PWM magnitude and phase advance. No more expensive trig!

This was attractive to me since my experience is with slow 8-bit AVR microcontrollers. I wasn't sure it would work, but I went with the AT90PWM3b at 16mhz. spoiler - it does work, but the sensorless algorithms use up nearly 80% of the processing time on a 15.6 khz PWM cycle. I'm currently drawing up a circuit with an xmega, the next level up in processor.

Here's a picture of the PCB I etched up to play around with this. It's super simple.

- In the middle is the micro.
- The big thing at the bottom left is a dcdc converter to get 15v
- the blue pots and small smt chips are a nand circuit for hardware shutdown on an overcurrent event.
- on the right side, top and bottom, are two small 30A current sensors. 
- also on the right side, under the PCB bolted to the heatsink, is the IGBT chip. This thing has been pretty awesome as it has the low and high side drivers built into the whole package which already has the three phase bridge. So, on the power side, supply the power source and connect the bridge outputs, and in the control side, supply power, high/low inputs for the 3 phases, and a high/low shutdown pin. Oh, all for 20 bucks! In fact, I've already blown one up and it was pretty easy to cut out, unsolder, and replace. Not sure if it'll end up being powerful enough in the end, but good enough for testing and playing around.










next up, some initial results...


----------



## jyanof (Nov 11, 2008)

The video below is pretty boring - it's just the motor spooling up and down, but I was pretty damn excited to get the sensorless code to work.







The serial data streams data from a point in time about 10 times per second, so nowhere near fast enough to get a continuous plot of parameter data. But, the gather enough data over constant conditions and there's enough to plot.

For example, here's a plot of the three phase currents vs rotor position. Phase 1 actually isn't measured, but is calculated from Phase 0 and 2. The rotor position also isn't actually measured, but interpolated between the feedback points from the sensorless algorithm. Assuming the sensorless stuff is working well, this should be pretty accurate. This is probably 20-30 seconds worth of data.












Here's a similar plot of the flux linkage. These are calculated by integrating (Vphase - Current_phase*R_phase) over time and then subtracting (current_phase * L_phase). This calculation also gets high-pass filtered so that it mostly stays vertically centered. I have no idea what the units actually are on the x-axis since everything is scaled to work using integer math. The software watches for zero crossings and then updates the internal rotor position estimator if it's behind or ahead. Since the position estimator is essentially the x-axis, it's not really surprising that the zero-crossings happen every 60 degrees at the expected times. But, the curves are pretty smooth and mostly sinusoidal, and the motor runs in sensorless mode.


----------



## nimblemotors (Oct 1, 2010)

Why not just add some position sensors?


----------



## jyanof (Nov 11, 2008)

There's a lot of info out there on non-salient permanent magnet AC motors. These have surface mounted magnets, a constant inductance, and for field-oriented-control, operate most efficiently when Id is zero.

I haven't found much info on salient motors, other than they have interior mounted magnets, an inductance that varies with rotor angle, and Id is non-zero for efficient operation.

So I set up a simple experiment where the motor runs at constant speed and thus, constant power and torque. Then, vary Id over a reasonable range and measure the input current and voltage to find the value of Id that gives minimum input power.

Here's a plot at 1000 RPM at about 55W. The input power and Iq are plotted against Id. It's pretty obvious where the min input power occurs.













Here's a similar plot at about 110W also at 1000 RPM.










Do this over enough power settings and an "optimum Id" can be plotted against Iq. 









The compressor will probably spend most of its time out to the right, anyway. Assuming it draws 1500W as an actual a/c compressor at 6000 rpm, Iq will probably be somewhere around 12-15A, I think.

Actually that's another question I had - has anyone measured the phase current to the a/c on an actual prius? I actually don't know anyone with a 2nd gen model.


So, not sure if this is the best way to optimize the motor control, but it makes sense to me. Also not sure if things will change at higher speeds.


----------



## jyanof (Nov 11, 2008)

nimblemotors said:


> Why not just add some position sensors?


I suppose I could while I have it on the bench for testing. In fact, I had thought about marking up the coupler every 15 degrees or something and using some sort of optical sensor. But, that was in case I had trouble with the sensorless stuff. 

So, while I don't have an actual position measurement to compare with the estimated position, I figure it must be good enough if the stability is good.

In the actual application, the compressor looks like this and is totally enclosed. There's no room for a sensor and if I get a working compressor, I don't really want to take it apart, much less hack something in there that has to work in that oil/refrigerant environment. But yeah, things would be pretty easy with a position sensor.


----------



## eldis (Sep 3, 2013)

You could harvest the Prius AC controller from the inverter assembly. In the previous generations this was completely decoupled (controller mounted on the bottom of the inverter). So just providing power to this module and getting a CAN bus capture, you could then easily turn it on and command the AC power directly. It will work on 144V, as the NiMH Prius battery also tends to move around a lot.


----------



## jyanof (Nov 11, 2008)

eldis said:


> You could harvest the Prius AC controller from the inverter assembly.


I had thought about using the latest compressors that have the built-in controller. If I were using its AC controller, may as well use the whole compressor. That is probably the most elegant solution for electric a/c. I went with the 2nd gen model for a couple of reasons:

- At the time, I knew nothing about CAN or PMSM motor control. The latter seemed more fun to learn.
- The older generation compressors are a little cheaper and more abundant. In fact, I just picked up a (supposedly) functional used compressor for $75.

But, if I have troubles with this route, maybe I'll pick up a 3rd gen compressor and find someone with a prius who'd let me tinker with the CAN communication.


----------



## eldis (Sep 3, 2013)

jyanof said:


> - At the time, I knew nothing about CAN or PMSM motor control. The latter seemed more fun to learn.
> - The older generation compressors are a little cheaper and more abundant. In fact, I just picked up a (supposedly) functional used compressor for $75.


Don't get me wrong, I like your approach  please keep us updated on your progress.

I've never had a chance to play with an AC compressor, but intuitively I would expect that they don't require much torque to spin from stand still, and then cooling power is somewhat proportional to RPMs of the compressor (where higher RPM means more resistance of the gas/fluid?) Then your sensorless approach is more than adequate - difficult thing is to give the rotor an initial spin under load, as the rotor state is unknown. In this case the rotary field should be easy to generate (low RPM->low load?) Once the EMF is high enough to be detected, your algorithm will have an easy job of maintaining it.

What kind of power do you think it will be needed to run the AC on full power?


----------



## jyanof (Nov 11, 2008)

eldis said:


> ...but intuitively I would expect that they don't require much torque to spin from stand still, and then cooling power is somewhat proportional to RPMs of the compressor (where higher RPM means more resistance of the gas/fluid?)


I agree, the starting torque should be pretty low and stay low at low speeds. I bet power is proportional to speed squared since higher speed means higher pressure and higher flow. Torque would probably then be linear with speed.

Anyway, one thing I know with house a/c compressors - after a shutdown, the scroll kind of siezes in its housing probably due to high thermal variation. Thus, there can be a very high start torque if you try to start it again before it cools down. Not sure what happens with the prius compressor.



> What kind of power do you think it will be needed to run the AC on full power?


Not sure exactly, but there's this PDF floating around that states the cooling performance of the ES18 compressor at 7500 rpm to be 3.4 kW. Everywhere else, though, says that the compressor runs at 6000 rpm. But, 3.4 kW is 11,500 BTU/hr, so that's probably about right for an automotive a/c. Then it just depends on the efficiency of the compressor. Scrolls are efficient, and so are PMSMs, so maybe a coefficient of power of 3 (analogous to SEER ratings for residential units). 3.4 / 3 = about 1.1kW of electrical power. If COP were only 2, that's 3.4/2 = 1.7 kW, which still doesn't sound too bad. 

I'm just guessing though, will just have to build it and see what we get!


----------



## eldis (Sep 3, 2013)

Nice  Now probably quite a basic question - could you actually heat up your car with this (or similar) AC setup?
I've seen some statements here in the past, that heating up with AC would be so much more efficient, but I haven't seen anyone actually demonstrating anything like that in a car.


----------



## jyanof (Nov 11, 2008)

eldis said:


> ...could you actually heat up your car with this (or similar) AC setup?


Yep, it should be doable. Essentially, the evaporator and condenser switch places in the car and the system moves heat into the car instead of taking it out. My house has a heat pump that does this - it works fine in AZ, but starts to get less efficient the colder it gets outside. Below 40F, it hardly works at all. I think automotive a/c systems would have similar limitations.

But, as long as it isn't too cold outside, it's more efficient to move heat than it is to just turn electrical energy directly into heat. The system would need a valve and extra plumbing to reverse the flow of refrigerant, and the expansion valve would probably have to replaced with a capillary tube. So, it can get complicated which is probably why it isn't done much.

I've heard that some of the new OEM EV's do this though, but not sure on that.


----------



## jyanof (Nov 11, 2008)

I've been using some 3s hobby lipos in series to raise the source voltage. I'm up to 68V now and was able to get the motor up to 4000 rpm. Here's the video - again, it's just the motor spooling up and down, so pretty boring. 

There are some shots of this program called kst2 that i'm using the plot the incoming serial data in real time. It's pretty good for being free.


----------



## jyanof (Nov 11, 2008)

Ok, going full in now...

At 4k rpm, that test rig got pretty shaky. I think the motor is counterbalanced to offset the imbalance of the scroll, so since i'm running without the scroll in the test rig, it's not balanced at all. But, I think the controller is working well enough to test in the car as an actual a/c compressor.

Went down to the local auto shop and had them evacuate my current a/c system, then went home and broke the system all apart. I had bought some prius hoses on ebay just to use the compressor fittings and the guys at AZ Tube and Hose built some new hoses for the compressor.

Here's everything out of the car. Apparently, normal PAG oil will eat away at the enamel coating of the motor windings so a special oil needs to be used. Toyota calls it ND-11 and there is some aftermarket stuff just called 'hybrid compressor oil'. 

In any event, everything needs to be flushed to get the old oil out. I found a place that would flush everything for $45 which I thought was a great deal. 










I also mounted the used functional compressor in the car, bought a new expansion valve and drier, some pure 134a refrigerant, and the hybrid compressor oil. This should all get together this next week or so.


----------



## bigmotherwhale (Apr 15, 2011)

I dont see why you have to mount a different motor to the compressor, its already a good little unit, if you cant get it to work from the existing electronics which shouldnt be too hard by using a modified 1kw dc to 240v inverter, all you would have to do is solder some wires on to the high voltage capacitor and you will be provided with 320v DC connect that to your prius compressor module and your half way there....

if you cant figure out the electronics to drive it directly, just use a dc to 240v inverter (pure sinewave) and a capacitor connect it directly to the motor phases and it should spin... or a use a small 3 phase inveter. 

mounting different motors to it when the one thats on there is perfect seems like a waste of time. 

All the best.


----------



## jyanof (Nov 11, 2008)

bigmotherwhale said:


> mounting different motors to it when the one thats on there is perfect seems like a waste of time.


Agreed! You must've misread something because that's not what I'm doing.

In other news, the functional compressor is mounted in the car on some rubber standoffs. Also added in 4.5 oz of hybrid compressor oil, had the system evacuated, and charged with just one can of 134a. That's most likely not enough refrigerant, but I'll wait until I can get the compressor up to full speed before filling the rest.

Here's the mounted compressor:










I'm planning to utilize the cool suction line as a heatsink for my 3 phase BLAC controller. When the hoses were made, I asked for a section of straight hardline to which some aluminum plate could be clamped. Here's two half inch plates with a half inch hole drilled through (it was drilled with a 5 thou shim so that there would be a 5 thou interference with the hard line) and here it is trial fitted in the car.



















This has got to be better for cooling the IGBTs than a finned heatsink in that hot compartment. 

I actually had the compressor spinning with my controller up to about 2000 rpm with 50V of hobby lipos as a source. High side was up to about 110 psi and low side was around 40 psi and cool air was coming out of the vents. It was only 75F outside, so the system wasn't working too hard, but I'll take a little success!

Thermodynamically, I think it's going to work. Next steps are to:

- hook up the controller to pack voltage (144V), see if anything blows up, and push the compressor speed higher. Hopefully the sensorless algorithm continues to work at the higher speeds.
- put together a suitable controller board. The one I have now is pretty shady and lacking some things needed to really implement into the car. I'm working on a design using an xmega16A4U and will share if it works.


----------



## jyanof (Nov 11, 2008)

Oh, and eldis asked about the starting torque... Even though I was running from low voltage, I did a number of starts. Similar to household hvac units, there's more start torque upon a restart vs nearly no start torque when the system first starts. 

The first time it started, everything was fine. After that, the compressor was essentially locked and the open-loop start ramp didn't have enough torque to un-seize it. 

Increasing the open-loop torque fixed the issue, but got me thinking that the program should be able to detect a failed start. I'm betting this start torque gets worse with a fully charged system in the hottest time of the summer.

The sensorless algorithm does a pretty good job of estimating the rotor speed during the open-loop ramp. In fact, it still estimates what the speed should be even if the rotor is locked. Well, kind of - if the rotor is locked, the estimated speed will jump around a bit whereas it'll be a nice smooth ramp if the start is normal. So now, the code looks for a constantly increasing speed during the ramp cycle and aborts the start if it doesn't see it. Self protection!

Oh, and the compressor is ridiculously quiet too. Completely inaudible with all the fans running.


----------



## eldis (Sep 3, 2013)

jyanof said:


> Oh, and eldis asked about the starting torque... Even though I was running from low voltage, I did a number of starts. Similar to household hvac units, there's more start torque upon a restart vs nearly no start torque when the system first starts.


Congratulations and thanks for writing this!
Stupid suggestion - what if you would try to run the compressor backwards after the failed start? Would it lower the pressure and allowed you to start the correct way?


----------



## jyanof (Nov 11, 2008)

eldis said:


> what if you would try to run the compressor backwards after the failed start? Would it lower the pressure and allowed you to start the correct way?


Not sure! I think there's actually a check valve after the scroll. I couldn't tell for sure, but on the scrapped compressor I have, there appears to be something that'd act like a check valve. there's also some stuff on the web that talks about check valves with scroll compressors.

This would actually fit with what I see on the high side pressure when the compressor shuts down - it stays pretty high, around 100 psi for a while, even though the low side is down around 60 or 70. I think the high pressure refrigerant is getting trapped between the compressor check valve and the expansion valve. Not sure if that's normal, I didn't think the expansion valve would actually close all the way down.

In the end, I don't think that turning the compressor backwards would reduce the high side pressure because of the check valve. Though it also means - since the high pressure is kept back by the valve - that the scroll doesn't have to fight it during a start. So, maybe the locked scroll is a result of some thermal gradient. Or, maybe this used compressor is a bit worn already.

I could try spinning it backwards anyway, but at the moment, my code uses up nearly the entire flash memory of the AT90PWM3B and I had to strip some things down that would make it hard to be able to easily reverse direction. The xmega has more memory, or maybe I'll try to work it in if there are more troubles with the open loop start.


----------



## jyanof (Nov 11, 2008)

It's been a successful few days!

Installed the prototype controller in the car and worked up the guts to hook it up to pack voltage - nothing blew up!

Here's the controller on the cold plate. The camera angle is weird, but it's mounted vertically and is clamped onto the suction hose from the evaporator.









Magically, with the controller hooked up to pack voltage, the compressor started up fine the first time I tried. I quickly shut it back down, and oddly enough, it wouldn't start for the rest of the night - it would pass through the open loop ramp up just fine, but crap out and trip a shut down fail safe on overcurrent after transitioning to sensorless mode.

Slept on it and realized that the control loop gain was too high. It would either increase the output magnitude too quickly for the sensorless algorithm to keep up with or the speed would overshoot and the output magnitude would undershoot to compensate and cause the motor to fall out of control. Anyway, reducing the gain fixed that. Makes sense too since the supply voltage was now three times higher - the control loop needed to be adjusted to compensate.

It was early afternoon the next day when I got to work on it again and it was about 85F outside. The compressor ran smoothly and I almost maxed out the speed. Speaking of which, I realized a factor of 2 error in my conversion to RPM for all the previous stuff, so everything posted before is really only half as fast. 

Fixing that, the compressor reached about 4000 rpm with 94% throttle output. So, with only 144v, this really isn't going to go much higher, and extrapolating to 6000 rpm means a pack voltage of at least 200V is really needed to get the full capacity out of the compressor (if 6000 rpm is really the design point - seems to be what people say, though).

At 4000 rpm, high side pressure was about 165 psi and low side pressure was about 60 psi. I wasn't sure if the low side gauge was attached correctly, but it that pressure is correct, then the system is probably doesn't have the proper charge. I only had one of the condenser fans running, so the outlet temperature of the condenser was about 100F and not closer to the ambient air temp. Despite that, the air coming out of the vents with the fan blowing pretty hard was down in the high 40's. The cold plate worked well and was cool to the touch near the IGBTs.

A DC clamp meter measured the input current to the compressor at about 6 amps (about 860W) and another 4 amps to power all the fans and other 12v accessories. 10 amps total seems pretty good, though the compressor will probably draw more power as the ambient temps go up.


One weird thing that might be a problem - at 4000 rpm, the output currents started to have a pretty significant offset. here's a sample of the output; the black and pink are measured with current sensors and the blue is calculated assuming the currents add to zero. The y-axis is Amps X 10, so 100 is really 10.0 amps.










In the picture above, the black curve is offset high and the pink curve is offset low. Also, not sure if this is related, but the shape isn't smoothly sinusoidal and maybe the phase advance needs to be adjusted.

Here's a picture of the same curves but at 2000 rpm. Oddly enough, the black curve is pretty much centered vertically while the pink curve still has a negative offset.









so, not sure what all that means, but i've been combing through the code in search of something that might offset the output PWM signals with no luck. Could be measurement offset error too, but I'd expect that to be constant.


----------



## jyanof (Nov 11, 2008)

Also started putting together the xmega board. This'll be a lot less cludgy than the prototype and hopefully works just as well.

Here's the etched board. At some point, I'll probably realize that etching is too much of a pain, but I like having something ready for solder in just a few hours.









The board has two of those IGBT chips - one for the 3 phase stuff and another configured as three half bridges in parallel for a boost converter. I'll probably start without the boost phase and add the inductor and code in later. (That's another reason for going with the more powerful micro - need a little more processing power to run the boost stage control loop).

The board also has the same hardware overcurrent protection as well as some relay controls for the condenser fans and precharge relay, an isolated potentiometer input for throttle (if it doesn't end up automated), a couple of temperature inputs to measure heatsink and maybe suction line temperature, and an isolated on/off control signal if needed.

I got most of the board populated and made sure everything powered up ok. I was able to program the micro and got the timer and uart settings all worked out. Just gotta mount the board on the heatsink and will be ready to test it out.


----------



## jyanof (Nov 11, 2008)

oh yeah - i'd take a video of the compressor running, but it'd be so boring since there really isn't anything to see, so seems rather worthless. Actually, can't even hear it over the condenser fans.


----------



## AntronX (Feb 23, 2009)

Great project! I have some 24V Masterflux BLDC compressors that I want to make controller for. I also only work with 8 bit AVRs and knowing that you did it on Xmega is reassuring. Did you code in assembly or C? Are you going to release your code?


----------



## jyanof (Nov 11, 2008)

AntronX said:


> Did you code in assembly or C? Are you going to release your code?


Thanks!

I code in C and do plan to release it. I could share where it's at now, if you're interested - the sensorless stuff won't be changing much, just some basic controls stuff, and maybe some safety checks and auto shutdowns will go in.

I bet those masterflux compressors are welded shut, right? know if they have surface mounted or interior mounted magnets?


----------



## AntronX (Feb 23, 2009)

Yes, they are welded shut, just like regular compressors in window ACs. I don't know how magnets are arranged. I may have to cut one open, since Masterflux did not want to reveal extra info that's not in the datasheet. Thanks for being open with the software. I should have some free time to explore this in few weeks. 

I like how smoothly your motor starts in your first video. Hobby RC controllers tend to jerk the motor as they start. I will be watching your project, keep us posted!


----------



## jyanof (Nov 11, 2008)

Here's everything populated on the new board. 12v power, an isolated throttle input, and two relay drivers are in the bottom left. 

The two sets of IGBTs are at the top (under the board) with the 3 phase bridge on the left and boost converter on the right (as of now, I'm just bypassing the boost stage completely) with some bulk capacitors in the middle and film caps on each phase.

There are three current sensors in the upper middle, two for two phases of the motor output and one for the boost converter input.

The same comparator/NAND circuit for hardware overcurrent protection is on the middle right with an extra circuit for the boost stage. If any of the three current sensors go out of the range set by the pots, all the IGBTs are disabled.

And, the xmega16a4u is in the bottom middle with the programming port and serial out connections.

The last few days have been spent making sure all the hardware is working. I did find that I forgot to ground one of the current sensors, but that was an easy fix. 

Also, it was surprisingly tricky to port the code over from the at90pwm3b. Some of the sign conventions needed to be changed in order for the actual phase outputs to match the software and all of the ADCs are now 12 bits, so that changed a lot of the math.

Everything seems to be working on the test bench at 24V. It should get into the car this weekend!


----------



## jyanof (Nov 11, 2008)

AntronX said:


> Yes, they are welded shut, just like regular compressors in window ACs. I don't know how magnets are arranged. I may have to cut one open, since Masterflux did not want to reveal extra info that's not in the datasheet.


I found this appnote by freescale on how to measure motor parameters. It's not directly applicable to you because you can't actually see the rotor nor would you be able to lock it in place with anything.

But, I think there's some things you could do to get around that. for example, i didn't do their method of determining Lq and Ld. They suggest measuring the current rise time when a voltage is applied in order to calculate L. 

Instead, I used a 1uF film cap and a scope. I put the scope probes across the cap (with the scope in trigger and hold mode) and charged it up with a 12v battery. Then, touching the cap to two of the phase lines produces an RLC circuit that will oscillate at its natural frequency. I used the scope to capture a few periods of the oscillation and calculate the frequency, and knowing what C is, solving for L is pretty easy.

Anyway, the point is that it was a way to measure L without having the lock the rotor in place. you could do what they suggest to align the rotor in the q and d axis, but use this method to measure Ld and Lq. If they're the same, then the magnets are surface mounted. If not, then it's a salient motor (like the prius compressor).

another thought for determining number of poles - i noticed that the prius compressor would make a little 'puff' sound when it was spun with the inverter but disconnected from the a/c hoses (so just pumping air). If you built an inverter and could spin with with just an open loop output, you could find what electrical frequency (and pole count) makes a puff at 1 hz. The prius compressor has 3 poles, so its electrical frequency would be 3 hz to make one puff per second.


----------



## jyanof (Nov 11, 2008)

Attached are the C code as it stands right now and the schematic and PCB files using ExpressPCB's software (free, and kind of crappy). 

These are truly for educational purposes only, and even at that I didn't really take the time to comment things or make things easily understandable. But, to get this working on anything other than the setup it was tested on will likely require serious code/hardware modification.


----------



## jyanof (Nov 11, 2008)

Afternoon temps were in the low 90's on the drive home from work - and the a/c was on for the whole trip!

Things aren't perfect - the weirdest thing is that the throttle control jumps up about 800 rpm whenever the drive motor controller is pushing current. I suppose there's a lot of noise, but still - weird, and annoying. Ultimately, I want to program in speed control based on evaporator exit temperature... too warm, more compressor speed and vice versa. Also, took a couple of tries to start the compressor, so a more robust start sequence would be good.

Here's a photo of the controller in the car with a temporary case made out of tupperware. The baby food container houses the bluetooth wireless adapter (which amazingly works while driving around).











I only ran it to about 3700 rpm at which point the phase currents started to offset again. The motor current also rises, so maybe the offset is related to that and not speed. Not sure if it's a big deal, but here are plots of motor phase currents at 1700 and 3700 rpm.

1700 rpm










3700 rpm










One thing that works really well is the heatsink on the suction line. At startup, the heatsink temperature will rise a few degrees at first, and then plummet as the refrigerant cools it down. It's pretty obvious that there's more cooling power than waste heat from the IGBTs. No finned heatsinks or extra cooling fans... nice.


At a medium fan setting and the compressor at 3000 rpm, the total a/c system (condensor and vent fans plus compressor) drew about 800W. Vent air temp was in the mid 50's. At 3700 rpm and high vent fan, the system drew about 1300W.


----------



## jyanof (Nov 11, 2008)

Poured over the code for anything that might produce an offset in the duty cycle outputs (and consequently a DC offset in phase current) and couldn't find anything. Streaming the PWM duty cycles for each phase over serial confirmed that they are always balanced around the neutral point. 

Something could be happening in the driver hardware, maybe with deadtime or something, but all of that is buried in the IGBT module and inaccessible for probing.

On a whim, I tried increasing the amount of D-axis current. At 4000 rpm with ambient around 80F, the Q-axis current was about 8.0 amps. D-axis current was increased by about 10% from 3.9A to 4.3A.

I'm not sure why, but this helped the DC offset a bit. Also, it resulted in less output magnitude required for the same speed - additional field weakening, perhaps?

This plot shows the two cases with the increased Id in red. It's subtle, but the red dots for each phase are more centered around the x-axis than the blue dots. The benefit can be shown quantitatively if the data for each phase is averaged to calculate the DC offset (before and after, respectively):
Phase 0: 0.14A vs 0.05A
Phase 1: 0.72A vs 0.3A
Phase 2: -0.87A vs -.35A









I'm not ready to completely declare a win since I have no idea why changing the amount of d-axis current would affect phase DC current offset. But, it would be interesting to play around with the amount of d-axis current some more on the test rig.

This was also interesting (and maybe related?). I had the serial data output the estimated rotor position angle every time the sensorless algorithm had a zero crossing and supposedly indicated the true rotor position. I got a chart like this - looks ugly with no labels, but shows how far off the estimated rotor position was for a supposedly true rotor position.









It seems at 30 degrees, the estimated rotor position is pretty close to what the sensorless algorithm thinks it should be. The data is centered around zero and seems to mostly be within +/- 2 degrees, with some points out to +/-4 degrees.

What is interesting is that the data for 150 degrees is all negative. It seems that nearly all the time, the estimated rotor position is always a few degrees less than what the 'true' position indicated by the sensorless stuff. So either the rotor is speeding up just a little bit on the way to 150 degrees and gets there before the linear interpolated estimation does, or the opposite: the sensorless code thinks it's getting there sooner than it actually is. Not sure it matters, but it's interesting.


----------



## AntronX (Feb 23, 2009)

Could your offset be caused by non linear load on pump motor? Since compression cycle happens at fixed angular position, it would show up as current offset on your graphs.


----------



## jyanof (Nov 11, 2008)

AntronX said:


> Could your offset be caused by non linear load on pump motor? Since compression cycle happens at fixed angular position, it would show up as current offset on your graphs.


Interesting! Perhaps? I'm not sure. 

So, there are 3 electrical cycles per physical revolution. That would seem to imply that there would be a spike every 3rd cycle and the current plots would show two curves (which in fact I do see this at really low speeds and couldn't figure out what that might be until now - I bet it is in fact the increased torque at the end of the compression cycle). 

At high speeds though, the current waveforms are more uniform, or perhaps more cloud-like, depending how it's interpreted.

Also, would an increase in torque result in a current increase in all the phases or just one? That's the part that confuses me.

I'll find some of that low speed current data with two waveforms to throw up here.


----------



## dcb (Dec 5, 2009)

short of adding hall effect for testing, maybe you can use an extra i/o pin to trigger a timing/strobe light, and put some marks on the shaft/case and test where the cpu thinks the shaft is and where it actually is?


----------



## jyanof (Nov 11, 2008)

Some new updates:

For whatever reason, the throttle pot circuit stopped working. I think somehow the 5v regulator died and overvolted the isoamplifier chip. That's ok though - I wanted the speed to be controlled by evap outlet temperature feedback, so this just forced me to do it. Added another thermistor (with some extra resistors that were needed to get its output within the ADC input range) and coded up a slow control loop. If the evap temp is above 10C, speed increases gradually and if temp is below 8C, speed decreases. Problem fixed!

Also, the code that looked for a stalled rotor during start simply wasn't working anymore (not sure why). The code simply looked at the estimated speed from the sensorless algorithm during the open loop ramp and made sure the calculated speed kept increasing. There would often be false positives and it would take several attempts to start the motor. Then, it would hardly ever sense an actual locked rotor - it would fire up as if the motor was spinning and usually the hardware overcurrent circuit would trip and shut it down.

During the open loop ramp, a basic control loop tries to maintain Iq at a constant value by changing the PWM magnitude of the output. Visually, it was simple to see that the PWM magnitude barely increases during the ramp if the rotor is locked (after the compressor runs for a while, it seems to lock up for about 5 mins after shutdown - increasing the start torque might help, but haven't tried that yet). The picture below shows the PWM magnitude during the align phase (first slope) and ramp phase (second slope) for a locked (top) and free (bottom) rotor. Now, the code just checks the PWM magnitude at the end of the ramp and makes sure it's above a certain value. It's been 100% reliable so far.










Up next, some performance results...


----------



## jyanof (Nov 11, 2008)

There's been some unusually cool weather here in AZ - it was nice, but I was almost disappointed that I couldn't use the a/c much. Yesterday was the first 100F day since I got this working.

Sitting in the driveway (so with only the two condenser fans going and no benefit from extra airflow while driving), the vent fan was at med/high with the recirculation on. Vent air temp settled in just below 50F and it was quite comfy in the vehicle cabin. The Cycle Analyst showed about 1.7 kW total from the batteries, so about 1.4 kW for the whole a/c system after subtracting off the 300W for the other fans and parasitic accessories. The compressor speed was at 4000 RPM and PWM output was at 96%, so couldn't go much faster anyway.


















Cranking the fan to full blast and turning recirculation off (so it sucked in 100F outside air instead of the cooler cabin air) loaded the a/c system as hard as possible (for that ambient temperature, at least). Vent temperature rose to 60F, so still not too bad - it was cooling a lot of air by 40 degrees! Power draw rose to 1.7 kW for the a/c system and the PWM output was at 100% to maintain 4000 rpm. During this time, the controller heatsink maintained a cool temperature at 66F .

For grins, I turned the vent fan all the way down to low and turned the recirculation back on. Compressor speed dropped down to just below 3000 rpm after several minutes and the vent air temp was a cool 40F. Aiming all the vents at myself kept it reasonably comfortable, but probably would piss off any passengers... Power draw dropped to only 850W for the a/c system.

Everything should get even better if the car were moving.

Things seem pretty good for moderately hot days, at least. It seems a 144v system is plenty to get the required speed for a 100F day. It's going to get hotter...


----------



## AntronX (Feb 23, 2009)

Thanks for an update. Looks like you may not even need that step up DC converter.


----------



## mani9876 (May 10, 2012)

Hello!

You've done a really great job. And I am planning to do the same thing like you, but could you tell me, why you don't use a standard vector - controlled VFD ? Wouldn't this make things easier?

Thank you,
regards


----------



## jyanof (Nov 11, 2008)

AntronX said:


> Thanks for an update. Looks like you may not even need that step up DC converter.


Yep, I think I'll be ok without it. 

The web said it was 111F today and everything still seemed to work. Within a couple of minutes, I'll get 60F air out of the vents. Then, after maybe 10 minutes, that'll cool down to under 50F. That seems comparable with a normal system - when it's this hot, things take a while to cool down.

I'm scheming a way to remote start the a/c - that would be ideal.


----------



## jyanof (Nov 11, 2008)

mani9876 said:


> Hello!
> 
> You've done a really great job. And I am planning to do the same thing like you, but could you tell me, why you don't use a standard vector - controlled VFD ?


thanks! if you could find a VFD that will run a permanent magnet synchronous motor with interior permanent magnets, then it should work. Most VFDs I've seen will only work with induction motors though. A quick google search looks like they're out there though.

I just looked up the Mouser order for all the electronics for this controller - $140. Actually would be a little less if I didn't buy stuff for a boost converter. A proto board might be another $30 from a pcb house if I didn't etch it myself. The heatsink was less than $10 of aluminum.

So cost was an issue - I've never looked, but not sure if a suitable off-the-shelf controller could be had for under $200.

Also, it was a fun challenge! (as long as it lasts the summer)


----------



## jyanof (Nov 11, 2008)

that last post got me thinking about costs for what's actually in the car. 

controller - $180
used compressor - $85
a/c fittings - $50
new custom a/c hoses - $175
system flush - $45
fancy hybrid compressor oil - $12
2 cans of 134a - $25
rubber mounts - $15

Total: $587

functional a/c for under $600 seems pretty good!


----------



## mani9876 (May 10, 2012)

Hello,

yes you're right, it's really hard to find a suitable one.

It's definitly better if you could build it yourself, like you did. But you have to be a very very very good programmer to make all the algorithms work with a BLDC motor with sensorless sinus conduction.

So that's really great. But my programming skills are too bad for such things .

Manuel


----------



## kstegath (Nov 4, 2008)

I'm over here in FL, it's July, and it's hot. I just bought a Prius A/C compressor on ebay (for a 2011, it was cheaper). I have the pack voltage (276), but may need to hack it as I'm still trying to find what signals it's looking for.

Great article. Any new surprises?


----------



## jyanof (Nov 11, 2008)

kstegath said:


> I'm over here in FL, it's July, and it's hot. I just bought a Prius A/C compressor on ebay (for a 2011, it was cheaper). I have the pack voltage (276), but may need to hack it as I'm still trying to find what signals it's looking for.
> 
> Great article. Any new surprises?


sorry, just saw your post. My a/c has been working well all summer. Well, except those 118F days, but no one's a/c works well. So, no new surprises.

With the 3rd gen prius compressor like you have, i think there's only 2 connections for the DC voltage and then CAN bus control. I don't know if 276VDC is too much for the electronics, nor do I know any CAN. I've read about CAN bus sniffers, so maybe you can tap into someone's prius and see what commands control the a/c.

Would be interesting! Let us know how it goes!


----------



## mx6 (Dec 8, 2010)

Great job
Hoping to try this before next summer. 
Do you have a BOM?
Also running 120v and I know my RPMs will be lower but do you see any other issues with 120v?


----------



## jyanof (Nov 11, 2008)

mx6 said:


> Do you have a BOM?
> 
> Also running 120v and I know my RPMs will be lower but do you see any other issues with 120v?


Sorry for the late reply!

For a BOM, you can d/l the zip in this post and open the schematic file (you'll need the free software from www.expresspcb.com). In the schematic, I had assigned a part number to each part and if you go to the edit menu, you can copy the list of parts to the clipboard and paste to a document. Let me know if you have any questions and I can try to dig around in my head for an answer.

Honestly, I think there were some mistakes in my schematic and board that I had to fix after the fact, but I can't remember what they were. So, view this as a starting point and not a plugnplay solution.

As for 120V, you'll just have a limited max RPM. If I'm limited to 4000 RPM with 144V, I'm guessing you'll be able to get to 3300 rpm or so. Not sure how hot it is where you are, but I bet that will suffice for most days of the summer if you're not in AZ.


----------



## cts_casemod (Aug 23, 2012)

I'm actually following this with interest.

Had the idea there was a prius AC unit with an induction motor fitted...? Perhaps I got confused somewhere.
Is there any reason you didn't went with a standard sensorless controller IC, such as those used on high power electric bicycles (72-144V)?

I ordered one of these and looking to play with it. Just going to need some sort of buck converter for my HV battery


----------



## jyanof (Nov 11, 2008)

cts_casemod said:


> Had the idea there was a prius AC unit with an induction motor fitted...?


Nope, it's a brushless ac motor with embedded magnets in the rotor (PMSM). There are some pictures in the first post of the thread.



> Is there any reason you didn't went with a standard sensorless controller IC, such as those used on high power electric bicycles (72-144V)?


I didn't look too hard for an off-the-shelf solution, but I thought I would need a 200VDC bus and couldn't find anything that went that high for PMSM control nor something I considered cheap enough. Also, if 200VDC was needed and I needed to build a boost converter anyway, then why not just do the whole controller? Also, it was fun!

But, I suppose if you can find an off the shelf 144V PMSM controller than can handle salient motors, then it ought to work fine.

If you're referring to the actual dedicated controller chips like TI has for motor control, then it was just a preference of mine. I did't know how to use them nor did I know how to do my own programming, but I thought that there was more flexibility with doing it myself. I bet one of those TI instaspin chips would work well, though.


----------



## cts_casemod (Aug 23, 2012)

Thanks. No I definitively seen the thread since the beginning, it was a misconception I had. Thank god I cleared that 

Regarding the motor, my question was if you needed any sort of control that a dedicated off the shelf controller didn't offer. Judging by your last reply everything was pretty standard, but just to confirm.

Have you implemented a 4 way valve to get hot air as well?


----------



## jyanof (Nov 11, 2008)

cts_casemod said:


> Regarding the motor, my question was if you needed any sort of control that a dedicated off the shelf controller didn't offer. Judging by your last reply everything was pretty standard, but just to confirm.
> 
> Have you implemented a 4 way valve to get hot air as well?


Right, nothing special for the motor. The only handy thing I did was program a control loop to adjust the speed to maintain the evaporator discharge within a certain range, but that could be done with an off the shelf controller and an external homemade control module to set the controller throttle.

For reversing the flow, I'm pretty sure the system would required an orifice tube instead of an expansion valve (which just blocks reverse flow, I think) and of course all the extra plumbing for the valve. It'd be neat to figure out how to do that since heat pumps quite effective for AZ 'winters'. I already had a resistor coil based heater, so I didn't bother.


----------



## cts_casemod (Aug 23, 2012)

jyanof said:


> Right, nothing special for the motor. The only handy thing I did was program a control loop to adjust the speed to maintain the evaporator discharge within a certain range, but that could be done with an off the shelf controller and an external homemade control module to set the controller throttle.
> 
> For reversing the flow, I'm pretty sure the system would required an orifice tube instead of an expansion valve (which just blocks reverse flow, I think) and of course all the extra plumbing for the valve. It'd be neat to figure out how to do that since heat pumps quite effective for AZ 'winters'. I already had a resistor coil based heater, so I didn't bother.


So the compressor auto throttles based on the evaporator temperature? 
Any field weakening or the likes, or just a PID loop to reduce the speed? 

Yes, two TXV valves with a one way valve on each. I'm not sure the capillary tube would work well with variable speed.


----------



## jyanof (Nov 11, 2008)

cts_casemod said:


> So the compressor auto throttles based on the evaporator temperature? Any field weakening or the likes, or just a PID loop to reduce the speed?


Yep - there's a thermistor taped and insulated to the evap discharge coming out of the firewall and the controller tries to maintain it between 5 and 8 degrees C. It's just a very slow PI loop that adjusts the controller's throttle setting based on this measurement. I noticed that even at a constant speed, the TXV hunts a little bit and this temp will oscillate anyway, so the PI loop is really slow, like maybe a minute to settle down to a constant speed.

This makes the system very efficient on those just slightly warm days where you have the fan on low. No cycling of a compressor going full blast, just the compressor operating at part power. The whole system might only draw a few hundred watts.

No field weakening necessary, though I suppose salient motors technically are always operating with some level of field weakening to take advantage of reluctance torque, but I don't think that's what you were referring to. The speed control algorithm I used adjusts the controller output voltage and the sensorless algorithm adjusts the commutation frequency to follow.



> Yes, two TXV valves with a one way valve on each. I'm not sure the capillary tube would work well with variable speed.


Ah that makes sense. Doesn't sound too difficult to plumb up if you have the parts. Let me know how it goes if you do it!


----------



## skeyes (Dec 3, 2016)

I am a year late to the party, but *great work* on your prius A/C compressor setup. How is it holding up?

For Houston I am also looking at A/C as a necessity, but I don't see myself being able to pull off a custom controller! I was hoping to just hook up voltage on a used compressor with custom lines and roll with it, but it seems a tad bit more complicated!


----------



## jyanof (Nov 11, 2008)

skeyes said:


> I am a year late to the party, but *great work* on your prius A/C compressor setup. How is it holding up?
> 
> For Houston I am also looking at A/C as a necessity, but I don't see myself being able to pull off a custom controller! I was hoping to just hook up voltage on a used compressor with custom lines and roll with it, but it seems a tad bit more complicated!


Thanks - it's worked well for two summers now. Occasionally on the hottest Phoenix days, it will trip the overcurrent circuit if the vent fan is on high. But, I'm in 'good enough' mode and haven't bothered to troubleshoot.

There's a steep learning curve, but building a controller is a fun challenge. Other options might be looking at a 3rd generation or later prius compressor. It has the controller built into the compressor, but you'd have to feed it high voltage and figure out the CAN commands to actually get it working. There are also off-the-shelf electric compressors sold by some of the EV parts suppliers, but they're expensive. Masterflux compressors fit in this category too.

you'd lose efficiency, but a belt driven 'regular' compressor can be run off the tail shaft of your drive motor (assuming you have a tail shaft). my friend did this and it works fine, just has to rev the motor at long stop lights. It sucks ~5 HP though.


----------



## AfdhalAtiffTan (Jan 22, 2017)

jyanof said:


> Attached are the C code as it stands right now and the schematic and PCB files using ExpressPCB's software (free, and kind of crappy).
> 
> These are truly for educational purposes only, and even at that I didn't really take the time to comment things or make things easily understandable. But, to get this working on anything other than the setup it was tested on will likely require serious code/hardware modification.


Thank you for the great write up!
I am working on the same project, but instead of AVR, I am using Cypress PSoC kit (using the provided example code).

Looking at your code, is your measured inductance of the motor 4.7mH?


----------



## arber333 (Dec 13, 2010)

jyanof said:


> Thanks - it's worked well for two summers now. Occasionally on the hottest Phoenix days, it will trip the overcurrent circuit if the vent fan is on high. But, I'm in 'good enough' mode and haven't bothered to troubleshoot.
> 
> There's a steep learning curve, but building a controller is a fun challenge. Other options might be looking at a 3rd generation or later prius compressor. It has the controller built into the compressor, but you'd have to feed it high voltage and figure out the CAN commands to actually get it working. There are also off-the-shelf electric compressors sold by some of the EV parts suppliers, but they're expensive. Masterflux compressors fit in this category too.
> 
> you'd lose efficiency, but a belt driven 'regular' compressor can be run off the tail shaft of your drive motor (assuming you have a tail shaft). my friend did this and it works fine, just has to rev the motor at long stop lights. It sucks ~5 HP though.


Hi

I have a 2012 Leaf compressor that is BLDC and works from 360Vdc. It has internal controller running from some UART protocol. I tried to regulate it using UART TX RX but it operates on a level that i cant setup. It is not computer UART.

Would your controller work with Leaf compressor BLDC motor? 

Do you use the right boost IGBT bridge at all or can i just leave it unpopulated?

Are there any changes from the PCB that you posted here?
Are there any outside components that you installed and are not mentioned here?

tnx


----------



## jyanof (Nov 11, 2008)

arber333 said:


> Hi
> 
> I have a 2012 Leaf compressor that is BLDC and works from 360Vdc. It has internal controller running from some UART protocol. I tried to regulate it using UART TX RX but it operates on a level that i cant setup. It is not computer UART.
> 
> ...



I bet that the controller could be adapted to work with a leaf a/c compressor. You'll have to bypass the internal controller and find the 3 leads to the motor windings to hook up the new controller.

I doubt the hardware would have to be modified unless the leaf motor demands more current, but I doubt that's the case at the higher voltage.

The software will surely have to be modified. You'll have to determine if the motor is salient or not (are the magnets embedded in the rotor or on the surface - I'm guessing they're embedded like the prius a/c compressor). The Id/Iq ratio will have to change in order to optimize the torque for this new motor. The motor inductance and other parameters will have to be figured out and changed.

For the prius a/c, my 144v pack was able to adequately spin the motor fast enough for good cooling without any boost. If you have enough voltage from your pack, the boost IGBT can be bypassed. The leaf has a 360V pack, so assuming the motor is designed to fully utilize that voltage, anything less than 360V will not spin the motor as fast as designed. But, that may be fine.

There was one mistake on the PCB that I recall. If you end up using I3, the ground pin is not connected to anything, but a simple solder bridge to the capacitor pad next to it is a simple fix.

Externally, I had planned on having the boost inductors mounted somewhere but ended up not using them. I had a couple of ~2in diameter toroid cores that I hand wound with a couple strands of 14ga magnet wire for another project.

For testing, I had a pot signal go across U12 to control the motor speed, but that never worked well (if I remember right). Anyway, once the control scheme was changed to controlling evap temp, this part of the circuit wasn't necessary.

There's also a precharge resistor and bypass relay externally mounted. The thermistors for monitoring heatsink temp and evap exhaust temp are board terminated, but obviously mounted to their respective components.

So, I'm sure it can be done and this controller would be a good start, but will probably take a bit of modification and motor testing.


----------



## jyanof (Nov 11, 2008)

AfdhalAtiffTan said:


> Thank you for the great write up!
> I am working on the same project, but instead of AVR, I am using Cypress PSoC kit (using the provided example code).
> 
> Looking at your code, is your measured inductance of the motor 4.7mH?


This sounds very familiar for the inductance value. It's been a few years! In hindsight, this is the unsaturated inductance at room temp. The operating inductance is probably less as it heats up and the windings saturate, but I think the beauty of this method is that the control scheme is pretty tolerant of some of this stuff.


----------



## AfdhalAtiffTan (Jan 22, 2017)

jyanof said:


> This sounds very familiar for the inductance value. It's been a few years! In hindsight, this is the unsaturated inductance at room temp. The operating inductance is probably less as it heats up and the windings saturate, but I think the beauty of this method is that the control scheme is pretty tolerant of some of this stuff.


Thank you!


----------



## arber333 (Dec 13, 2010)

jyanof said:


> This sounds very familiar for the inductance value. It's been a few years! In hindsight, this is the unsaturated inductance at room temp. The operating inductance is probably less as it heats up and the windings saturate, but I think the beauty of this method is that the control scheme is pretty tolerant of some of this stuff.


Hi

I got new PCBs to make controller. Now i am dealing with schematic. Can you by chance make a list of items neccessary for single bridge controller? I have 360Vdc in mind and i think compressor will like it. I have no need of a boost circuit. Could you make a list of items for single bridge unit or just omit redundant items from original BOM?

tnx


----------



## staska (Feb 12, 2009)

Hi. Pretty good solution. How it is going ? Any hope to see updated code ?


----------



## jyanof (Nov 11, 2008)

staska said:


> Hi. Pretty good solution. How it is going ? Any hope to see updated code ?


Sorry for the late reply - things are still going fine with the a/c controller. I'm pretty sure this is the latest code I'm running now, my version control is pretty terrible. Remove the ".doc" at the end of the file extension, had to get around the file size limits.


----------



## staska (Feb 12, 2009)

jyanof said:


> Sorry for the late reply - things are still going fine with the a/c controller. I'm pretty sure this is the latest code I'm running now, my version control is pretty terrible. Remove the ".doc" at the end of the file extension, had to get around the file size limits.


Hi. thanks for code - but my diff checker, shows, that it is identical to previuosly uploaded into this forum. It lacks that regulation of evaporation temp..


----------



## jyanof (Nov 11, 2008)

staska said:


> Hi. thanks for code - but my diff checker, shows, that it is identical to previuosly uploaded into this forum. It lacks that regulation of evaporation temp..


Oops, found it this time - try this.


----------



## staska (Feb 12, 2009)

jyanof said:


> Oops, found it this time - try this.


Super. Now it looks better.

Just curious, about hardware overcurrent protection - if both sensed phases are in ie. 70% of nominal, both positive or negative, not sensed, will see 140% of current, if i am correct. shortly, will receive pcb and start creating some blue smoke from ic 

Will it run unloaded ? Or should i load it ?


----------



## arber333 (Dec 13, 2010)

Hi folks

I have a plan to make my own AC controller since i have Leaf compressor and it is quite larger than Prius one. I will use Lebowski drive and 3rd bridge from my Ampera inverter.
That leaves one board from here as a backup, just in case i am not succesfull.

I still have at least 4 boards left and i will not need all of them. I can part each of them for €12 per piece and shipping to wherever it will go. Anyone interested?
My location is Slovenia.
PM me.

EDIT: Laszlo i am sorry i deleted your msg by accident. Can you resend PM?


----------



## arber333 (Dec 13, 2010)

jyanof said:


> Oops, found it this time - try this.


Hi Jyanof

I have some practical application questions about your controller

Can you comment on how you run your compressor? So when the car starts AC how long does it take for the compressor to spool up to desired RPM? Do you have this programmed or does it just work itself out?
Also how long does it take to stop when AC control wants to stop? do you just apply regen brake or do you slowly spool down compressor?

tnx


----------



## jyanof (Nov 11, 2008)

The compressor starts up pretty quickly to a min operating speed, i think of 1000 rpm. During this start, it transitions from open loop control to sensorless feedback control.

Then, it sits at this min operating speed for half a minute or so to let the system pressurize a bit before going into temperature control mode. In this mode, the speed gradually changes in order to maintain the evap discharge temp at a certain temperature range (between 5 and 10 C, I think).

When shutdown is commanded, the compressor spools down slowly to the min operating speed (over 10-20 seconds, depending on how far it has to go) and then power is cut (IGBTs off).

I have no idea if any of this is necessary, but i was trying to be easy on the system and not push the limits.


----------



## JustinNguyen (Aug 9, 2014)

Yan...

Thanks for the coding, some day i will make the your code run on my board. Again thanks for your hard work so all of us can have it for free.. 


1. Do you used the original Evaporator/Condenser from your car?
2. Which gas did you charged?
3. Which development board are you using?
4. Your chip has 16KB does it fit your code?

thanks
Justin


----------



## StephanoClarkson (Jun 23, 2021)

I admire you guys. You write your own code and make your own controllers. All I can do is fill an appointment form on socool.sg and wait until they contact me. And I'm so glad that they quickly solve all my A/C problems. Life in Singapore is impossible without air conditioning. And thank God that they do everything efficiently and have reasonable prices. I don't know what I would do without their help; words like compressor, freon, thermostat drive me into a panic. I always prefer to trust such issues to professionals.


----------



## arber333 (Dec 13, 2010)

jyanof said:


> Sorry for the late reply - things are still going fine with the a/c controller. I'm pretty sure this is the latest code I'm running now, my version control is pretty terrible. Remove the ".doc" at the end of the file extension, had to get around the file size limits.


Hi Jyanof 

You opened the motor. I did not. But i ran my Prius AC compressor using Lebowski brain. For RPM limits i used your estimation of motor being 3pole. That means 1.5 pole pairs for math. I am not convinced. Motor runs just fine, but RPMs seem feeble. Is it possible you made a mistake and motor is actualy 6 pole i.e. 3pole pairs? This would raise eRPM from 6K to 12K at 4000RPM actual.


----------

