I am building a pendant/control panel and i want to use a PIC processor to talk with Mach3 and keygrabber.
My MPGs is connected to the parallelport and i want all of the other knobs from the panel go thru the PIC.
Has anybody done this and do you have some code in ASM (Assembler) for the PIC.
I suppose that you want to add physical buttons and knobs to your control panel. That should as be straight forward as connecting any switches to a microcontroller, and then reading them in the code.
I am not a big expert in assembler programming of PICs, but i have done some C programming for them, with a bit of inline assembler.
There is quite a bit of tutorials about PIC programming either in C or assembler, so a simple google search would provide you with many examples.
Now a little bit about inputs on microcontrollers..
Usually when connecting switches to a microcontroller, you will want to "pull up" the pin thru a resistor to the VCC 5v (so that its never left unconnected to anything, floating), this part is simply done by selecting some higher value resistor (something between 10k and 47k), and connecting it between the input pin you wish to use, and the VCC. Then you connect one pin of your switch/button to the microcontroller pin (where the resistor is), and the other pin of the switch to the ground. This way, normally when the switch is not pressed, the input stays at 5v (through the current limiting resistor), now if you press the button, you are literally grounding that pin. Notice that the use of the resistor on the pin, avoids shorting the VCC to ground directly, instead, when the button is pressed there will be a small current flowing from the VCC to GND thru the resistor ( current = voltage / resistance or I = V / R), aswell as your input will be grounded through your switch. All this is just the hardware part.
Now, in the software part, you will want to configure your PIC pin as a digital input (notice that some pins on certain PICs are shared with other peripherals, so you need to make sure that they are disabled to get proper performance). Setting a pin as input is usually done by setting to "1" the bit corresponding to your pin, in the TRIS register of the port on which the pin is.
After this, you will want to set that pin to 1, so that 5v are present on the pin terminal (done by setting appropriate bit in the PORT register).
After this you just poll the pin in code (read the pin's state in the code) or if you use some pins which have "interrupt on change" feature, it could be implemented more efficiently.
So normally, when your switch is not pressed, you read the pin state, and it will be a "1" ... now if you press the switch/button and read the pin, it will be read as "0".
Of course there are numerous ways of connecting switches to a microcontroller, this being only one of them usually usefull if you have spare free pins to use on the microcontroller.
In the case that you needed to connect several switches and dont have enough pins left for input, you would have to use some sort of parallel to serial shift register IC's, to which you could connect, say 8 switches (in the case of the shift register being 8bit), and then serially input the data into the microcontroller. But this is another topic.
If you wanted to connect also rotary knobs, you have 2 basic options (maybe more): potentiometers or rotary encoders.
For using a potentiometer you would have to connect it to a port of the PIC which has the analog to digital converter device, then you read the analog voltage that is present on the pin. The rotary encoders, on the other hand, are basically simple switches, which you would connect using same method as explained above, and the rest of decoding of the encoder rotation would be done in software.