View Full Version : How do I program a pic to accept inputs?
timbear3
- 25th November 2012, 16:16
I am planning of using a 16F88 to control my future 3D printer I am working on. This is a projection type of 3d printer and it's controlled by a pic that in general the Arduino is used. I want to use the pics I am learning now (16Fxxx) and I have no idea of how to communicate with it after the pic is programmed and soldered on board. In other words, every object to be printed varies the projection time, the thickness of the cut and some other parameters that needs to be input before the pic takes control of that printing. What I really need is an example program that leads me of how to do those inputs before every printing take place. I am sure that someone of you has tried it before. Please help me learn about it. Thanks.
electromark
- 26th November 2012, 02:50
Would you be talking about a (for simplicity) ports or "pins" that are dual direction, AKA bidirectional?
I'll look for some articles. I just dont know off the top of my head, although I do know that you would need to build within your code instructions to flip from output to input. That being said, some external circuitry would be needed as for if you have a wigit connected to a specific pin, such as an LED, and you flip that output to an input that input signal could possibly interfere with the device connected.
-OR-
Are you simply looking for a interface to communicate with the device to send it instructions? That can be accomplished with a serial connection, (pins 8-RX and 11-TX) or you could get really fancy with a USB interface. Either way requires SERIN SEROUT commands and code plus much more to make this happen.
-OR- (Not recommended, really)
You could (and Im only throwing this out there, I would not suggest it) build your circuit with the In-circuit Serial Programming (ICSP) connection point.... Although this should be added anyway to fix bugs and creepies that come up in the code AFTER you have soldered it in place (and it happens, A LOT) but again I would not go this route to send the uC instructions for your printer, ONLY for ease of changing code for fixes/improvements. It's worth the 50 cents in lieu of de-soldering the chip.
timbear3
- 26th November 2012, 15:09
Hi, thank you Electromark for your time and your answer. I probably did not explain my self clear enough. I apology my English is not the best, it's my second language. Anyway, let me put it this way: you buy let say a coffee maker. First time you use it you must key in the time; when you want it to star brewing the coffee every morning; how do you like the coffee, light or bold and few other things. All of these instructions I supposed goes into the data eeprom or somewhere like that and the processor read these instructions and follow these every day until they are changed. I understand I'll need some extra electronics to do the job but that is part of learning this process. Only I need is someone that had that experience and lead me to books or places or his own knowledge on how to be able to accomplish this. Thanks a lot.
mackrackit
- 26th November 2012, 15:39
Seems like you just answered your own question... Do you need help with reading and writing to the EEPROM?
timbear3
- 27th November 2012, 00:31
Ok, that's a good start point! But any where to go on line? Any good book, Any program that does something alike. Thanks.
mackrackit
- 27th November 2012, 01:26
This page has links to examples for using the internal EEPROM and for using an external via I2C.
Depending on the amount of data you need to store and the frequency will probably determine if you use an internal or external solution.
I will suggest starting with the internal for practice.
http://melabs.com/samples/PBP-mixed/ee.htm
and
http://melabs.com/samples/PBP-mixed/eeword.htm
Once the examples are working then add an input button. Try increasing the data stored at a location by 1 every time the button is pressed.
timbear3
- 27th November 2012, 18:03
Thank you Mackrackit, now I can get the taste of it. I also have found some other examples and I think that that's the way to go. I'll report back. Thanks to all of you!
Archangel
- 1st December 2012, 02:30
I would ask you what your expectations are for your controller to do. Do you want it to interpret G code, or do you only expect it to act as a stepper motor controller/interpreter under the control of Mach III or similar?
timbear3
- 2nd December 2012, 00:35
No, I think that once I have the control program burned on the Pic it will control the projector and the stepper motor with pulses from within. The projector will need a digital pulse to advance the slide show for a number of milliseconds and the controller will count the slides to 0 and stop. The stepper motor will control the thickness of every slice and keep the resin in motion. I wanted to write the initial numbers at the eeprom en case the power is lost the program will read the number of slices and subtract a unit every time it read it and remember the thickness also. One print will take hours to make and you don't want to trash an almost finished part because of power failure. The program will have that contingency on it. I think the rest will be very easy once I finished the programming and test it for bugs. Thanks
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.