News:

Let's find out together what makes a PIC Tick!

Main Menu

Buy an PLC or use a PIC board

Started by basparky, Jul 26, 2021, 02:14 PM

Previous topic - Next topic

basparky

Hi all,

I was just thinking.. I need to build a machine which we use in our production facility. Machine will be used 24/7 and need to be simple in use.

I would love to use a Pic to do the job but are wondering if there any 'standard' IO/ dev boards available. I need to control the following:
- 8 steppers by step/dir.
- 1 servo by step/dir.
- Read 21 digital (sensor) inputs
- Switch 2 5/2 pneumatic valves.
- thats about it.


What would you guys do in such situation? There is time and not a lot of pressure. I need to build and maintain the machine myself.

Or just by a PLC or HMI/PLC? Any suggestions in this? I have experience with Siemens but is to expensive in this case.

Any suggestions very welcome!

Thanks in advance

Tenaja

So many steppers would require (depending on speed demands, and how many might move at a time) a pic for each motor, or serially controlled steppers. It would most likely be easier to use an Arduino, since there are many libraries already set up for steppers.

Myself, I'd probably go with something like a duet 3d printer board--they have add-ons to extend the i-o beyond your needs. The gcode is pretty easy to handle. (I've used one for industrial control before.)

But, depending on the actual project, a "real" PLC might be simpler to set up.

RGV250

Hi,
Have you looked at the S7-1200 range from Siemens, pretty powerful and relatively cheap.

Regards,
Bob

top204

#3
An Arduino is less powerful than a PIC18F device, and the standard Uno board uses a, very much, outdated microcontroller on it!.

One of the better ways to interface to a stepper motor is to use a seperate drive such as the DRV8711:

DRV8711DCPR IC Motor Controller

It interfaces to the microcontroller via an SPI interface, so many of them can easily be controlled via a single PIC18F microcontroller, with microsteps of up to 128 if required. They are very easy to interface with and simple commands set the stepper current requirements etc, and tell it its direction, then either send an SPI command to step it, or pulse one of its pins to step it. There is no pulsung of seperate pins of the stepper motor or timing slices etc for smooth steps etc... The chip does it all for you beautifully!

You can design your own board using the individual DRV devices, or purchase ready made boards, but these tend to be a bit more expensive for what they are, especially now! You can always purchase a ready made board to test your firmware, then design your own PCB with 8 of them on it when you know it is working.

The servo motor can be interfaced using a simple timing interrupt because they operate quite slowly.

The digital pins will be very easy to interface with, especially with the newer 18F devices that have an INT that can be enabled for each I/O pin, so a signal is never lost because it will set a flag, or enter an interrupt when it is detected going either high to low or low to high.

The pneumatic valves I cannot advise on beacause I do not know how they are interfaced with.

Using third party libraries is not always the best method, because if a device's operation is not understood, how can it be corrected if the library fails etc... Also, the C++ libraries are utterly dreadful things and bloated, and way over complex for what they actually do. If using a Positron library, it can at least be understood and easily changed to suit, and it certainly is not over bloated and slow in operation, as the C++ code is on an 8-bit microcontroller. :-)

Tenaja

I've controlled steppers from everything from a basic stamp to a pc, dedicated controller, 32 bit controller, 18f, and several others I can't recall today.

There are numerous serially controlled step generators. (As I mentioned above.) If you aren't going super slow, you need one that has acceleration. Since this is for in-house use, it's likely the cheapest route, unless those 8 motors must be tightly coupled. If that's the case, and they need tight synchronization, then they might cause frustration.

A 32 bit Arduino can do a lot more than any pic that's not 32 bit... It's not just faster, but also a lot more efficient with it's clock... Not 4 clocks per instruction.

When you need the motors in sync, it's the accel& decel that really grind a pic to a halt. (Assuming you aren't running the motors super slow.) I've done it with an 18f, and had to use a lookup table for accel, but it couldn't handle synchronized moves.

I'm a pic fan, and not into Arduino, but the latter has an amazing library of stepper libraries to choose from... And if you choose wisely, they aren't complicated. They Include (but not limited to) grbl and other CNC-ready projects that give decent step rates that an 18f could only dream of. Trying to run synchronized steppers with a pic is like trying to reinvent the wheel. Possible, but not likely to make your boss happy with the dev time.

For the other i-o, use a board with an opto-22 style module. One with a shift register should be fine unless you need ultra precision timing. Modules will save headaches... Relays are headaches on a production line.
(For similar reasons, try to use modular motor controllers, or off the shelf control like duet. You want repairs fast with minimal down time.)

basparky

Thanks for the feedback!

just had a quick look at the S7-1200 range and yes indeed, not to expensive except need to get a license and TIA portal package. The idea of using a 3D printer board is also nice. proven technology and i do believe the Code can be send from whatever device.

I haven't done much with Arduino... It does look interesting and time saving to use ready made libraries and boards. I understand why Arduino is so popular but i'm somehow not convenient using it. 2 years ago i did a blink led test with a 'blue pill' STM32 board using the Arduino IDE.STM32Blue pill board....

While writing this perhaps using such a board is also an option?? :-\

For this machine i need to control the 8 steppers individual but at low speed and simple ramp up-down. I need to drive a spindle 1 rotation every time a product passes. Some homing and reset procedures and thats it.  I believe i can do this with step/dir from a dspic but looking at for example: https://www.pololu.com/product/3134

I do think this makes things more easy...

Anyone used this board?



JonW

