OK, so I'm trying to write a simple program for a 12f629 that will, after a certain amount of time, connect two wires through the PIC. I want the PIC to keep the wires disconnected until the right time, and I think I've written it properly in my code - but I'm probably wrong. Here's what I've done:
start:
set Pin1 ON ;make a connection between Pin1 and Pin2
set Pin2 ON
wait 125 ms
set Pin1 OFF ;break connection
set Pin2 OFF
wait 7 s
goto start
==================================================
What do you think? Is this not the proper way to code a simple program like this?
I thank you for looking at my post,
-Qlept0
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your code works perfectly fine, it's doing exactly what you are telling it to do. If 330 ohm resistors, and leds were attached to the GPIO's, they would briefly flash, wait 7 sec, then flash again.
The PIC GPIO's have the ability to sink or source 25ma. The outputs do not act as switches in the sense of completing a circuit. You would use an appropriate transistor to switch the current and complete the circuit of two separate wires. The GPIO would be used to turn on the base/gate of the transistor.
Is high current is involved?, did the PIC got really hot?....the poor guy may be DOA.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The PIC doesn't get hot, I don't think there's any high currents involved, it's only an xbox controller.
I noticed that when everything is soldered together, the two wires I am trying to connect through the PIC seem to always be connected (the button I'm trying to control is always active). Could this be because the PIC is not getting power? I'll have to try attaching it to another source.
If it's not the power, I'll try to get a hold of a transistor from somewhere.
Thanks a lot for helping me out!
-Qlept0
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Darn it, lost the message by accidentally hitting the back button, so here it goes again.
If you have connected the GPIO pins in series with the high side of the button, then nothing will change. You definitely need a transistor. At best the Xbox microcontroller input is left floating during the off time of the PIC.
Check out how the MCLR pin and button is configured on any Pic schematic out there. Think of the MCLR button as the button of your Xbox, when its pressed down the input to the MCLR pin goes from V+ (3-5V)to ground (0V). Notice that the current to either the MCLR pin or ground is limited by a 1-10K resistor.
So if you wanted full function of the button and also have it blip every 7 seconds then you would OR the input by placing a transistor in parallel with the button, like:
High/V+ side of the button >> 1k resistor >> collector pin of transistor.
Emitter pin of transistor >> low side of button/ground.
GPIO of PIC >> 1k resistor >> Base/gate of transistor.
Connect V+ and ground of PIC to V+ and ground of the controller.
If you only wanted the blip every 7 seconds then you would also disconnect (or cut the trace) either side of the button.
Good luck.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for all your help, but I won't be able to try any of this for a while. I connected my PIC to a few other points on my xbox and I think I fried it (it heated up pretty bad), and in the process of checking to see if the PIC was fried, I broke my cheapo PIC programmer. I made a new one, but it's not reading any of my PICs. I made a big mistake and will have to wait on this project.
Thank you so much for sharing your expertise with me, I learned a bunch about PICs from this topic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, so I'm trying to write a simple program for a 12f629 that will, after a certain amount of time, connect two wires through the PIC. I want the PIC to keep the wires disconnected until the right time, and I think I've written it properly in my code - but I'm probably wrong. Here's what I've done:
==================================================
#chip 12F629, 20 ;configure chip
#define Pin1 GPIO.1 ;define pins
#define Pin2 GPIO.2
DIR Pin1 OUT ;set pins as OUT
DIR Pin2 OUT
start:
set Pin1 ON ;make a connection between Pin1 and Pin2
set Pin2 ON
wait 125 ms
set Pin1 OFF ;break connection
set Pin2 OFF
wait 7 s
goto start
==================================================
What do you think? Is this not the proper way to code a simple program like this?
I thank you for looking at my post,
-Qlept0
Your code works perfectly fine, it's doing exactly what you are telling it to do. If 330 ohm resistors, and leds were attached to the GPIO's, they would briefly flash, wait 7 sec, then flash again.
The PIC GPIO's have the ability to sink or source 25ma. The outputs do not act as switches in the sense of completing a circuit. You would use an appropriate transistor to switch the current and complete the circuit of two separate wires. The GPIO would be used to turn on the base/gate of the transistor.
Is high current is involved?, did the PIC got really hot?....the poor guy may be DOA.
The PIC doesn't get hot, I don't think there's any high currents involved, it's only an xbox controller.
I noticed that when everything is soldered together, the two wires I am trying to connect through the PIC seem to always be connected (the button I'm trying to control is always active). Could this be because the PIC is not getting power? I'll have to try attaching it to another source.
If it's not the power, I'll try to get a hold of a transistor from somewhere.
Thanks a lot for helping me out!
-Qlept0
Darn it, lost the message by accidentally hitting the back button, so here it goes again.
If you have connected the GPIO pins in series with the high side of the button, then nothing will change. You definitely need a transistor. At best the Xbox microcontroller input is left floating during the off time of the PIC.
Check out how the MCLR pin and button is configured on any Pic schematic out there. Think of the MCLR button as the button of your Xbox, when its pressed down the input to the MCLR pin goes from V+ (3-5V)to ground (0V). Notice that the current to either the MCLR pin or ground is limited by a 1-10K resistor.
So if you wanted full function of the button and also have it blip every 7 seconds then you would OR the input by placing a transistor in parallel with the button, like:
High/V+ side of the button >> 1k resistor >> collector pin of transistor.
Emitter pin of transistor >> low side of button/ground.
GPIO of PIC >> 1k resistor >> Base/gate of transistor.
Connect V+ and ground of PIC to V+ and ground of the controller.
If you only wanted the blip every 7 seconds then you would also disconnect (or cut the trace) either side of the button.
Good luck.
Thanks for all your help, but I won't be able to try any of this for a while. I connected my PIC to a few other points on my xbox and I think I fried it (it heated up pretty bad), and in the process of checking to see if the PIC was fried, I broke my cheapo PIC programmer. I made a new one, but it's not reading any of my PICs. I made a big mistake and will have to wait on this project.
Thank you so much for sharing your expertise with me, I learned a bunch about PICs from this topic.