Another Lebowski controller

Jeremy Harris

100 MW
Joined
Oct 23, 2007
Messages
4,208
Location
Salisbury, UK
Ages ago Lebowski was kind enough to let me have a couple of programmed dSPIC30F4011 chips, as used in his neat controller and I promised to start a thread here when I started making a controller with them. I have plans to build a pretty big controller with one of the chips, but thought I'd start off by making a low power one to replace the 6 FET Xiechang I'm currently using on the Swift folder with the other. This is just a preview of my plans for now, as I need to get on and finish the PCB layout and get the remaining parts ordered.

The case I'm going to use is a small Hammond extruded alloy box, their part number 1455K1201 (see here: http://www.hammondmfg.com/1455.htm ). This is around the same size as a 9 FET Xiechang case, but I'm hoping that I will be able to fit the controller and an RFID power switch, battery charge monitor etc into it. I have the PCB layout done for the power board, including provision for three ACS758 current sensors, and just need to finish the layout for the piggy-backed "brain" board that will hold the dSPIc and the voltage regulators, then make a start on the other board that will hold the power switch and charge monitor stuff.

Controller case.JPG

This isn't a high power beast, I'm using just six IRFB3077s and 50A bidirectional phase current sensors. The idea is to get to grips with tuning Lebowski's controller with a low power unit where I can better prevent the release of magic smoke if I get something wrong. The main reason I want to start out with a small controller like this is that the Swift with the Q100 motor needs much better throttle control. The combination of the high motor rpm, two stage gear reduction and speed command throttle isn't great on a small wheel bike, it makes for a jerky, rather on/off, throttle response, due in part to the wide motor rpm range, I think, together with a coarse speed command throttle. I'm hopeful that current mode throttle control will get around this problem and that the motor will also be quieter when driven with a better waveform.

