Page 1 of 1

Code pieces work indipendently but not together

Posted: Mon Dec 14, 2009 5:28 pm
by WTrefren
The pieces of my code work great independent of each other, but I'm having difficulty getting them to work in an integrated mater.

More precisely, I'm using a 12F675. I can get LEDs to blink on three pairs (e.i. GPO/GP1, GP3/GP2, GP5/GP4) or I can get a steady stream of LED light to be produced via GP5/GP4; however, if GP5/GP4 is programed to produced a steady stream the other pairs won't producing blinkage.

Any suggestions?

Re: Code pieces work indipendently but not together

Posted: Mon Dec 14, 2009 9:17 pm
by medelec35
So you want the code to have GP4 and GP5 permanently on and at the same time GPO/GP1, GP3/GP2 flashing?
In any particular sequence?
I would not recommend connecting LEDs up without a series limiting resistor for each one , you could exceed the power rating of pic chip.

Re: Code pieces work indipendently but not together

Posted: Tue Dec 15, 2009 9:44 am
by Benj
Hello

In your perm macro you read the entire port into the perm variable. This will switch off any LEDs connected to the port. You could use the port masking as part of the input properties to allow the lower port bits to be read without disabling the LEDs.

Re: Code pieces work indipendently but not together

Posted: Tue Dec 15, 2009 4:12 pm
by WTrefren
medelec35 wrote:So you want the code to have GP4 and GP5 permanently on and at the same time GPO/GP1, GP3/GP2 flashing?
In any particular sequence?
I would not recommend connecting LEDs up without a series limiting resistor for each one , you could exceed the power rating of pic chip.

I want to be able to have GP4/GP5 permanently on or off regardless if GP0/GP1 or GP3/GP2 is called upon to flash. Only GPO/GP1 or GP3/GP2 will be flashing at one time, but in no particular order.

Roger that on the series limiting resistor, thank you.

Re: Code pieces work indipendently but not together

Posted: Tue Dec 15, 2009 5:52 pm
by Benj
Hello

Did you try this?
You could use the port masking as part of the input properties to allow the lower port bits to be read without disabling the LEDs on the higher bits.

Re: Code pieces work indipendently but not together

Posted: Tue Dec 15, 2009 7:08 pm
by medelec35
WTrefren wrote: I want to be able to have GP4/GP5 permanently on or off regardless if GP0/GP1 or GP3/GP2 is called upon to flash. Only GPO/GP1 or GP3/GP2 will be flashing at one time, but in no particular order.
If you want to use all available pins as outputs , then no pins left for inputs!
one problem is you only have 5 pins which are bidirectional which are GP0, GP1,GP2,GP3,GP5. So these can be used for inputs or outputs.
GP4 is a input pin only.
If have two switches then you only have 4 pins left for connecting LEDs to.
Now of course I agree with ben about masking. But there is a way of driving more LED's with the few available pins, The term is called Charlieplexing. E.g using just 3 pins, you can connect 6 LED's and have individual control over them all. Bit it is more complex since it requires tristate pins. I will see what I can create, and post the flowcode and circuit diagram if I can get it to work OK
Unless you state otherwise. I will do it so you press one switch and 1 LED will be solid and rest will flash in pairs. Press the other switch then a different LED will be solid while the LEDs are still flashing.
Would you be interested in that or would you want it kept more simple and have two switches and just 4 LED's?

Re: Code pieces work indipendently but not together

Posted: Tue Dec 15, 2009 7:43 pm
by WTrefren
I've tried masking which has worked somewhat (i.e. I can get GP5/GP4 to stay solid or GPO/GP1 to blink, but, in both instances, only if GP3 is pulled up... connected to positive). Furthermore, GP5/GP4 will shut off only when GP3 is disconnected from the plosive rail.

What is needed is three switches controlling three LEDs (i.e. one switch per LED). Only one (GP5/GP4) will stay constant when called upon. GPO/GP1 blinks regardless of GP5/GP4 activation, as is the same with GP2/GP3; however, if GPO/GP1 is blinking GP2/GP[3 is not and vice versa.


Thank you Medelec35 and Benj for your help thus far.....it is greatly appreciated!

Re: Code pieces work indipendently but not together

Posted: Wed Dec 16, 2009 12:12 am
by medelec35
Your welcome
Ahh. Whats confusing me is you say
WTrefren wrote:Only one (GP5/GP4) will stay constant when called upon
To me GP5/GP4 is a quantity of two LEDs that will stay on. So I'm assuming you mean switch connected to GP4 (since that's an input only) controls LED connected to GP5?
Also Switch connected to GP0 will control GP1to make it blink?
If so will be able to help you tomorrow. Bit to late for me now :cry:

Re: Code pieces work indipendently but not together

Posted: Wed Dec 16, 2009 1:05 pm
by WTrefren
Yes you're quite right.
-GP4 input to GP5 output (LED)--constant stream
-GP0 input to GP1 output--blink
-GP2 input to GP3 output--blink

Re: Code pieces work indipendently but not together

Posted: Wed Dec 16, 2009 4:17 pm
by medelec35
Here you are as promised.
All three LED's and Switches are working independently.

There are several different ways of achieving same results.
This is just one of them.

Re: Code pieces work indipendently but not together

Posted: Wed Dec 16, 2009 4:29 pm
by WTrefren
I'll try it out ASPA! Thank you for your diligence and follow through Medelec35.

Re: Code pieces work indipendently but not together

Posted: Wed Dec 16, 2009 4:40 pm
by medelec35
Your welcome.

Opps sorry forgot GP3 is input only on 12F675 :oops:
was just following:
WTrefren wrote: -GP2 input to GP3 output--blink.
lol
Corrected version.

A question. I can’t make out the colours on your resistors. What are value and colour please?

From what I can make out they look like brown, black and blue = 10Meg. If so your circuit will probably work OK but 10Meg is very high value for pull up resistor. Im not sure on the highest value, but you do get to a point when although input resistance of pins are high, leakage, input resistance, induced voltage form
neighbouring tracks/wires etc will change value of the pull-up voltage.

On a different note, If you have only got 3 LEDs then a LED limiting resistor may not be required since I believe the outputs are limited to 20mA anyway. But If low current LEDs then resistor will be necessary

Re: Code pieces work indipendently but not together

Posted: Wed Dec 16, 2009 9:48 pm
by WTrefren
YES...finally...oh joy!!

I was trying diligently to get the last sample to work, but I see now that you've already taken care of that. Thank you again Medelec35.
As for the LEDs, they're there just to test the outputs.

Best regards and holiday wishes!

Re: Code pieces work indipendently but not together

Posted: Wed Dec 16, 2009 11:22 pm
by medelec35
Glad its working for you.
If you need Flowcode 4 examples to learn from see here: http://www.matrixmultimedia.com/Flowcode3a-X.php
Good luck.