Introduction: Arduino PLC Master Industrial Controller for Festo CPV Valves

Browsing round my local scrapyard I cane across five Festo CPV14 pneumatic valve manifolds. My eyes lit up. This was treasure. Not scrap. The proprieter kindly let me take them for free. But how do they work ?

Supplies

CPV14-GE-DIO1-8 relay driver interface

CPV14 servo valve block with 8 double acting "C" pneumatic switches

Power supply providing 24V > 100mA

Teensy 3.6 in breadboard

Adruino IDE with teensy support

Two off MAX485 TTL to RS485 module

jumper wires

An indespensible website https://www.felser.ch/profibus-manual/adressbyte.html

Step 1: Protocol and Address Settings

Festo has some great manuals and after a little surfing I found CPV-DI01_1999-04_165817g1.pdf  which described four possible communication protocols. Profibus-DP seemed like the most standard one so I went for it. The protocol setting is set by switches on a removable block in the interface module. The four way switch is two bits D0 and D1 for protocol setting and D2 D3 for extension module, not fitted here. The eight way switch is module address with D8 = diagnostic .

My setting was 00 profibus , 00 no extension, 11000001 address 3 with disagnotics enabled.

Step 2: RS485 Loop Back Test

The interface on this module is a two wire profibus DP implementation which uses RS485 as its physical layer. The signals are named A and B .The profibus has an aditional requirement of 2.1V minimum delta between the A B signals but driving from 3v3 appeared to work . Its important to have the termination enabled by the switch in the RS485 CPV14 connector.

I used two RS485 modules with one switching between transmit and recieve and a second one as recieve only so I could read on port 2 what I was sending on port 1 . This initially was wrong as I was using arduino print where I should have used write. Once I was sending raw bytes I could start to shout ignorantly in pigeon profi at the cold silent monolith.

Step 3: Powering Up

The scrap yard had been unkind to the modules , four of five power connectors had the threaded sleve snapped off leaving just the pins but one had an intact connector, the connections from the manual were 24V nominal at 100mA to supply the interface and relays on two pins, 0V and an earth to the case. If only the circuit is powered the green power led flashes. with both circuit and relays powered the green is stable but will flash if the rail goes below about 20V . The red bus led was blinking. I opened all the modules up before powering as some has mosture in them but all have worked after drying.

Step 4: First Contact

The profibus protocol has a very specific format. A correctly formatted diagnostic message should always be answered even with an unconfigurated device. It seems to need at least two requests and answers the second or susequent, I put the diagnostic request in a loop waiting for any response which finally came. The RS485 is intended for long busses so has a termination requirement, this is a switch in the connector which should be on in the final module. The Arduino default serial parameters were also wrong, it needs to be set to Even parity, 8E1. A common ground signal isnt required from what i can tell but i connected one anyway. The ebay RS485 module connections needed A and B swapping to the profibus connector.

The diagnostic request :

Serial2 sent 68 05 05 68 83 81 6D 3C 3E EB 16 // the first four bytes are the header , 0x68 is a SD2 message format with the 0x05 as data length, this is repeated with SD2 , next is DA destination address 3 with D7 high to flag that a the message contains a DSAP address (the ox3C) , next is SA, source address , this i just set to 1 for the master but it could be anyother address if there are multiple masters. Again this has D7 set to indicate a SSAP address in the data payload (0x3E) , the 0x6D is a compiled bit pattern for the message function for a request ( D6) , a data send and request , high priority with bit toggling off and bit D4 high. The last two bytes are uint8_t checksum of the data payload and a message end 0x16

the CPV answer : 68 0B 0B 68 81 83 08 3E 3C 02 05 00 FF 00 C9 55 16 // 0x02 and 0x05 are the key responses effectivley saying no config, no parameters Go to the Back, Theres always one, note the source and destination addreses 81 , 83 are swapped in the answer. Diagnostic messages are detailed in the Festo manual.

Step 5: Parameter , Config and Data

The setup requires a parameter and config message, these are detailed in the profibus protocol documents but the specifics are in the Festo manual. The parameters are for watchdog timings, freeze and sync, all set to zero to disable for now. The profibus appears to suggest the config message should have two bytes of data following the identifier 0x00C9 but this gave a message response rather than a pure single byte ackwnolege so they were not needed. The code has comments so hopefully its self explanitory. When fully configured and data is sent the red bus light stops flashing and goes out ! sucess .( goes through motion of hitting a baseball out of the park, ) and ive never played baseball.

The cyclic data exchange messages don't have DSAP or SSAP addresses and contain two bytes , 16 bits for the 16 relays in the block. 1 is on. 0 off.

If the voltage is turned down whilst requesting diagnostic it extends the message to report low voltage.

Step 6: Next Steps

I haven't pressurized the system yet but all the valves click happily , If I lift the interface block off the relays the led's dont light up so its an intellegent controller and probably has lots of diagnostic data and the switch settings can be read. with a specific function command. Also there were some extension blocks ive yet to explore. A really exciting project getting an industrial controller runnng without commertial S7 or similar PLC master. Finally a big thanks to Festo for making such a beautiful work of art, Felser very clear documentation of Profibus protocol and TuenHiDiy