CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Electronics > PIC Programing / Design


PIC Programing / Design Discuss programing of PIC chips here and design of electronics using PIC chips.


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-29-2006, 10:30 PM
spalm's Avatar
Gold Member
 
Join Date: Feb 2005
Location: USA
Posts: 578
spalm is on a distinguished road
Another PIC controller

As if I don’t have enough things to think about, I just can’t get my mind off of playing with a PIC controller. I have been tinkering around in my head with this design for a little while now and would like to throw it out there. I chose a PIC 16F684 as it costs only $1.39, has PWM and has a built-in 8Mhz oscillator. I set it up so that I could build it as either a cheap unipolar or by adding high side drivers and FETs, it could drive a bipolar. The costs come out quite reasonable, see attached bill of materials from Mouser. Of course connectors, passives, PCB, etc always add up.

Quick circuit description:

The PIC gets STEP and DIR inputs and looks up values to place in the PWM. The PWM will be running just outside the audible range at about 25khz. It has two outputs that are the complement of each other. The PWM is just a variable duty cycle oscillator, so it can for example direct 70% to one winding and 30% to the other in order to get micro stepping. It also has four other outputs to enable the FETs for switching directions.

The sense resistor is fed to a comparator to monitor current limit. When the current is too high, the comparator will drive its output low clearing the ‘165 shift regs. These will clock out 0’s disabling the FETs as long as the comparator is low. When the current subsides, the shift regs will take another 8 clocks to shift in the HI on the SDI pin and turn on the FETS. The clock output from the PIC is 2Mhz, so this will take about 4 usec.

For unipolar, do not install the high side drivers or FETs, and connect the center tap to VMOT. For bipolar, install everything and connect the motor across pins 1 and 4.

I realize that I need to work on stepping down VMOT more before it hits the regulators, more bypass, EMF diodes, and a few other things.

Is it worth pursuing? Suggestions?

Steve
Attached Files
File Type: pdf PICstep2 .pdf‎ (32.9 KB, 1318 views)
File Type: doc PICstep2 BOM.doc‎ (256.5 KB, 575 views)
Tweet this Post!Share on Facebook
Reply With Quote

  #2  
Old 06-08-2006, 11:13 PM
joecnc2006's Avatar
www.joescnc.com
 
Join Date: Aug 2004
Location: usa
Posts: 3,055
joecnc2006 is on a distinguished road

Any Progress?
Tweet this Post!Share on Facebook
Reply With Quote

  #3  
Old 06-10-2006, 10:38 PM
spalm's Avatar
Gold Member
 
Join Date: Feb 2005
Location: USA
Posts: 578
spalm is on a distinguished road

Progress? Hmmm. Lots of hours spent. I have learned a lot.

I’m still trying to do a cheap upgradeable design. Progress is just so slow, so many things to worry about. I did my first (and second and third) toner transfer PCB today. I took Phil’s advice and ended up using a glossy advertisement from a mattress store as the print medium. It worked so much better than the other papers I was trying. The ad had color pictures all over it, but that made no matter. It was nice and thin, so the removal was much easier also.

I changed the design from post #1. It seems to me that stepper controllers have 5 parts: the Logic (processor), the Current sense/monitor, the Chopper, the Drivers, and the FETs. I moved all of the current and chopper out of the processor and into hardware (just like the original PIC design). After a lot of thinking about it, it just seemed more predictable (and I was not too impressed with the comparators and resistor ladder in the PIC). Simple IC’s are extremely cheap, so the cost comes out as a wash. Problem is that the chip count went up, so it is fairly packed on a one sided board that is etched at home. To packed for me, over 250 holes and 45 jumpers. But this bipolar design from Mouser is still under $15 with pretty good quality 60 volt / 20 amp FETs and $2 in sense resistors.

I came up with a 4 bit resistor network D2A that lets me have 51 different voltage levels for the steps in a sine wave. By pulling up combinations of resistors, and pulling down others, and letting others float. I attached a spread sheet of my playing around with this. It was kind of fun. It also has what a hex value waveform and a ten step waveform look like for comparison.

I have to come up with a better way to route or shrink this thing, or just give up.

Would like some critisism.
Steve

Edit: Just a note: I only see this as a 3 or 4 amp, and about a 45 volt controller. I am not trying to enter into the high drive stuff.
Attached Thumbnails
Click image for larger version

Name:	PCB2.jpg‎
Views:	567
Size:	109.4 KB
ID:	18821  
Attached Files
File Type: pdf Schem2.pdf‎ (38.3 KB, 753 views)
File Type: pdf PCB3.pdf‎ (56.6 KB, 429 views)
File Type: xls ResNetwork.xls‎ (46.5 KB, 295 views)

Last edited by spalm; 06-10-2006 at 10:56 PM. Reason: High current disclamer
Tweet this Post!Share on Facebook
Reply With Quote

  #4   Ban this user!
Old 06-10-2006, 11:38 PM
pminmo's Avatar  
Join Date: Jun 2003
Location: St. Peters, Mo USA
Age: 59
Posts: 3,325
pminmo is on a distinguished road

I think you are going to have trouble with the reliablility of your bridges.
__________________
Phil, Still too many interests, too many projects, and not enough time!!!!!!!!
Vist my websites - http://pminmo.com & http://millpcbs.com
Tweet this Post!Share on Facebook
Reply With Quote

  #5  
Old 06-11-2006, 12:25 AM
spalm's Avatar
Gold Member
 
Join Date: Feb 2005
Location: USA
Posts: 578
spalm is on a distinguished road

Sorry Phil, I don't understand.

Steve
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-11-2006, 10:51 AM
pminmo's Avatar  
Join Date: Jun 2003
Location: St. Peters, Mo USA
Age: 59
Posts: 3,325
pminmo is on a distinguished road

Shoot through, low side gate drive, among others
__________________
Phil, Still too many interests, too many projects, and not enough time!!!!!!!!
Vist my websites - http://pminmo.com & http://millpcbs.com
Tweet this Post!Share on Facebook
Reply With Quote

  #7  
Old 06-11-2006, 09:11 PM
spalm's Avatar
Gold Member
 
Join Date: Feb 2005
Location: USA
Posts: 578
spalm is on a distinguished road

OK, please help me understand this.

Is driving a bipolar bridge really that much more of a problem than driving a unipolar stepper. It seems to me like they are very close; same current, same voltage. I thought the hard part was getting the high side drivers to work correctly. The plus side is 30% more torque.

I am driving the low side with low power CMOS, like a lot of other designs do. They all seem to work OK. I also kicked up the voltage on this part to help discharge the gate capacitance a bit quicker.

I just added the eight diodes to help absorb the back EMF. The FETs do have these built in, but for a dollar more, better safe than sorry. A large number of low cost controllers have also left off these diodes and they seem to weather the storm.

I have separate control lines to drive each side of the bridge. This allows me to turn off everything when a change of direction occurs and let the back EMF be absorbed before energizing the other side.

Thanks for your help,
Steve
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 06-12-2006, 08:00 AM
pminmo's Avatar  
Join Date: Jun 2003
Location: St. Peters, Mo USA
Age: 59
Posts: 3,325
pminmo is on a distinguished road

yes and no,
The problem, is everybody thinks MOSFETs are a simple device present a gate voltage, and they turn on. Each MOSFET has characteristics, where simple cmos will drive one logic level mosfet, it won't necessarily drive the next PN MOSFET. Gate capacitance and charge and switching speeds all come into play. Where H bridges seperate in drive complexity doesn't end at how to drive the high side. You HAVE to make sure you don't have both and HI and LOW side FET on the same side of the bridge on at the same time. And you have to be sure that is true for the whole tolerance range of the P/N of the selected devices.
__________________
Phil, Still too many interests, too many projects, and not enough time!!!!!!!!
Vist my websites - http://pminmo.com & http://millpcbs.com
Tweet this Post!Share on Facebook
Reply With Quote

  #9   Ban this user!
Old 07-04-2006, 10:26 PM
 
Join Date: Jul 2005
Location: us
Age: 55
Posts: 668
Madclicker is on a distinguished road

Steve,

You might want to use a couple of half bridge drivers that are made for bipolar drives. The charge pumps keep from having shoot through problems with the naked fets.

A couple per motor coil that is.
__________________
Steve
DO SOMETHING, EVEN IF IT'S WRONG!
Tweet this Post!Share on Facebook
Reply With Quote

  #10  
Old 07-05-2006, 10:39 AM
spalm's Avatar
Gold Member
 
