MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Running_avrdude_from_eclipse_under_linux",
        "continue": "gapcontinue||"
    },
    "warnings": {
        "main": {
            "*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
        },
        "revisions": {
            "*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."
        }
    },
    "query": {
        "pages": {
            "27": {
                "pageid": 27,
                "ns": 0,
                "title": "Reading Rotary Encoders",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "Many [[wikipedia:rotary encoder|rotary encoders]] work in quadrature mode. This means that their signals will look somewhat like what is shown on the right[[Image:Quadrature encoder.png|thumb|300px|typical quadrature signal]]. Note that the ones you turn by hand normally have one noticable 'click' for every full cycle (phases 1-4 in the image). Whether the pins are low-active, or high-active and which pin is which is normally not important, though it does influence which direction is considered 'up' and which is 'down'.\n==AVR code==\nThe following code runs in a timer interrupt. Most timer frequencies will do, as long as it's fast enough to see all states in the interrupt. Of course, you can also use a pin change interrupt if you want to be sure. The code assumes a <code>read</code> function that reads the state of the two encoder output pins and puts them in the bottom two bits of the return value. Any two adjacent bits will do if the constant <code>0x02</code> is adapted. Do take care that <code>timer.state</code> in this example counts up or down for ''every state change'', which means that the counter is increased four times for every click. \n\n<syntaxhighlight lang=\"cpp\">\n/// Timer interrupt\nISR( TIMER1_COMPA_vect)\n{\n\t// previously seen value of encoder bits.\n\tstatic uint8_t previous = 0;\n\n\t// get the encoder state \n\tuint8_t current = read(encoder); // this reads the A and B line values in the lower 2 bits.\n\tif (current != previous)\n\t{\n\t\t// there's a change, decide whether we count up or down.\n\t\tif ((previous ^ (current << 1)) & 0x02)\n\t\t{\n\t\t\t--timer_state.value;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t++timer_state.value;\n\t\t}\n\t\ttimer_state.value_changed = 1;\n\n\t\t//timer_state.value = current;\n\t\tprevious = current;\n\t}\n\n}\n</syntaxhighlight>\n\nThe code works by comparing line A at time ''t'' with line B at time ''t-1''. Looking at the drawing above, you can see that when we move to the right in this diagram, the state of line A seems to follow that of line B, which means that ''A(t) == B(t-1)'' if the encoder moves to the right. Conversely, if the encoder moves to the left ''A(t)'' will always be the opposite of ''B(t-1)''. An exclusive OR of ''A(t)'' and ''B(t-1)'' is used to compare the two values.\n\n==SX code==\nThe following SX28 assembly contains two virtual pheripherals: \n* Reading a rotary encoder\n* driving 4 7-segment led displays\nReading the encoder starts at label <code>ReadEncoder</code>.\n[[Image:4x7segments 003.jpg|none]]\n\nThe main program just loops and does nothing. The first vp communicates directly with the second.\nThis code is an adapted version (made into a vp) of sources found on [http://sxlist.com sxlist].\n<syntaxhighlight lang=\"asm\">\n ;=======================================================================\n \n ;TITLE:         4x7segments.src\n ;\n ;PURPOSE:       Read pulses from a rotary encoder, adapt a counter\n ;\t\t\tand output to 4 7-segment led displays\n ;\n ;AUTHOR:        Danny Havenith\n ;\n ;REVISIONS:\n ;  <mm/dd/yy> - <details of revision>\n ;               <more details of same revision>\n ;\n ;CONNECTIONS:\n ;\tra.0 and ra.1: encoder inputs\n ;\trc: led segment outputs\n ;\trb.0-4: led column outputs\n ;\n ;=======================================================================\n \n \n ;-------------------------- DEVICE DIRECTIVES --------------------------\n \n \t\tDEVICE\t\tSX28,OSC4MHZ,TURBO\n \t\tDEVICE\t\tSTACKX, OPTIONX\n \t\tIRC_CAL\t\tIRC_SLOW\n \n \t\tRESET\t\tInitialize\n \n ;------------------------------ CONSTANTS ------------------------------\n \n TicksPerMs\tEQU\t20\t; interrupts per ms\n CyclesPerTick\tEQU\t200\t; cycles per interrupt\n \n \n ------------------------------ VARIABLES ------------------------------\n \t\t\tORG\t$10\n \n BankLeds\t= $\n \n MSTimer\t\tDS\t1\n CurrentDigit\tDS\t1\n CurrentColumn\tDS\t1\n Digits\t\tDS\t4\n \n CounterA\tDS\t1\n CounterB\tDS\t1\n CounterC\tDS\t1\n \n BankEncoder\t= $\n EncoderState\tDS \t1\n temp\t\tDS\t1\n \n \n ColumnPort\tEQU \trb\n RowPort\t\tEQU\trc\n \n EncoderPort\tEQU\tra \t; port for the rotary encoder\n EncoderMask\tEQU\t$03\t; which bits to use.\n \n ;---------------------------- DEBUG SETTINGS ---------------------------\n \n \t\tFREQ\t4_000_000\n \t\n ;\t\tWATCH\t<Symbol>,<bit count>,<format>\n \n WKED_W\t\tequ\t$0A\t\t;Write MIWU/RB Interrupt edge setup, 0 = falling, 1 = rising\n WKEN_W\t\tequ\t$0B\t\t;Write MIWU/RB Interrupt edge setup, 0 = enabled, 1 = disabled\n ST_W\t\tequ\t$0C\t\t;Write Port Schmitt Trigger setup, 0 = enabled, 1 = disabled\n LVL_W\t\tequ\t$0D\t\t;Write Port Schmitt Trigger setup, 0 = enabled, 1 = disabled\n PLP_W\t\tequ\t$0E\t\t;Write Port Schmitt Trigger setup, 0 = enabled, 1 = disabled\n DDIR_W\t\tequ\t$0F\t\t;Write Port Direction\n \n RA_latch\tequ\t%00000000\t\t;SX18/20/28/48/52 port A latch init\n RA_DDIR\t\tequ\t%11111111\t\t;see under pin definitions for port A DDIR value\n RA_LVL\t\tequ\t%00000000\t\t;SX18/20/28/48/52 port A LVL value\n RA_PLP\t\tequ\t%11111111\t\t;SX18/20/28/48/52 port A PLP value\n \n RB_latch\tequ\t%00000000\t\t;SX18/20/28/48/52 port B latch init\n RB_DDIR\t\tequ\t%11110000\t\t;SX18/20/28/48/52 port B DDIR value\n RB_ST\t\tequ\t%11111111\t\t;SX18/20/28/48/52 port B ST value\n RB_LVL\t\tequ\t%00000000\t\t;SX18/20/28/48/52 port B LVL value\n RB_PLP\t\tequ\t%11111111\t\t;SX18/20/28/48/52 port B PLP value\n \n RC_latch\tequ\t%00000000\t\t;SX18/20/28/48/52 port C latch init\n RC_DDIR\t\tequ\t%00000000\t\t;SX18/20/28/48/52 port C DDIR value\n RC_ST\t\tequ\t%11111111\t\t;SX18/20/28/48/52 port C ST value\n RC_LVL\t\tequ\t%00000000\t\t;SX18/20/28/48/52 port C LVL value\n RC_PLP\t\tequ\t%11111111\t\t;SX18/20/28/48/52 port C PLP value\n \n ;-------------------------- INTERRUPT ROUTINE --------------------------\n \t\tORG\t$0\n \t\t\n ;\tbreak Interrupt\n Interrupt\n ; timer\n \tbank BankLeds\n \tmov w, #TicksPerMs\n \tdec MSTimer\n \tsnz\n \tmov MSTimer, w\n \tsz\n \tjmp EndInterrupt\n \n \tmov w, #Digits\n \tadd w, CurrentDigit\n \tmov fsr, w\n \tmov w, IND\n \tcall Decode\n \tclr ColumnPort\n \tmov RowPort, w\n \tmov ColumnPort, CurrentColumn\n \n \t; next column\n \tclc\n \trr CurrentColumn\t; rotate column left\n \tmov w, #%00001000\n \tinc CurrentDigit\t\t; increase digit counter\n \tsnc \t\t; reset if digit = 4\n \tmov CurrentColumn, w\n \tsnc \n \tclr CurrentDigit\n \n :EndLeds\n \n \tbreak ReadEncoder\n ReadEncoder\n         mov w, EncoderPort           ;get change between current and previous \n                             ;encoder state in w\n         xor w, EncoderState    ;\n         \n         xor EncoderState, w    ;update state and preserve difference in w\n \n         and w, #EncoderMask         ;check if there is change\n         snz\n          jmp :EndEncoder       ;no change, read encoder again\n \n         ;if both bits changed, this will be an error, but we ignore it here\n         ;xor w, #$03\n         ;skpnz\n         ; jmp enc_error\n \n         ;calculate direction in temp.1\n         mov temp, w       \n         mov w, <<EncoderState\n         xor w, EncoderState\n         xor temp, w\n \n         sb temp.1\n          call EncoderIncrease       ;Encoder moved up\n         snb temp.1\n          call EncoderDecrease       ;Encoder moved down\n \n :EndEncoder\n \n EndInterrupt\n \tmov w, #-CyclesPerTick\t\t\n \tretiw\n \n EncoderIncrease\n \tinc\tDigits + 3\n \tcjne\tDigits + 3, #10, :EndInc\n \tclr \tDigits + 3\n \n \tinc\tDigits + 2\n \tcjne\tDigits + 2, #10, :EndInc\n \tclr \tDigits + 2\n \n \tinc\tDigits + 1\n \tcjne\tDigits + 1, #10, :EndInc\n \tclr \tDigits + 1\n \n \tinc\tDigits \n \tcjne\tDigits, #10, :EndInc\n \tclr \tDigits\n :EndInc\n \tretp\n \n EncoderDecrease\n \tdec\tDigits + 3\n \tcjne\tDigits + 3, #$FF, :EndDec\n \tmov\tDigits + 3, #09\n \n \tdec\tDigits + 2\n \tcjne\tDigits + 2, #$FF, :EndDec\n \tmov\tDigits + 2, #09\n \n \tdec\tDigits + 1\n \tcjne\tDigits + 1, #$FF, :EndDec\n \tmov\tDigits + 1, #09\n \n \tdec\tDigits\n \tcjne\tDigits, #$FF, :EndDec\n \tmov\tDigits, #09\n :EndDec\t\t\n \tretp\n \n Decode\n \tand w, #$0F\n \tjmp PC+w\n \tretw %00000101 ;0\n \tretw %11011101 ;1\n \tretw %10000110 ;2\n \tretw %10010100 ;3\n \tretw %01011100 ;4\n \tretw %00110100 ;5\n \tretw %00100100 ;6\n \tretw %10011101 ;7\n \tretw %00000100 ;8\n \tretw %00010100 ;9\n \tretw %00001100 ;A\n \tretw %01100100 ;b\n \tretw %00100111 ;C\n \tretw %11000100 ;d\n \tretw %00100110 ;E\n \tretw %00101110 ;F\n \n ;------------------------ INITIALIZATION ROUTINE -----------------------\n \n Initialize\n \t\t; Configure all ports\n \t\tmov \tm, #ST_W\t\t\t;point MODE to write ST register\n \t\tmov     w,#RB_ST            \t;Setup RB Schmitt Trigger, 0 = enabled, 1 = disabled\n \t\tmov\t!rb,w\t\t\n \t\tmov     w,#RC_ST            \t;Setup RC Schmitt Trigger, 0 = enabled, 1 = disabled\n \t\tmov\t!rc,w\t\n \t\tmov \tm, LVL_W\t\t\t;point MODE to write LVL register\n \t\tmov     w,#RA_LVL            \t;Setup RA CMOS or TTL levels, 0 = TTL, 1 = CMOS\n \t\tmov\t!ra,w\t\t \n \t\tmov     w,#RB_LVL            \t;Setup RB CMOS or TTL levels, 0 = TTL, 1 = CMOS\n \t\tmov\t!rb,w\t\t\n \t\tmov     w,#RC_LVL            \t;Setup RC CMOS or TTL levels, 0 = TTL, 1 = CMOS\n \t\tmov\t!rc,w\t\n \n \t\tmov \tw,#RA_PLP            \t;Setup RA Weak Pull-up, 0 = enabled, 1 = disabled\n \t\tmov\t!ra,w\t\t \n \t\tmov     w,#RB_PLP            \t;Setup RB Weak Pull-up, 0 = enabled, 1 = disabled\n \t\tmov\t!rb,w\t\t\n \t\tmov     w,#RC_PLP            \t;Setup RC Weak Pull-up, 0 = enabled, 1 = disabled\n \t\tmov\t!rc,w\t\n \n \t\tmov \tm, #DDIR_W\t\t\t;point MODE to write DDIR register\n \t\tmov\tw,#RA_DDIR\t\t;Setup RA Direction register, 0 = output, 1 = input\t\t\n \t\tmov\t!ra,w\t\n \t\tmov\tw,#RB_DDIR\t\t;Setup RB Direction register, 0 = output, 1 = input\n \t\tmov\t!rb,w\t\t\t\n \t\tmov\tw,#RC_DDIR\t\t;Setup RC Direction register, 0 = output, 1 = input\n \t\tmov\t!rc,w\t\t\t\n \n \t\tmov     w,#RA_latch          \t;Initialize RA data latch\n \t\tmov     ra,w\t\t\n \t\tmov     w,#RB_latch         \t;Initialize RB data latch\n \t\tmov     rb,w\t\t\n \t\tmov     w,#RC_latch          \t;Initialize RC data latch\n \t\tmov     rc,w\t\t\n \n ; zero all ram (SX28)\n \t\tclr\tfsr\t\t\t;reset all ram banks\n :zero_ram\tsb\tfsr.4\t\t\t;are we on low half of bank?\n \t\tsetb\tfsr.3\t\t\t;If so, don't touch regs 0-7\n \t\tclr\tind\t\t\t;clear using indirect addressing\n \t\tincsz\tfsr\t\t\t;repeat until done\n \t\tjmp\t:zero_ram\n \n :init_leds\tbank BankLeds\n \t\tmov CurrentDigit, #0\n \t\tmov CurrentColumn, #1\n \n ;---------------------------- MAIN PROGRAM -----------------------------\n \n Main\n \n \tmov Digits, #1\n \tmov Digits + 1, #2\n \tmov Digits + 2, #3\n \tmov Digits + 3, #4\n \tmov\t!option, #%10011111\t;enable rtcc interrupt\n \n :loop\t\n  \tjmp :loop\n \n \n \n \n \t\n ;----------------------------- SUBROUTINES -----------------------------\n \n ;<GlobalLabel>\n ;<detailed description of routine>\n \n ;\t\t<inst>\t<op1>,<op2>\t\t;<time>\t<comment>\n</syntaxhighlight>\n[[Category:SX]]\n[[Category:AVR]]"
                    }
                ]
            },
            "90": {
                "pageid": 90,
                "ns": 0,
                "title": "Roland FD-8 Issues: Hall Sensor Modification",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "This page describes one of two solutions to common issues with the Roland FD-8 hi-hat pedal. Both solutions replace the film resistor with a Hall effect sensor. This solution uses discrete components and you may find it easier to construct. A low-cost microcontroller-based version is described [[Digital FD-8 pedal|on this page]].\n\nBoth editors of the Justintime pages have a Roland TD-3 electronic drum kit. This kit plays quite nicely, but after some years the responsiveness of the Hi-hat pedal seems to worsen. We are not the only ones who have noticed this; google for 'roland fd-8 issues' to find widespread complaints and hacks/solutions people have come up with. Most solutions have to do with adjusting the mechanical pressure on the variable film resistor in the pedal. \n\nHowever, I wanted to completely get rid of the film resistor and replace it with an electronic alternative that has no contact issues AND had the possibility to adjust the half-open range to personal taste. The obvious choice for the detection was a (linear) Hall Sensor, but this would have to be translated to a variable resistor for the TD-3. The first design thoughts were MCU based with an ADC and programmable variable resistor, but after some more (clever) thinking it became clear that a circuit with two comparators and two analog switches would work just as well and might be a lot simpler. Another important consideration is that it might be easier for the average FD-8 owner (other than the two of us) to recreate.\n\nAlthough the film resistor is very variable, the TD-3 hi-hat recognizes three positions from the resistor: \n* closed (short, 0R to 5K)\n* half (5K to 15K)\n* closed (15K and up)\n\n==Electronics==\nFinding a linear Hall Sensor can be hard. Pay attention: most Hall Sensors are on/off type and have hysteresis circuit inside. These can not be used, because we have to detect at least two switching points. I used a Honeywell SS490, but I suspect any Linear (Ratiometric) Hall Sensor should do. Also be aware that the sensor is polarity-sensitive; the circuit is designed for voltage increase when the magnet draws near (4.5 - 8.5V), but if you flip the magnet the voltage will decrease!!\n\nFor powering the circuit we branch off the TD-3 power supply. Be careful: the Roland power supply states 9V output, but it outputs about 11.5V. Since my Hall Sensor max was 10.5V, a regulator was necessary. 9V seemed a good pick. Using a small Neodymium magnet the sensor had a working range of 4.5V to 8.5V. I used a plastic Lego brick because it was available and about the right size, and most of all because it was sturdy plastic. After starting of with a metal construction, this was abandoned because I was worried the metal would interfere with the magnetic field and influence the sensor readings, so plastic seemed a better pick.\n\nBy making the comparator inputs adjustable with potmeters, the sensitivity range of the FD-8 half and closed settings can be made very flexible. The circuit is not very complex, so it could very well be made on veroboard or stripboard. I have made a SMT PCB myself, because I prefer working in SMT. Check out the [[Hall-High-Hat-Hack-Schematic|schematic]], [[PCB Layout]] and [[Media:HallHighHat Eagle Files.7z |Eagle Files]]. \n\nThe prototype circuit works very well and makes the Hi-Hat a lot easier to play e.g. provides a much more reliable closing action. The only 'downside' of the circuit is that the foot-sound is always on full volume. I suspect that this can be adjusted by increasing the 0R value, but this has yet to be tested.\n\n==Construction==\nBelow are some pics. These pictures were made before the  DC connectors had arrived. These 2.1mm DC Power plugs are intended to make use of the original TD3 power supply; the pedal will feature 2 parallel plugs, one for power supply input and the TD-3 module can be connected to the other power plug via a cable.\n\nBelow are some pics of the not-yet-finished build. Mechanically, this is exactly the same as in the [[Digital FD-8 pedal|microcontroller-based concept]].\n\n[[File:Hall Sensor and Strip.JPG]]\n\nThe Magnet sticks to the metal by magnetism, but is also glued with superglue to avoid shift. The Hall Sensor and Lego brick are set using doublesided tape and [[secured by a tie-wrap]]. Also visible is the original variable film-resistor. This is left intact, so it is always possible to return to using the original mechanical film-resistor mechanism. The output of the hall-sensor-resistor-circuit is routed to a new jack output on the other side of the pedal, as can be seen on this picture, since the original output is on the left side.\n\n[[File:External Pots.JPG]]\n\nThe external pots are for adjusting the sensitivity of the closed and half-open state. If you do not intend to tweak trimpots would do fine too.\n\n[[File:Internal Wiring.JPG]]\n\nThe Hall Sensor is connected by a pin header connector, so it is easier to take the pedal apart. Fortunately there is enough spare room in the pedal for the circuitry.\n\n[[File:FD8 with Knobs.JPG]]\n\nDisclaimer: Use this info at your own risk. We take no responsibility for any damaged equipment!\n\n==Comments? Questions?==\n{{ShowComments|show=True}}"
                    }
                ]
            }
        }
    }
}