Code pieces work indipendently but not together
Moderator: Benj
Code pieces work indipendently but not together
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?
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?
- Attachments
-
- test.jpg
- eample of circuit set-up
- (109.8 KiB) Downloaded 2399 times
-
- 5 in 4 out + Left + Right.fcf
- example of code set-up
- (14.32 KiB) Downloaded 256 times
Willard Trefren
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Code pieces work indipendently but not together
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.
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.
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Code pieces work indipendently but not together
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Code pieces work indipendently but not together
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.
Willard Trefren
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Code pieces work indipendently but not together
Hello
Did you try this?
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Code pieces work indipendently but not together
If you want to use all available pins as outputs , then no pins left for inputs!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.
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?
Martin
Re: Code pieces work indipendently but not together
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!
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!
Willard Trefren
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Code pieces work indipendently but not together
Your welcome
Ahh. Whats confusing me is you say
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
Ahh. Whats confusing me is you say
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?WTrefren wrote:Only one (GP5/GP4) will stay constant when called upon
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
Martin
Re: Code pieces work indipendently but not together
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
-GP4 input to GP5 output (LED)--constant stream
-GP0 input to GP1 output--blink
-GP2 input to GP3 output--blink
Last edited by WTrefren on Thu Dec 17, 2009 7:33 pm, edited 1 time in total.
Willard Trefren
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Code pieces work indipendently but not together
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.
All three LED's and Switches are working independently.
There are several different ways of achieving same results.
This is just one of them.
- Attachments
-
- 3 Button LED Control.fcf
- (11 KiB) Downloaded 260 times
Martin
Re: Code pieces work indipendently but not together
I'll try it out ASPA! Thank you for your diligence and follow through Medelec35.
Willard Trefren
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Code pieces work indipendently but not together
Your welcome.
Opps sorry forgot GP3 is input only on 12F675
was just following:
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
Opps sorry forgot GP3 is input only on 12F675
was just following:
lolWTrefren wrote: -GP2 input to GP3 output--blink.
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
- Attachments
-
- 3 Button LED Control.fcf
- (11 KiB) Downloaded 263 times
Last edited by medelec35 on Thu Dec 17, 2009 9:52 am, edited 1 time in total.
Martin
Re: Code pieces work indipendently but not together
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!
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!
Willard Trefren
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Code pieces work indipendently but not together
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.
If you need Flowcode 4 examples to learn from see here: http://www.matrixmultimedia.com/Flowcode3a-X.php
Good luck.
Martin