Join Date: Feb 2005
Location: USA
Posts: 578
spalm is on a distinguished road

Steve, I agree. Seems to me that the IR2104 drivers would work for this small of a current load and they are $2.40 from Arrow and they include shoot through protection. I was going to give up on this little experiment, but judging by the PMs I have received; I plan to keep plunking along.

I have two separate designs now: a unipolar and a bipolar. I talked myself out of a D/A converter and went with PWM. Actually it needs two separate PWM modules and there are only a few PICs with two. They are pretty much pin compatible so I am trying to accommodate a few choices. The PIC16F873 seems a fair choice, but it is $4.25 at Mouser. I also ordered some brand new PIC18F24J10 from Microchip Direct for $2 each (shipping was obnoxious as they had to come from Singapore, but they say the parts will be available soon for distributor purchase) but they are a 3.3volt device so extra regulation and level shifting needs to happen. The open collector TTL inverters do the level shifting when using CMOS parts (the IR2104 is already 3.3v compatible).

Actually the charge pumps are there for the purpose of being able to drive the high side gate of an N-channel FET all the way to the top rail (or beyond). There is extra logic and a time delay inside the driver to control shoot through.

I will try to get some boards built to try it out.
Any thoughts or comments are more than welcome.

Steve
Attached Files
File Type: pdf BiPICstep.pdf‎ (37.7 KB, 605 views)
File Type: pdf UniPICstep.pdf‎ (30.6 KB, 452 views)
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 07-10-2006, 06:03 AM
 
Join Date: Jul 2005
Location: us
Age: 55
Posts: 668
Madclicker is on a distinguished road

Shows how little I know about real world circuit design. Just associated the charge pumps with the shoot through protection. Had thought before that delays might work.

Can't see why 2104's couldn't work, they work for gecko's.;-) Some of the big dogs here say you should use real driver chips instead of home brew and I'm sure that's true.

My concern is providing idiot protection on the output. It costs extra on the geckos. Don't have a clue what's involved. This is one of the reasons I'm gonna try the lmd18245's for my first baby step. I think I have some samples coming. I wish I had access to the dac output because I want to add lead compensation to take care of mid-band resonance. I can always make my own 3-bit dac with an opamp.

How are you going to use 2 designs, unipolar and bipolar? Are the step sequences the same?
__________________
Steve
DO SOMETHING, EVEN IF IT'S WRONG!
Tweet this Post!Share on Facebook
Reply With Quote

  #12  
Old 07-18-2006, 11:46 AM
spalm's Avatar
Gold Member
 
Join Date: Feb 2005
Location: USA
Posts: 578
spalm is on a distinguished road

Well, I decided to make a flexible prototype PCB (4”x5”) that I will condense once I have tried some stuff because I just couldn’t make up my mind on what I was trying to design here – cheap or robust. I have it set up so I can do unipolar and bipolar type testing. I added AND gates and control outputs that will allow different styles (with some chip replacing and pin lifting). Four different styles of drive are possible for each type. All will use PWM for the microstepping and simple current chopping.

Style 1: Run both coils with simple sinusoidal currents from 0 to max.

Style 2: Run one coil with simple sinusoidal current and the other coil always turned on (sometimes called Hi-Torque).

Style 3: Run both coils as you would a servo or DC motor. That is, each coil always gets max current that is oscillating back and forth to get the sum to be a sinusoidal result. (Does this make sense to anyone else?).

Style 4: Use style 3 but keep one coil always turned on.

(I am rooting for style 3 bipolar).

I’ve received all the parts and sent out for PCBs to be made as I just can not find time to make them myself. I got a new stepper motor rated at 4.6 Amps for current testing, and it has 8 wires to test all the different modes (plus serial and parallel bipolar).

I am starting with a 5volt PIC16F737, but have options to go to the 3.3volt PIC18F45J10 when I get more confident. I am using the free MPLAB toolkit from Microchip and writing in assembly.

I plan to have on-board programming for the chip and I have most of the programmer written in Visual C, so I don’t have to buy a programmer thingy.

I am including my schematic and silk, top, and bottom of the PCB.

Now to find some more free time,
Steve
Attached Files
File Type: pdf Layout.pdf‎ (299.7 KB, 416 views)
File Type: pdf Schematic.pdf‎ (45.7 KB, 635 views)
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 10:13 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353