Push button Vs LED layout

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Push button Vs LED layout

Post by JLeith »

Hello All,

Well I have been able to get my Scoreboard down to the ROM size to fit in the PIC.

I have also set my Push Buttons to "Active Low" this I believe is the mode I will be using to receive the incoming ground enabled signal on Port B 0 -7.

Now I have a issue with the LEDS not turning off once the Bit pattern has been sent. You can see by the picture the PDF that the Leds are still on ?

The flow is the incoming signal (Simulated by the push buttons) is picked up and the corresponding macro action such as a "Ball" or "Strike".

This would mean the Push button is in a Receive Mode. and the LED's would be in a inactive state. ( Not happening )

Once the Ball Macro runs then the Port B should switch form input to Output.

Once the display has been sent the LED's should turn off and Port B should be Incoming.

I have placed a PDF to help with my thoughts on how the Flowcode handles the Push Button and LED wiring.

I think I have the Port B as input when it is scanning for the push buttons and the Macro is sending out the sequence but the Leds don't turn off. I think the LED are responding to the "Active Low" of the Push buttons ?

I'm hoping there is something missing on my Macro side to Flip to Output for Leds and then Switch to Input for the Switches.

I have also added my project. ( Date Nov 28th )

John
Attachments
Flowcode Scoreboard Nov 28.fcf
(119.02 KiB) Downloaded 281 times
Push Button Layout in Flowcode PDF.pdf
(100.05 KiB) Downloaded 300 times

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Push button Vs LED layout

Post by Mikat »

Hi.
The program don't work on simulation, or at hardware?
If the hw don't work, what are the resistor values in actual design?

Mika

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Push button Vs LED layout

Post by JLeith »

Hello Mikat,

In my PDF I was showing what I believed is the flow of the Flowcode when it deals with Push Buttons and Leds.

It is normal to have a resistor to allow the PIC to determine if a state change to the current is happening.

My puzzle is if the Push button is open in a Active Low how is the LED lighting the LED current should be to low. The PIC needs to send out a +5 volts to light the led's because the Cathodes are connected to Ground.

In the Process if the PIC Port B is set for Input then the PIC should be looking for a Ground Input.

When the PIC Port B is set for Output the Pic will send the +5 to the Port B ports.

I just can't work out how to set the Port B as Input for the push Buttons and then when the Marco is running the Ports are Output.

I hope this helps.
John

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Push button Vs LED layout

Post by JLeith »

Hi all,

I have been doing some investigation and this is what I have found.

From the info if I can set the Input switches to Input flowcode should be activating the 47K resistor to stop the LED form coming on. This is not happening when I press the Button the LED lights, I suspect I'm missing the code to set the switch to ( INPUT ) and activate the 47K resistor. I will have to keep the buttons as Active High. I will rework my PCB to Active high.

If someone can help me set input as (INPUT) to activate the 47K should wrap up my project.

The connections for the LED: ( from the help menu )

Combined LED and switch circuit

We find this general LED and switch circuit allows you to use either a switch or a LED on a I/O pin of the Chip. The LED's in this component are wired with all cathodes connected to ground and the anodes of each LED are connected to a suitable Chip port via a 560 ohm resistor.
The 4k7 resistor is used to pull the pin down to a logic level of 0V when the pin is used as an input and the 390 ohm resistor is used to limit current flow when the switch is closed.
Led and Switch.jpg
Led and Switch.jpg (9.23 KiB) Viewed 7153 times
John

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Push button Vs LED layout

Post by Mikat »

Hi.
The reason why I asked about the resistors is that the way you describes the led and button schematic in you pdf creates quite simple voltage divider at the PIC port. So if you use the 10kohm resistors the voltage goes like this (5V - 1.8V)*(30kohm/10Kohm) + 1.8V...
That 1.8V is the forward voltage of the led.. So the voltage at the PIC i/o pin is something like 2,9V when the pin is an input and switch is open, and thet might not be enough to read pin correctly (usually the min Vin_hi voltage is something like 0,7*vcc = 3,5V)..
Sorry my bit bad English, but are looking at solution that when you use the port as input, the led should not work, and when you use it at output, the led should work?

Mika

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Push button Vs LED layout

Post by JLeith »

Hi Mikat,

Your info:
are looking at solution that when you use the port as input, the led should not work, and when you use it at output, the led should work?

100% correct that is exactly the statement I was hoping for that if the Port is INPUT the LED should not work.

In my project I'm missing the process to make the Port INPUT and then OUTPUT when needed. I have tried everything I know and I must say it isn't much.

It starting to look like the 4.7K bypass is not working in version PICmicro 5.4.

Mikat do you know the process to make the port INPUT and not have the LED work until the PORT is OUTPUT ?

John

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Push button Vs LED layout

Post by Mikat »

Hi.
The led is quite hard to get work that way that it don't react when the switch is pressed, at least I don't know how that could be done..
Isn't is possible to move leds different port than switch?
Mika

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Push button Vs LED layout

Post by JLeith »

Good morning Mikat,

From the information provide by Flowcode it should be possible if the 47K resistor shunts the LED.

For selecting a different port I only have Port A and B. for the Dip18 PIC16F1826. Back in 2002 students at a college in London produce a similar project with two Electro-Mechanical digit displays. The original code was written in a ASM format and only addressed two displays and I need a little more with 8 displays and wireless interface.

From the process of INPUT and OUTPUT control of a single port is possible from what I have read but they don't lay it out for use in flowcode. I do see from the help menu that flowcode also believes it but they don't list how to make it happen. This is the mystery.

So I will keep searching the net to see if anyone has made it happen. Or maybe the staff design team of Flowcode has a answer.

All the best,
John

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Push button Vs LED layout

Post by Mikat »

Hi.
The only way that I can think to get the button and Led working as you want is use 3 volt zener diode serial to diode, like picture below
Led_button.jpg
Led_button.jpg (36.13 KiB) Viewed 7118 times
.
The led and 3 volt zener serial should let the pullup resistor rise the voltage at 3v+ LED forward voltage (about 4.8V), but the pullup resistor is so large that led don't light up.. The button (ST1) is active low, so the voltage at PIC i/o pin is 0V when the button is pressed.. And when the PIC port is output hi, the led should light up... The R_SER is to protect the PIC i/o port, and limiting the LED current...

Mika

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Push button Vs LED layout

Post by JLeith »

Evening Mika,

From you picture it is possible to drop the voltage with a Zener Diode but in the documents Flowcode is using the 47K to shunt the LED with the option of setting the Port B as INPUT.

The mystery is how to inform Flowcode to set the Port B as INPUT and when needed switch to OUTPUT.

John

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Push button Vs LED layout

Post by Mikat »

JLeith wrote:Evening Mika,

From you picture it is possible to drop the voltage with a Zener Diode but in the documents Flowcode is using the 47K to shunt the LED with the option of setting the Port B as INPUT.

John
No it's not possible...
Using the port both at the input and output is quite easy, if you mean the way that is the last picture what you had posted (by the way the resistor 4k7 = 4,7k, not 47k) , the port works ok both input and output, BUT the LED will light up when the button is pressed, so that is the "hard" part, to get LED the not react the button...
If you don't have 3V zener, you might test 4-5 (depends the forward voltage) normal diode at series, but the resistor don't work...

Mika

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Push button Vs LED layout

Post by JLeith »

Sorry I missed the decimal point when listing the 47K you are correct it should read 4.7K.

John

Post Reply