CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Electronics > PIC Programing / Design


PIC Programing / Design Discuss programing of PIC chips here and design of electronics using PIC chips.


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 07-25-2007, 08:01 AM
 
Join Date: Feb 2005
Location: Sweden
Posts: 32
per.e is on a distinguished road
Anybody build a pendant/control panel with a PIC ?

Hello everybody.
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.
Per
Tweet this Post!Share on Facebook
Reply With Quote

  #2   Ban this user!
Old 05-10-2009, 10:27 PM
 
Join Date: Apr 2009
Location: Mexico
Posts: 15
kostix777 is on a distinguished road
Hello!

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.

Best regards,
Konstantin
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
RFQ - Small Aluminum Control Panel grmnfox Employment Opportunity 7 01-21-2007 08:54 PM
V2XT Control Panel Updates NEATman Bridgeport and Hardinge Mills 0 10-06-2006 12:32 AM
My DIY control panel DennisCNC CNCzone Club House 6 10-02-2006 11:24 PM
Professional Control Panel Lables Karl_T General Metalwork Discussion 13 11-13-2005 05:28 PM
Building my control panel ChrisJ General Electronics Discussion 0 03-02-2005 09:09 PM




All times are GMT -5. The time now is 03:57 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353