I would not use off the shelf hobby development boards for any industrial product but rather build a custom board for that specific purpose or use high quality generic modules that will be supported over time.  This way you control the whole design and can easily get/produce spares to minimise any down time on you production line, documenting it and controlling the design will make it easy for debug and also for another engineer to pick up.

Designing a board and even getting them SMT is really easy now with the likes of JLCPCB and you can literally turn a new design within a week for boards and 2-3 with SMT.

top204

A standard PIC24F would do the job nicely, but one of the new dsPIC33CK devices would do it superbly. They are very inexpensive, run at 100 MIPS and have quite a bit of RAM and flash memory, and have a lot of peripherals inside them.

I agree with Jon... Keep away for the hobbyist boards for a professional unit. They, generally, have zero protection around them and some of them have never heard of correct decoupling methods. :-) For testing a stepper controller chip for prototyping and firmware writing, using a cheap hobbyist board is OK, but in the final unit, it should be a professionally designed circuit with all the protections put in place.

Gamboa

Basparky,

I designed my PLC for a specific application. It is a somewhat particular PLC. It has a control module with a PIC24 and then communicates with the input and output modules by RS485, being able to put them distributed. Each input module has 16 inputs and each output module has 16 outputs. You can connect multiple input modules and multiple output modules. It has the disadvantage that it does not work in real time and it asks the input module every 50ms. For many applications that do not need to be immediate response it works perfectly. The input and output modules have a PIC18F25K22 for communication and input / output control.

I attach images with three connected modules.
It is just an idea for providing a different vision.

Regards,
Gamboa
 
Long live for you

Gamboa

Sorry , input module
Long live for you

CPR

Quote from: top204 on Jul 26, 2021, 09:11 PMAlso, the C++ libraries are utterly dreadful things and bloated, and way over complex for what they actually do. If using a Positron library, it can at least be understood and easily changed to suit, and it certainly is not over bloated and slow in operation, as the C++ code is on an 8-bit microcontroller. :-)

Not ALL the C++ Libraries are dreadful and bloated or "slow" Take Kriegsman/ Daniel Garcia excellent FastLED (for controlling many WS2812B type leds) as an example, or Alexy Dynda's ultrafast/compact lcdgfx libraries. I'm controlling a string of 60 WS2812B leds, with 16 different effects, selected by a rotary controller which displays on a 128x64 OLED with custom bitmaps for numerals AND I have a serial RS232 RF link using a HC12. All of this runs simultanously on an 8bit Arduino Nano. 

Tenaja

Quote from: CPR on Jul 27, 2021, 01:02 PMNot ALL the C++ Libraries are dreadful and bloated or "slow"... 
I agree--this is like saying "all basic is slow and bloated." Of course, we here know better--it depends on the paticular implementation.

John Lawton

Quote from: Gamboa on Jul 27, 2021, 12:01 PMBasparky,

I designed my PLC for a specific application. It is a somewhat particular PLC. It has a control module with a PIC24 and then communicates with the input and output modules by RS485, being able to put them distributed. Each input module has 16 inputs and each output module has 16 outputs. You can connect multiple input modules and multiple output modules. It has the disadvantage that it does not work in real time and it asks the input module every 50ms. For many applications that do not need to be immediate response it works perfectly. The input and output modules have a PIC18F25K22 for communication and input / output control.

I attach images with three connected modules.
It is just an idea for providing a different vision.

Regards,
Gamboa
 

Hi Gamboa,
that looks very interesting, I've thought of designing a little PLC type unit a couple of times when it seems I might have an application. Yours looks very good, surprising slow though, why is that, as RS485 isn't too slow?

John

ken_k

Quote from: basparky on Jul 26, 2021, 02:14 PMHi all,

I was just thinking.. I need to build a machine which we use in our production facility. Machine will be used 24/7 and need to be simple in use.

I would love to use a Pic to do the job but are wondering if there any 'standard' IO/ dev boards available. I need to control the following:
- 8 steppers by step/dir.
- 1 servo by step/dir.
- Read 21 digital (sensor) inputs
- Switch 2 5/2 pneumatic valves.
- thats about it.


What would you guys do in such situation? There is time and not a lot of pressure. I need to build and maintain the machine myself.

Or just by a PLC or HMI/PLC? Any suggestions in this? I have experience with Siemens but is to expensive in this case.

Any suggestions very welcome!

Thanks in advance


My guess is development and debug time may make it as cheap to use a PLC/HMI, if the program is written in structured text most industrial electricians would be able to edit the code, hardware repairs could be made using off the shelf components, even changing to a different PLC is not so bad. I have been down this path myself and used both solutions.

Gamboa

John Lawton,
In my case it was about controlling limit switches and solenoid valves.

I was interested in a distributed system and did not need a lot of speed so I chose RS485. For communications I chose 9600 bps. You can raise the speed up to 115200 without problems. The control unit asks the input unit every 50ms. But the input unit can be made to send a message to the control unit when there is a change in any input and raising an interrupt in the control unit would be very fast.

At a speed of 115200 it could work with times of 3ms. This is not real time either and it is valid for many processes but not for all cases.

Regards,
Gamboa
Long live for you

basparky

Thanks for your feedback all!

Very interesting configuration Gamboa. I'm very interested in such a design! Perhaps a bit too much in this case but very nice to develop and build something like this. In Holland we say: Petje af! i have no idea ho to translate this correctly. Maybe something like, respect for your work or so:)

I'm close to using the dsPic33CK as suggested and design a mainboard such as Gamboa has made or so. Is this something people on this forum would like as open source project with input from all of us?
I'm just a hobbyist electronic noob so i would love to do the kick off but need some help :)