One thing I'm slightly concerned about is that the controller needs the motor to be spun in order to calibrate the Hall timing, and the only way I can do that is to spin the motor backwards, as it's a small geared hub. I'll need to check with Lebowski if there's a way of reversing the calibration process to take account of this (I think there is, but haven't got that far in understanding how it works, yet).
 
Jeremy Harris said:
One thing I'm slightly concerned about is that the controller needs the motor to be spun in order to calibrate the Hall timing, and the only way I can do that is to spin the motor backwards, as it's a small geared hub. I'll need to check with Lebowski if there's a way of reversing the calibration process to take account of this (I think there is, but haven't got that far in understanding how it works, yet).

It has an option for this in the EEPROM save menu. You have the choice of saving "as is" or with the direction
reversed (what you will need). Only save with direction reversed once ! Else you get the 'reverse reverse' direction
which is forward again :D So, after hall and back emf calibration save with direction reversed. Then, if you change
something like loop parameters or max phase current, save with 'as is'.

I'm very curious to see your board designs :?:
 
Thanks for confirming that the motor can be turned the other way for setting the controller up, I had thought that might be the case. This means I can spin the wheel the wrong way to get the motor to turn for the calibration, then reverse the direction when saving the result.

The board design is tricky, as not only do I want to make the controller quite small (so it doesn't look too obvious on the bike) but I also want be able to make the board myself (so through hole and single sided, if I can!). The main problem is the amount of room on the board the current sensors take up, together with trying to get a neat location for them. I think I've solved the problem, but am still playing around with moving things around to get the best layout. I've opted to use a simple switchers for the power supplies, to keep the efficiency reasonably high, but the inductors take up more real estate on the board than I would like. I may have to re-think the case and go for something that would allow a slightly larger board size, I think................
 
Can't wait to see how this goes for you. My New scope is only ~1 day away so I will be back on mine very soon!
 
Jeremy Harris said:
Thanks for confirming that the motor can be turned the other way for setting the controller up, I had thought that might be the case. This means I can spin the wheel the wrong way to get the motor to turn for the calibration, then reverse the direction when saving the result.

The board design is tricky, as not only do I want to make the controller quite small (so it doesn't look too obvious on the bike) but I also want be able to make the board myself (so through hole and single sided, if I can!). The main problem is the amount of room on the board the current sensors take up, together with trying to get a neat location for them. I think I've solved the problem, but am still playing around with moving things around to get the best layout. I've opted to use a simple switchers for the power supplies, to keep the efficiency reasonably high, but the inductors take up more real estate on the board than I would like. I may have to re-think the case and go for something that would allow a slightly larger board size, I think................

Gonna etch a board, or send it out? I've etched plenty of boards, with highly variable results. Later on, when I was in an electroncis prototype shop, we'd send them out, because we had a lot better luck with them. A hundred bucks was a typical order, and I got half a dozen boards (mistakes happen). I would always oversize the board (same price for 6 X 6 as 4 X 4) and fill the remaining area with pad-per-hole. That pad-per-hole has been an amazing resource for prototyping ever since, beats Radio Shacks crappy pad-per-hole all to pieces, since we'd get plated through holes everywhere.

Or, you could save a hundred bucks and just etch and drill... SRSLY, a double-sided homemade board isn't any harder than a single sided, and makes it a lot easier to route.
 
I'll just make the board myself, as I've done with a few other projects documented on here, using the laser toner transfer method. Single sided is a heck of a lot easier for DIY, I've found, as getting good registration with the toner transfer method is tricky.

I have used UV etch resist in the past, with masks printed on to transparency film. This makes double sided boards easier to DIY, but I found the spray on resist a bit variable and the pre-coated boards have a finite shelf life, even when kept cool, I found. It doesn't make much sense (for me) to keep pre-coated board around, only to have it expire before I get to use it, whereas the stack of plain copper clad board I have has been in the cupboard for years.

I like the flexibility and speed of DIY board making - if I've made a small error I can knock out another board in an hour or so. It's also dirt cheap, compared to the cost of getting boards made commercially for one-offs like this. The trade off is the compromise in layout and space, but I can live with that OK.
 
Yep, single sided is easier, considering registration and the inaccuracies of toner transfer method. Printers tend to stretch things slightly in one direction or the other. I always had four registration holes outside the board area, on both sides. These get drilled first, then I used pins to keep the paper in place until I have it anchored correctly. Really, though, it isn't necessary to go to double sided unless you are doing complex surface mount and really need to jam it into a small space. Then it has to be so damn accurate that a homemade board is almost not good enough.

One of the things I did that made the etch work a lot better was put a bubbler in it. This was a plastic tube fulla holes, connected to a little aquarium air pump. Stirs the mix, which then seems to cut much better. Took about 5 minutes to hack together and really improved etching. Also helped if the etching solution was a little warm.

Lately all my projects have simply been on pad-per-hole board, or on Arduino protoboards. I haven't usually gone to the trouble of cutting a circuit board if I am just making one of something.

I may be getting back into this soon, though, as I just bought some surface mount LED lighting parts. No way to do surface mount without a custom etched board.
 
The board is taking way, way, longer to do than I thought, as getting a configuration that meets all of the somewhat conflicting layout requirements isn't easy. I think I may have to resort to only using two current sensors, rather than three, and accept the degradation in the current noise measurement. I notice that neiles did this with his version, and it seemed to be OK for him, so I'm going to do the same, I think (unless Lebowski chips in here and says it's much better to use all three sensors.......). This controller won't be running at high power levels anyway.

A quick couple of questions for Lebowski:

1) Can the software adapt if the Hall sensors are configured with the opposite current flow sense?

2) If I opt to use two current sensors rather than three do I have to have the sensors on phases A and B, or could I have them on B and C?
 
Well, it is better to use 3 current sensors, but when you use hall sensores 2 should be OK (sensorless self-start definitely needs 3).
With 2 sensors all the noise in Ia and Ib get assigned to Ic (as it is computed as -Ia-Ib) while with three sensors all the noise common
to Ia, Ib and Ic is filtered out...

There is no relation between the current sensors and the hall sensors. There is DEFINITELY a relation between current sensors
and PWM outputs ! Thats why the hall sensors are numbered and the current sensors / pwm / motor phase voltage feedback
have letters, to show where the vital relations are.

Two current sensors must be on A and B.
 
Lebowski said:
Well, it is better to use 3 current sensors, but when you use hall sensores 2 should be OK (sensorless self-start definitely needs 3).
With 2 sensors all the noise in Ia and Ib get assigned to Ic (as it is computed as -Ia-Ib) while with three sensors all the noise common
to Ia, Ib and Ic is filtered out...

There is no relation between the current sensors and the hall sensors. There is DEFINITELY a relation between current sensors
and PWM outputs ! Thats why the hall sensors are numbered and the current sensors / pwm / motor phase voltage feedback
have letters, to show where the vital relations are.

Two current sensors must be on A and B.

Thanks for that, I think I may be able to get a layout to work OK with just two current sensors on A and B, and I've kept the same current flow sense on them as you have on your board, so that should be OK. I've switched to a slightly bigger box, but one that is sealed with a rubber gasket and that will still just fit into the space I have for it on the bike. I'm still going to have to use two boards, piggy-backed one on the other, shield-style, with the lower board having the output stage, voltage regulators and current sensors and the upper board just having the dSPIC and associated interface stuff.

I've resorted to fitting the FETs under the power board, rather than on top, as that gives a bit more board real estate where things are tight. I may just get the board layout finished today, with a lot of luck!
 
I'm reasonably sure that I have a layout that works now, but I've had to shift things around a fair bit to get everything to fit on to the board(s). I've ended up with the current sensors on the piggy backed board, and the dSPIC on the main board, as this allowed me to fit three current sensors in the space available.

One thing I've had to do is fit the current sensors the opposite away around to the way that you've fitted them, Lebowski. AFAICS this should be OK, even though it changes the sense of the current signals (positive going will now look to be negative going, and vice versa).

Hopefully I should get some boards made tomorrow - I have all the components now, so with luck I may have a working controller before too long...............
 
Lebowski said:
that won't work Jeremy, the polarity of the current sensors is vital !

Bugger............

I'd hoped that, because the current sensors were bidirectional, that I could get away with swapping the sense of the phase current flow through them. It's not defined on the schematic, AFAICS, so originally I just copied the layout you used on your circuit board. When I switched the current sensors to the piggy back board the layout became easier if I swapped the current sense direction. What I have at the moment is the sensors fitted with the supply, ground and output to the right, the FET bridge connected to the lower left connection and the motor connected to the upper left connection. I guess I shall have to sit down tomorrow and try and see if I can swap the current sense around the other way, so that the FET bridge feeds the upper left connection and the motor comes from the lower left connection, as you have it on your PCB.

I've really made a rod for my own back trying to fit this into a small box, using just a single sided circuit board...........
 
It just occurred to me that I may have implied that I was (stupidly) reversing the polarity of the current sensors, when in reality what I've done is change the sense of the current direction through them. Hopefully the sketch below might make things clearer.

I've been thinking about this, and have a feeling that swapping the current sense around like this only has the effect of reversing direction (I think), which I'm guessing can be compensated for during calibration.

 
Lebowski said:
Nope, you have to have the sense direction correct.... sorry

So, does this mean that the current sensors can be either way around? Looking at your board you have them configured as in the upper of those two sketches, and I originally had mine configured the other way around (in fact I've spent the morning rearranging the board so that mine are now the same way around as yours).
 
Jeremy Harris said:
Lebowski said:
Nope, you have to have the sense direction correct.... sorry

So, does this mean that the current sensors can be either way around? Looking at your board you have them configured as in the upper of those two sketches, and I originally had mine configured the other way around (in fact I've spent the morning rearranging the board so that mine are now the same way around as yours).
No, the sensors cannot be either way around, polarity of the sense current must be correct, this is vital. The output voltage must be above 2.5v for current going into the motor and below 2.5v for current coming out of the motor.
 
OK, just for the avoidance of doubt before I make this board tomorrow, the sketch below shows the right and wrong way around, I believe, with terminal 4 of the ACS758 connected to the controller output and terminal 5 connected to the motor, so that the ACS758 output will have a positive slope when current flows from the controller to the motor, yes?

Current sensor configuration.JPG
 
Jeremy Harris said:
OK, just for the avoidance of doubt before I make this board tomorrow, the sketch below shows the right and wrong way around, I believe, with terminal 4 of the ACS758 connected to the controller output and terminal 5 connected to the motor, so that the ACS758 output will have a positive slope when current flows from the controller to the motor, yes?

Yeh I think thats right Jeremy I wouold look at how I set mine up but its at my shop ATM

From the data sheet http://www.allegromicro.com/en/Products/Current-Sensor-ICs/Fifty-To-Two-Hundred-Amp-Integrated-Conductor-Sensor-ICs/ACS758.aspx

allegro said:
The output of the device has a positive slope (>VCC / 2) when an
increasing current flows through the primary copper conduction
path (from terminal 4 to terminal 5), which is the path used
for current sampling. The internal resistance of this conductive
path is 100 μΩ typical, providing low power loss.
 
Jeremy Harris said:
OK, just for the avoidance of doubt before I make this board tomorrow, the sketch below shows the right and wrong way around, I believe, with terminal 4 of the ACS758 connected to the controller output and terminal 5 connected to the motor, so that the ACS758 output will have a positive slope when current flows from the controller to the motor, yes?

View attachment 1
yep this should be correct.
DSC00909.jpg
 
Thanks folks, I'm just doing the final checks on the board now, ready for a manufacturing session in the morning.................
 
As the Allegro part is a bi-directional hall sensor I don't see why it would matter which way the current flows through the device. A simple change in the software should allow Vout-(Vcc/2) to represent negative current and (Vcc/2)-Vout to represent positive current. Anyway looks like you have it all sorted. Anxious to see the results of this controller. :D
 
Sort of..............

I made up some boards last week, but cocked up with the board to board connection, so ended up with no way to solder the SIL header and header socket to the boards to get them to interconnect. Last night I re-did the board layout and ordered some surface mount header sockets that I think should allow me to stack two single sided boards as I want. I've ended up with the dSPIC and power stage on the lower board, together with the voltage regulators, and three ACS758s on the piggybacked board. The piggybacked board will be supported by three copper pillars and screws that carry the phase connections up to it, plus a 10 way SIL header at the other side that carries the phase current and voltage sense connections, plus the supply.

As well as making the board compact enough to fit into a fairly small space, this also means that all of the connections are pretty much at one edge of the boards, which I'm hoping should make wiring easier inside the box (no big bundle of wires going across the board as there is in a typical Chinese controller).

I may be able to post the board layouts later, once I checked them again.
 
Back
Top