magnet control through PIC


Closed Thread
Results 1 to 23 of 23
  1. #1
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38

    Default magnet control through PIC

    Okay, so I'm not sure where to put this thread.

    I need to control multiple electromagnets from a PIC18F4550. The strength of the magnets needs to be varied over time, and each magnet individually controlled. To make this more difficult, I need to control more magnets than the PIC has outputs.

    Thoughts?

    -Sterling

  2. #2
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    Implement a 4 bit binary counter and use '154 one of 16 decoder. With a 2 port PIC you could control 128 magnets easily.

    Russ

  3. #3
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    I understand the 1 of 16 decoder, but I'm lost, those decoders have 4 inputs. Two '154 ICs would require 8 pins from the PIC I'm guessing the 4bit counter resolves this, but I'm not clear how.

    Can you be a bit more specific to my untrained brain?

    Thanks,

    Sterling

  4. #4
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    What about using a 1-wire network to address each magnet seperately? Maybe that's much more costly. I have no experience with 1 wire networks.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Depending on the wattage of the magnets, there are several ways to control them. Use PWM or maybe even FREQOUT. Connect the mag circuit to you chip with an opto-isolator or drive the mags with a MOSFET or IGBT. There are pros and cons to each though.

    How many more mags than pins? How many mags need to be on at a time? Look at some of the recent post about LEDs, add driver hardware and...
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi SterlingY,

    Don't know your level of expertise, but if it would help, there's a book out for Basic Stamps (these are PIC's) called "The Microcontroller Application Cookbook" that has a chapter on expanding I/O using only a few port pins and it has some code examples. Volume 2 also has some interesting I/O examples. These books are available from www.parallax.com and www.nutsvolts.com and probably from Amazon.com.

    HTH,

    BobK

  7. #7
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Thanks for the book info. I'll check them out. Can't hurt to have them around.

    As for how many mags to control at once, all of them. I would assume that I have 2 PORTS available for their control.

    -Sterling

  8. #8
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    That reminds me of the cemetery joke: How many people are dead in that cemetery? Answer: all of them!

    My idea of using the '154 was that 8 of them could be connected with their inputs in parallel. The enable port on the '154 would be connected to 8 pins on the PIC to select the group of 16 magnets. that leaves 4 pins on the PIC for other control.

    Russ

  9. #9
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Forgive me for asking this stupid question, but wouldn't that mean that each '154 would be the same as the others: if output 3 is HIGH on one then it is HIGH on the others?

    Another question, which is a better interface I2C or Serial Data? Microchip make a 16 channel port extender in both formats.

    -Sterling
    Last edited by SterlingY; - 19th March 2007 at 03:21.

  10. #10
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    wouldn't that mean that each '154 would be the same as the others: if output 3 is HIGH on one then it is HIGH on the others?

    Only the enabled IC has an output.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by SterlingY View Post
    Forgive me for asking this stupid question, but wouldn't that mean that each '154 would be the same as the others: if output 3 is HIGH on one then it is HIGH on the others?

    Another question, which is a better interface I2C or Serial Data? Microchip make a 16 channel port extender in both formats.

    -Sterling
    I2C....because PBP has built in I2C handling capabilities (sure, it's got serial and SPI also, but I find I2C a bit 'cleaner' if that makes any sense).

    On the '154...
    The '154 has 4 inputs to control the 16 outputs, it's also got an enable line which turns the chip on or off.
    You take a 5th bit from the PIC and drive that enable line with it. If you're driving 2 '154's, you have to invert that 5th bit going to one of the '154's, that way when one is on, the other is off.
    If you want to drive a whole load of '154's, you can take 17 '154's, connect 16 of them in parallel (with say D0-D3) except for the enable line, take the 17th '154, connect it to another 4 bits from the PIC (say D4-D7), and use each of the 17th '154's outputs to drive the other 16 '154's enable line. And you'll end up with 256 individually controllable outputs. (or you could do the same thing with a '138, but with 8 '154's instead of 16 of them, or just not use all of the outputs of that extra '154 connected to D4-D7).

    Another thing, with the '154, all you'll get is ON and OFF, nothing in between. You mentioned that you want to vary the strength over time. The '154 won't do it because you can't run multiple channel pulse-width modulation through it. You could easily set up an 8 channel software driven pulse-width modulation program and drive a bank of MOSFETs with the PIC and control the magnets that way. I've done exactly this with an 18F8722 and bank of 22 RGB LEDs (66 individual LEDs total). Replace those LEDs with n-channel MOSFETs or a bunch of ULN2803A's and you've got instant magnet control (well, as long as your power supply can handle it and doesn't cause the PIC to reset!).

    Let us know if I dumbed this down too far for you, or maybe not enough, or whatever. We'll get you straightened out...

  12. #12
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Talking

    OKAY!!!!

    This is starting to makes sense. It sounds so cool, I want to build the multiport system just to build it for something, anything.

    Of course to make my problem more difficult, I am now in the process of builing my own electromagnets. That's a whole other field to learn. My problem is making them strong enough without starting a fire.

    -Sterling

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by SterlingY View Post
    OKAY!!!!

    This is starting to makes sense. It sounds so cool, I want to build the multiport system just to build it for something, anything.

    Of course to make my problem more difficult, I am now in the process of builing my own electromagnets. That's a whole other field to learn. My problem is making them strong enough without starting a fire.

    -Sterling
    Well, if you're talking about electromagnets that are going to be drawing a fair amount of current (over a total of an amp or so), then you're going to want to skip the '2003 in the first place and just go straight with MOSFETs or whatever else you choose.

    In the meanwhile, while you get your magnets built up and working well, I'd suggest setting up a bank of LEDs set up and trying those out while you sort out your software. The light from the LEDs (in relation to the PWM input to them) won't be a linear curve, and neither will your electromagnets response to that same input...but at least with the LEDs you can learn how to change your program easily to change that curve without pumping a bunch of current and potentially burning something out...then you can easily swap out those LEDs for a MOSFET and the magnets...PRESTO! instant done...almost anyways

  14. #14
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Thanks for all of the info so far.

    Can someone suggest a logic-level MOSFET that they might use for this type of project?

    Thanks,

    Sterling

  15. #15
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by SterlingY View Post
    Thanks for all of the info so far.

    Can someone suggest a logic-level MOSFET that they might use for this type of project?

    Thanks,

    Sterling
    Unless somebody else beats me to it, I'll get you a good number when I get home after work. I use a few of them, 1 logic level, a couple not so logic level (but work at 5v anyways), and a couple that need a lot of V to turn them on.

    Take the advice of the post below. I forgot you were working with electro-magnet type things.
    Last edited by skimask; - 23rd March 2007 at 18:01.

  16. #16
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink Mosfet for inductive load ???

    Hi,

    Why not look at the automotives protected IGBTs ???

    IRGS 14C40 ( I R ) or ISL9V5036 ( Fairchild ) ... MGP 15N40 ( Motorola ... ON Semi. )

    No switching issues then !!!

    Alain
    Last edited by Acetronics2; - 23rd March 2007 at 18:02.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  17. #17
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Not sure about the 14C40, but the ISL9V5036, costs almost $4, so 56 of them would be too costly. The Motorola is $2.50, still too much. I'm trying to make this thing for $50-$70.

    It may not be possible.

    -Sterling

  18. #18


    Did you find this post helpful? Yes | No

    Default

    The best MOSFET I've used and use exclusively is an N-channel IRLZ44N. It has .02 ohm ON resistance with a logic level gate drive. It's rated (I think) 44 AMPS in a TO-220 package. We use a pair of them as a replacement for a solid state relay and run them at 1 AMP continuously. They stay cool up to a couple of AMPs without a heatsink, and are bi-directional. If you reverse the load voltage from source to drain they still conduct. If you want, I'll throw a few in an envelope & mail them to you. We have a lot of them.

  19. #19
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Peterdeco1,

    That's a very nice offer, but I can just order a few if I go that route. They are certainly cheaper than the other MOSFETS suggested.

    Honetsly, I am beginning to think that MOSFETS may not be the way to go.

    It may be determined by the magnets themselves. I've built a few, and now I've got some feelers out there to see what the pros think. I have seen small magnets driven by 6V that can hold 100lbs!!! I only need 1-2lbs. What I am getting at is that I should probably learn what my magnets will require and let that determine what the drivers need to be.

    In the mean time, I'm still interested in playing with a multiport analog system and MOSFETS.

    -Sterling

  20. #20
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Another thing to look at is the switching speed. IGBTs normally will switch faster.

    I use the FGA40N60UFDTU for motor control DC at 180 volts. These are out of you price range but... http://www.fairchildsemi.com/ds/FG%2FFGA40N60UFD.pdf

    Also, the higher the voltage the less amps. (stating the obvious) So try to make a coil that will handle say 48 volts and then you might get by with a MOSFET if the switching speed is not to high.

    Either way, do not forget a fly-back diode.
    Dave
    Always wear safety glasses while programming.

  21. #21
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by SterlingY View Post
    Peterdeco1,

    That's a very nice offer, but I can just order a few if I go that route. They are certainly cheaper than the other MOSFETS suggested.

    Honetsly, I am beginning to think that MOSFETS may not be the way to go.

    It may be determined by the magnets themselves. I've built a few, and now I've got some feelers out there to see what the pros think. I have seen small magnets driven by 6V that can hold 100lbs!!! I only need 1-2lbs. What I am getting at is that I should probably learn what my magnets will require and let that determine what the drivers need to be.

    In the mean time, I'm still interested in playing with a multiport analog system and MOSFETS.

    -Sterling
    Heck, try it out with the MOSFETs and the LEDs like I suggested above...get the firmware working right...swap in the magnets and the flyback diodes, and try it out.
    As long as you've got the firmware working, if you accidentally smoke the PIC of a couple of MOSFETs, no biggie, at least the firmware is tested and works. Just have to work out the kinks at the business end...
    and of course...I've just overstated the blatantly obvious...

  22. #22
    Join Date
    Mar 2007
    Location
    West Hollywood, CA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Skimask,

    You said you built a similar thing with LEDs. Would you happen to have the schematic?

    -Sterling

  23. #23
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by SterlingY View Post
    Skimask,

    You said you built a similar thing with LEDs. Would you happen to have the schematic?

    -Sterling
    Nope, built it off the top of my head with the datasheets, didn't really have time to draw it all out. But it really shouldn't be that hard in the first place.

    Have you 'finalized' the end result yet? or do you just want to try it out with a bank of LEDs first or what?

    'cause I'm thinking that you just get a PIC up and running, oscillator, a few buttons, maybe an LCD for diagnostics, and your bank of LEDs. Get them blinking the way you want, make the LCD work, make the buttons respond...then we can get working on applying some PWM to the LEDs. Since you'll have more than a couple of outputs to control, software PWM, timer interrupts, and a few other things will have to be used. Then after that's done, modify the outputs to run electromagnets instead of the LEDs by replacing the LEDs with the MOSFET/flyback/magnet combo.

Similar Threads

  1. DTMF and PIC for Remote Control
    By doggitz in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 30th March 2010, 11:42
  2. Replies: 5
    Last Post: - 12th September 2007, 15:59
  3. Motor Control PLC with a PIC
    By sougata in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 2nd November 2006, 07:59
  4. Pic Control With Software
    By Agent36 in forum General
    Replies: 5
    Last Post: - 18th October 2006, 18:18
  5. Need help on pic to pic flow control (simple problem I think)
    By khufumen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th January 2006, 00:34

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts