Die Erfindung betrifft eine Schaltungsanordnung zur Abfrage des Kontaktes eines Impulsgebers der im Oberbegriff des Anspruchs 1 oder 2 genannten Art.
Inkrementale Impulsgeber werden beispielsweise in mechanischen Zählwerken eingesetzt, um die Umdrehung des die letzte Ziffer anzeigenden Zählrades elektronisch zu erfassen. Dabei wird beispielsweise ein Reedkontakt geschlossen, solange die Ziffer 0 sichtbar ist. Bei einem gewöhnlichen Reedkontakt können nur die beiden Zustände "Kontakt offen" oder "Kontakt geschlossen" detektiert werden. Bei einem Impulsgeber, der einen Reedkontakt mit Namur-Beschaltung aufweist, ist es hingegen möglich, zwei weitere Zustände, nämlich "Kurzschluss" oder "Unterbrechung" des zum Impulsgeber führenden Stromkreises zu detektieren. Bekannte Schaltungen verwenden dazu als Vergleichselemente eingesetzte Operationsverstärker, um zu detektieren, ob der gemessene Ausgangswiderstand des Impulsgebers innerhalb eines vorgegebenen Fensters liegt.
Der Erfindung liegt die Aufgabe zugrunde, eine Schaltungsanordnung vorzuschlagen, die auf einfache Weise die Abfrage eines Impulsgebers mittels eines Mikrocontrollers ermöglicht.
Die genannte Aufgabe wird erfindungsgemäss gelöst durch die Merkmale des Anspruchs 1 oder 2.
Nachfolgend wird ein Ausführungsbeispiel der Erfindung anhand der Zeichnung näher erläutert.
Die einzige Figur zeigt eine Schaltungsanordnung, die einen Impulsgeber 1, einen Mikrocontroller 2 mit wenigstens drei schaltbaren Ausgängen 3, 4, 5 und einem Eingang 6 mit einem Schmitt-Trigger Verhalten, sowie drei Widerstände 7, 8, 9 umfasst. Der Impulsgeber 1 weist einen Kontakt 10, beispielsweise einen Reedkontakt, auf, zu dem in Reihe und parallel je ein Widerstand 11 bzw. 12 geschaltet ist. Der Impulsgeber 1 ist somit ein Reedkontakt mit sogenannter Namur-Beschaltung. Der Kontakt 10 kann auch ein open Collector oder ein open Drain usw. sein. Der Impulsgeber 1 weist wie ein gewöhnlicher Widerstand zwei Anschlüsse 13 und 14 auf. Der Ausgangswiderstand des Impulsgebers 1, d.h. der Widerstand zwischen den Anschlüssen 13 und 14, beträgt beispielsweise 7,5 k OMEGA , wenn der Kontakt 10 offen ist, und 2,2 k OMEGA , wenn der Kontakt 10 geschlossen ist.
Durch Messung des Widerstandes zwischen den Anschlüssen 13 und 14 kann deshalb die Stellung des Kontaktes 10 bestimmt werden.
Die Ausgänge 3, 4 und 5 des Mikrocontrollers 2 sind über den zugeordneten Widerstand 7, 8 bzw. 9 und eine Abfrageleitung 15 mit dem einen Anschluss 13 des Impulsgebers 1 verbunden, während der zweite Anschluss 14 des Impulsgebers 1 mit Masse m verbunden ist. Der Anschluss 13 des Impulsgebers 1 ist zudem mit dem Eingang 6 des Mikrocontrollers 2 verbunden. Jeder der Ausgänge 3, 4 und 5 des Mikrocontrollers 2 ist entweder hochohmig schaltbar, mit Masse m oder mit einer vorgegebenen Spannung U, beispielsweise der Betriebsspannung des Mikrocontrollers 2, verbindbar.
Sobald einer der Ausgänge 3, 4 oder 5 die Spannung U führt, fliesst ein Strom über den zugeordneten Widerstand 7, 8 bzw. 9, über die Abfrageleitung 15 vom Mikrocontroller 2 zum Impulsgeber 1, durch den Impulsgeber 1 und zur Masse m, wobei sich die Spannung V am Eingang 6 entsprechend den vom Strom durchflossenen Widerständen einstellt.
Die Schaltungsanordnung arbeitet wie folgt: Bei beispielsweise 16 durchzuführenden Abfragen des Impulsgebers 1 pro Sekunde, führt der Mikrocontroller 2 in zeitlichen Abständen von etwa 60 Millisekunden jeweils eine Abfrage durch. Eine solche Abfrage dauert etwa 30 Mikrosekunden. Zwischen den Abfragen sind alle Ausgänge 3, 4 und 5 mit Masse m verbunden: Es fliesst kein Strom durch den Impulsgeber 1 und der Eingang 6 des Mikrocontrollers 2 ist geerdet und somit vor elektromagnetischen Störeinflüssen geschützt. Zur Durchführung einer Abfrage führt der Mikrocontroller 2 folgende Abfrageschritte durch:
1. Alle Ausgänge 3, 4 und 5 hochohmig legen.
2. Den Ausgang 3 an die Spannung U legen, die Spannung V am Eingang 6 als binäres Signal S1 "0" oder "1" entsprechend einer unterhalb oder oberhalb der Triggerschwelle liegenden Spannung erfassen und den Ausgang 3 wieder hochohmig legen. Das Resultat S1 = "0" bedeutet, dass ein Kurzschluss in der Abfrageleitung 15 vorliegt.
3. Den Ausgang 4 an die Spannung U legen, die Spannung V am Eingang 6 als binäres Signal S2 "0" oder "1" entsprechend einer unterhalb oder oberhalb der Triggerschwelle liegenden Spannung erfassen und den Ausgang 4 wieder hochohmig legen. Das Resultat S2 = "1" bedeutet, dass ein Unterbruch in der Abfrageleitung 15 vorliegt.
4. Den Ausgang 5 an die Spannung U legen, die Spannung V am Eingang 6 als binäres Signal S3 "0" oder "1" entsprechend einer unterhalb oder oberhalb der Triggerschwelle liegenden Spannung erfassen und den Ausgang 5 wieder hochohmig legen. Das Resultat S3 = "0" bedeutet, dass der Kontakt 10 geschlossen ist, das Resultat S3 = "1" bedeutet, dass der Kontakt 10 offen ist.
5. Alle Ausgänge 3, 4 und 5 wieder an Masse m legen.
Falls nach dem Verfahrensschritt 2 oder 3 erkannt ist, dass ein Kurzschluss bzw. ein Unterbruch vorliegt, bricht der Mikrocontroller 2 das Verfahren vorteilhafterweise ab, da dann die Stellung des Kontaktes 10 nicht mehr messbar ist.
Die Triggerschwelle des Einganges 6 liegt typisch bei der halben Betriebsspannung, mit der der Mikrocontroller 2 gespeist ist. Damit die binären Signale S1, S2 und S3 gemäss der oben angegebenen Interpretation erzeugt werden, müssen die Werte der drei Widerstände 7, 8 und 9 entsprechend an die Werte der Widerstände 11 und 12 im Impulsgeber 1 angepasst sein. Der erste Widerstand 7 ist so bemessen, dass bei intakter Abfrageleitung 15 zum Impulsgeber 1 unabhängig von der Stellung des Kontakts 10 am Eingang 6 des Mikrocontrollers 2 eine über der Triggerschwelle liegende Spannung V und somit ein binäres Signal "1" resultiert. Bei einem Kurzschluss liegt der Eingang 6 nämlich auf Masse m, was ein binäres Signal "0" erzeugt.
Der zweite Widerstand 8 ist so bemessen, dass bei intakter Abfrageleitung 15 unabhängig von der Stellung des Kontakts 10 am Eingang 6 des Mikrocontrollers 2 eine unter der Triggerschwelle liegende Spannung V und somit ein binäres Signal "0" resultiert. Bei einem Unterbruch kann kein Strom fliessen, sodass am Eingang 6 die Spannung V = U anliegt, was ein binäres Signal "1" erzeugt.
Der dritte Widerstand 9 ist so bemessen, dass bei intakter Abfrageleitung 15 am Eingang 6 des Mikrocontrollers 2 eine unter der Triggerschwelle liegende Spannung V und somit ein binäres Signal "0" resultiert, wenn der Kontakt 10 geschlossen ist, und dass eine über der Triggerschwelle liegende Spannung und somit ein binäres Signal "1" resultiert, wenn der Kontakt 10 offen ist.
Es ist auch möglich, nur zwei Widerstände 7 und 8 vorzusehen, und den Widerstand 9 durch die Parallelschaltung der Widerstände 7 und 8 zu ersetzen.
Die Triggerschwelle des Eingangs 6 des Mikrocontrollers 2 unterliegt von Exemplar zu Exemplar relativ grossen Schwankungen. Bei der Produktion der Schaltungsanordnung ist es erwünscht, Widerstände 7, 8 und 9 mit fest vorgegebenen Werten verwenden zu können. Um Schwankungen der Triggerschwelle dennoch ausgleichen zu können, ist gemäss einer Weiterentwicklung der Erfindung vorgesehen, dass der Verfahrensschritt 4 derart modifiziert ist, dass entsprechend der aktuellen Triggerschwelle zusätzlich der Ausgang 3 und/oder 4 an Masse m oder an Spannung U gelegt wird, sodass sich das Potenzial auf der Abfrageleitung 15 so verschiebt, dass bei intakter Abfrageleitung 15 am Eingang 6 des Mikrocontrollers 2 eine unter der Triggerschwelle liegende Spannung V resultiert, wenn der Kontakt 10 geschlossen ist, und dass eine über der Triggerschwelle liegende Spannung resultiert,
wenn der Kontakt 10 offen ist.
Bei der Produktion der Schaltungsanordnung wird deshalb ein softwaregesteuerter Test durchgeführt, um zu ermitteln, ob beim Verfahrensschritt 4 zusätzlich der Ausgang 3 und/oder 4 an Masse m oder an Spannung U gelegt werden muss. Das Resultat dieses Tests wird im Mikrocontroller 2 gespeichert.
Der Vollständigkeit halber sei hier noch festgehalten, dass es grundsätzlich möglich ist, bei jedem der Verfahrensschritte 2-4 jeden der Ausgänge 3-5 hochohmig, an Masse m oder an Spannung U zu legen. Mit anderen Worten gesagt, es kann bei jedem der Verfahrensschritte 2-4 eine andere Kombination der Widerstände 7-9 zugeschaltet werden, wobei jeder zugeschaltete Widerstand entweder an Masse m oder an Spannung U gelegt wird.
The invention relates to a circuit arrangement for querying the contact of a pulse generator of the type mentioned in the preamble of claim 1 or 2.
Incremental pulse generators are used, for example, in mechanical counters to electronically record the rotation of the counting wheel that displays the last digit. For example, a reed contact is closed as long as the number 0 is visible. With a normal reed contact, only the two states "contact open" or "contact closed" can be detected. In the case of a pulse generator which has a reed contact with Namur circuitry, on the other hand, it is possible to detect two further states, namely "short circuit" or "interruption" of the circuit leading to the pulse generator. For this purpose, known circuits use operational amplifiers used as comparison elements in order to detect whether the measured output resistance of the pulse generator lies within a predetermined window.
The invention is based on the object of proposing a circuit arrangement which enables a pulse generator to be queried in a simple manner by means of a microcontroller.
According to the invention, this object is achieved by the features of claim 1 or 2.
An exemplary embodiment of the invention is explained in more detail below with reference to the drawing.
The single figure shows a circuit arrangement which comprises a pulse generator 1, a microcontroller 2 with at least three switchable outputs 3, 4, 5 and an input 6 with a Schmitt trigger behavior, and three resistors 7, 8, 9. The pulse generator 1 has a contact 10, for example a reed contact, to which a resistor 11 or 12 is connected in series and in parallel. The pulse generator 1 is thus a reed contact with a so-called Namur circuit. The contact 10 can also be an open collector or an open drain, etc. The pulse generator 1 has two connections 13 and 14 like an ordinary resistor. The output resistance of pulse generator 1, i.e. the resistance between the terminals 13 and 14 is, for example, 7.5 k OMEGA when the contact 10 is open and 2.2 k OMEGA when the contact 10 is closed.
The position of the contact 10 can therefore be determined by measuring the resistance between the connections 13 and 14.
The outputs 3, 4 and 5 of the microcontroller 2 are connected via the assigned resistor 7, 8 and 9 and a query line 15 to the one connection 13 of the pulse generator 1, while the second connection 14 of the pulse generator 1 is connected to ground m. The connection 13 of the pulse generator 1 is also connected to the input 6 of the microcontroller 2. Each of the outputs 3, 4 and 5 of the microcontroller 2 can either be switched with high resistance, with ground m or with a predetermined voltage U, for example the operating voltage of the microcontroller 2.
As soon as one of the outputs 3, 4 or 5 carries the voltage U, a current flows through the associated resistor 7, 8 or 9, via the interrogation line 15 from the microcontroller 2 to the pulse generator 1, through the pulse generator 1 and to ground m, whereby sets the voltage V at the input 6 in accordance with the resistances through which the current flows.
The circuit arrangement works as follows: With, for example, 16 queries of the pulse generator 1 to be carried out per second, the microcontroller 2 carries out one query at intervals of approximately 60 milliseconds. Such a query takes about 30 microseconds. Between the queries, all outputs 3, 4 and 5 are connected to ground m: No current flows through the pulse generator 1 and the input 6 of the microcontroller 2 is grounded and thus protected from electromagnetic interference. To carry out a query, the microcontroller 2 carries out the following query steps:
1. Set all outputs 3, 4 and 5 with high resistance.
2. Connect output 3 to voltage U, detect voltage V at input 6 as a binary signal S1 "0" or "1" corresponding to a voltage below or above the trigger threshold, and connect output 3 again with high impedance. The result S1 = "0" means that there is a short circuit in the query line 15.
3. Connect output 4 to voltage U, detect voltage V at input 6 as binary signal S2 "0" or "1" corresponding to a voltage below or above the trigger threshold and connect output 4 again with high impedance. The result S2 = "1" means that there is an interruption in the query line 15.
4. Connect output 5 to voltage U, detect voltage V at input 6 as binary signal S3 "0" or "1" corresponding to a voltage below or above the trigger threshold and connect output 5 again with high impedance. The result S3 = "0" means that the contact 10 is closed, the result S3 = "1" means that the contact 10 is open.
5. Connect all outputs 3, 4 and 5 to ground m again.
If it is recognized after method step 2 or 3 that there is a short circuit or an interruption, the microcontroller 2 advantageously terminates the method since the position of the contact 10 can then no longer be measured.
The trigger threshold of the input 6 is typically half the operating voltage with which the microcontroller 2 is supplied. In order for the binary signals S1, S2 and S3 to be generated according to the interpretation given above, the values of the three resistors 7, 8 and 9 must be adapted accordingly to the values of the resistors 11 and 12 in the pulse generator 1. The first resistor 7 is dimensioned such that when the interrogation line 15 to the pulse generator 1 is intact, regardless of the position of the contact 10 at the input 6 of the microcontroller 2, a voltage V above the trigger threshold and thus a binary signal "1" result. In the event of a short circuit, input 6 is at ground m, which generates a binary signal "0".
The second resistor 8 is dimensioned such that if the interrogation line 15 is intact, regardless of the position of the contact 10 at the input 6 of the microcontroller 2, a voltage V below the trigger threshold and thus a binary signal “0” result. In the event of an interruption, no current can flow, so that the voltage V = U is present at input 6, which generates a binary signal "1".
The third resistor 9 is dimensioned such that when the interrogation line 15 is intact at the input 6 of the microcontroller 2, a voltage V below the trigger threshold and thus a binary signal “0” results when the contact 10 is closed, and that one above the trigger threshold Voltage and thus a binary signal "1" results when the contact 10 is open.
It is also possible to provide only two resistors 7 and 8 and to replace the resistor 9 by connecting the resistors 7 and 8 in parallel.
The trigger threshold of the input 6 of the microcontroller 2 is subject to relatively large fluctuations from copy to copy. In the production of the circuit arrangement, it is desirable to be able to use resistors 7, 8 and 9 with fixed values. In order to be able to compensate for fluctuations in the trigger threshold, it is provided according to a further development of the invention that method step 4 is modified such that output 3 and / or 4 is additionally connected to ground m or to voltage U in accordance with the current trigger threshold, so that shifts the potential on the interrogation line 15 such that when the interrogation line 15 is intact at the input 6 of the microcontroller 2, a voltage V below the trigger threshold results when the contact 10 is closed and that a voltage above the trigger threshold results,
when contact 10 is open.
During the production of the circuit arrangement, a software-controlled test is therefore carried out in order to determine whether output 3 and / or 4 must additionally be connected to ground m or to voltage U in method step 4. The result of this test is stored in the microcontroller 2.
For the sake of completeness, it should be noted here that it is fundamentally possible to connect each of the outputs 3-5 with high resistance, to ground m or to voltage U in each of the process steps 2-4. In other words, a different combination of resistors 7-9 can be connected in each of method steps 2-4, each connected resistor being connected either to ground m or to voltage U.