Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
freesigs:start [2011-08-24 10:22] becki |
freesigs:start [2011-11-16 11:05] (aktuell) |
||
---|---|---|---|
Zeile 2: | Zeile 2: | ||
===== Overview == | ===== Overview == | ||
- | Free Signals is a **power logic control** (PLC) in the works. It has some unique features: | + | {{http://think-deep.com/becki/favicons/freesigs.png }} Free Signals is a **power logic control** (PLC) in the works. It has some unique features: |
* First of all, Freesigs is distributed under the [[http://www.eclipse.org/legal/epl-v10.html|Eclipse Public License]], that means it is freely available. No dongles, no licence fees. Neither for the runtime, nor for the development tool. -- Open source for automation developers. | * First of all, Freesigs is distributed under the [[http://www.eclipse.org/legal/epl-v10.html|Eclipse Public License]], that means it is freely available. No dongles, no licence fees. Neither for the runtime, nor for the development tool. -- Open source for automation developers. | ||
* Freesigs PLC user programs are written in [[wp>Lua_%28programming_language%29|Lua]]. This is a powerful //and// easy to use scripting language. No more awkward Structured Text or Ladder Diagrams!\\ Whats more, by using a scripting language, there is no intermediate compile cycle. You can try out your code directly. | * Freesigs PLC user programs are written in [[wp>Lua_%28programming_language%29|Lua]]. This is a powerful //and// easy to use scripting language. No more awkward Structured Text or Ladder Diagrams!\\ Whats more, by using a scripting language, there is no intermediate compile cycle. You can try out your code directly. | ||
* Freesigs doesn't need a development environment. In fact, your web browser is the IDE. This works on every computer and operation system. No need to install anything. All you need is a network connection. | * Freesigs doesn't need a development environment. In fact, your web browser is the IDE. This works on every computer and operation system. No need to install anything. All you need is a network connection. | ||
- | * Freesigs works event based. Even though it is possible to write traditional cyclic code, it is not recommended . Events are more flexible and effective to work with, and are more CPU friendly. See the examples below. | + | * Freesigs works event based. Even though it is possible to write traditional cyclic code, it is not recommended . Events are more flexible and effective to work with, and are more CPU friendly. Have a look at the examples below and the [[API]]. |
- | * Freesigs is extensible. To cope with the multitude of different fieldbusses around, the application is split into a core process and one or more IO processes (connectors). To add support for a certain fieldbus, just the IO connector needs to be written. It is not necessary to modify the core. Currently Modbus/TCP is implemented. | + | * Freesigs is extensible. To cope with the multitude of different fieldbusses around, the application is split into a core process and one or more IO processes (connectors). To add support for a certain fieldbus (or any other connector type), just the IO connector needs to be written. It is not necessary to modify the core. Currently Modbus/TCP is implemented. IO connectors can be written in any language. |
+ | |||
+ | ===== Documentation == | ||
+ | |||
+ | * [[API]] Reference | ||
+ | * [[Install]] Instructions | ||
+ | * [[Tutorial]] | ||
===== Requriements - What do I need? == | ===== Requriements - What do I need? == | ||
==== Hardware == | ==== Hardware == | ||
- | * Any Computer designed to run 24/7, e.g. a [[wp>SheevaPlug]] | + | * A Computer designed to run 24/7, e.g. a [[wp>SheevaPlug]]. Of course you can also use a PC or laptop.\\ {{sheevaplug2b.jpg?90|SheevaPlug}} |
- | * At least one fieldbus coupler (bus controller). The [[http://www.wago.com/wagoweb/documentation/navigate/nm0dc__e.htm|Wago]] 750-341, 750-342 and the B&R BC 0087 are known to work. | + | * At least one fieldbus coupler. Eg. [[http://www.wago.com/wagoweb/documentation/navigate/nm0dc__e.htm|Wago]] 750-341, 750-342 or B&R BC 0087.\\ {{wago_750-341.jpg?90|Fieldbus Coupler}} |
==== Software == | ==== Software == | ||
Zeile 26: | Zeile 32: | ||
===== Current State / Download == | ===== Current State / Download == | ||
- | Freesigs is still a young project. The Modbus IO connector is completed. The core system is currently in the works. Code is available at [[http://bitbucket.org/becki/freesigs|Bitbucket]]. | + | The Modbus IO connector and the core system is completed. We can connect an arbitrary number of bus couplers, register events on digital/analog inputs and control digital/analog outputs. Timer can be used. The code examples below are working. |
+ | The web programming interface needs yet to be done, but this is not vital anyway. | ||
+ | |||
+ | Code is available at [[http://bitbucket.org/becki/freesigs|Bitbucket]]. Bitbucket is also the place to get in contact. | ||
===== Code Examples == | ===== Code Examples == | ||
==== A latching relay in Freesigs / Lua == | ==== A latching relay in Freesigs / Lua == | ||
+ | |||
+ | <code lua> | ||
+ | -- First give the in- and outputs speaking names: | ||
+ | button1 = DI(0,0) -- digital input #0 on bus coupler #0 | ||
+ | button2 = DI(0,1) -- digital input #1 on bus coupler #0 | ||
+ | lamp = DO(0,0) -- digital output #0 on bus coupler #0 | ||
+ | </code> | ||
<code lua> | <code lua> | ||
Zeile 36: | Zeile 52: | ||
-- Function to control the relay output: | -- Function to control the relay output: | ||
function ctrl_latch_relay() | function ctrl_latch_relay() | ||
- | -- just invert output: | + | lamp:toggle() -- just invert the output |
- | local out= bc1.o[1].val() | + | |
- | bc1.o[1].set(not out) | + | |
end | end | ||
- | -- Register the function to be called when the digital input #1 of IO device (bus controller) "bc1" rises: | + | -- Register the function to be called when button1 is pressed: |
- | bc1.i[1].on_true(ctrl_latch_relay) | + | button1:on_rise(ctrl_latch_relay) |
- | -- Register the function to be called when the digital input #2 of IO device (bus controller) "bc1" rises: | + | -- Register the function to be called when button2 is pressed: |
- | bc1.i[2].on_true(ctrl_latch_relay) | + | button1:on_rise(ctrl_latch_relay) |
</code> | </code> | ||
Zeile 51: | Zeile 65: | ||
<code lua> | <code lua> | ||
- | bc1.i[1].on_true( | + | button1:on_rise(function() lamp:toggle() end) |
- | function() bc1.o[1].invert() end | + | button2:on_rise(function() lamp:toggle() end) |
- | ) | + | |
- | + | ||
- | bc1.i[2].on_true( | + | |
- | function() bc1.o[1].invert() end | + | |
- | ) | + | |
</code> | </code> | ||
- | ==== For comparison: Cyclic approach == | + | As you can see, two lines of code are enough to implement a latching relay with Freesigs. |
- | <code lua> | + | ==== For comparison: Traditional PLC code == |
- | -- Latching relay, cyclic approach. Not recommended! | + | |
- | old_in1= false | + | <code> |
- | old_in2= false | + | # Check if button 1 was pressed: |
+ | A button1 | ||
+ | AN button1_old | ||
+ | = button1_pressed | ||
- | function ctrl_latch_relay() | + | # Check if button 2 was pressed: |
- | local in1= bc1.i[1] | + | A button2 |
- | local in2= bc1.i[2] | + | AN button2_old |
- | local out= bc1.o[1] | + | = button2_pressed |
- | -- Check for a rising edge on either input: | + | # Switch light on: |
- | local edge= in1.val() and not old_in1 or in2.val() and not old_in2 | + | A button1_pressed |
+ | O button2_pressed | ||
+ | AN lamp | ||
+ | S lamp | ||
- | -- Invert output if there was a rising edge: | + | # Switch light off: |
- | if edge then | + | A button1_pressed |
- | out.set(not out.val()) | + | O button2_pressed |
- | end | + | A lamp |
+ | R lamp | ||
- | -- Save current input states for next edge detection: | + | # Save current state of button1 for next cycle: |
- | old_in1= in1.val() | + | A button1 |
- | old_in2= in2.val() | + | = button1_old |
- | end | + | |
- | -- Tell Freesigs to call the function "ctrl_latch_relay" cyclically: | + | # Save current state of button2 for next cycle: |
- | on_main_timer(ctrl_latch_relay) | + | A button2 |
+ | = button2_old | ||
</code> | </code> | ||
+ | ===== What comes next == | ||
+ | |||
+ | * Web programming interface | ||
+ | * Tutorial and install instructions | ||
+ | * Remove Glib dependencies. This allows Freesigs to run on an embedded Linux like the [[:becki:linux:wago_750-860_tips|Wago 750-860]]. With this you can use Freesigs standalone. Or you can use the Bus controller itself as controller for other bus couplers. | ||
+ | * We need a live demo in the Internet | ||
+ | * Create a Lua user library | ||
+ | * More extensibility: | ||
+ | * Possibility to work with several APIs. For this, each connector gets an API identifier assigned. Commands from an unknown API are simply forwarded to a Lua user callback. Hence the user can create new commands without changing the core. | ||
+ | * Allow Lua user code to start and stop connector child processes during runtime |