Decission won't switch

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

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:

Decission won't switch

Post by JLeith »

Hello All

I'm in a fog as to why my Decission is not switching to "Yes".

I'm trying to read the value of A5 and switch based on it being a value of 1.

For my test I set Port A5 = 1

Then I set my "Yes/No" to switch if "PortA5=1"

It won't switch.

Here is a picture
Attachments
Port A5.jpg
Port A5.jpg (54.76 KiB) Viewed 8359 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Decission won't switch

Post by kersing »

In the decision the check will switch PortA5 to input and read the pin level. The real level will read, not the level you set.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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: Decission won't switch

Post by JLeith »

Hi Kersing

Little confused

In my case I would like the Decission of A5 to switch to "Yes"

And I have set A5 = 1.

When I have it switching to A5 = 1 ( Level 1 ) Logic Level 1 ( 5V )

Does this make sense ?

John

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Decission won't switch

Post by kersing »

When you write $PortA5 = 1 in the decision Flowcode generates code to read the state of digital pin A5. To do so the output signal is removed, the pin is switched to input mode and the level is read. To go to the "Yes" branch you need to supply 5V to pin A5.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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: Decission won't switch

Post by JLeith »

The ghost of Flowcode.

I recall that once before.

Yes I have a incoming state coming into A5 that will be 5V Logic 1.

So you are saying in the Hardware with A5 set high the world will turn correctly.

Thank you

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: Decission won't switch

Post by JLeith »

I just noticed a problem

My A5 is oscillating I must have something odd.
But I don't have a device on A5.
Is there a way to set A5 as a input only?

John

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Decission won't switch

Post by kersing »

JLeith wrote:So you are saying in the Hardware with A5 set high the world will turn correctly.
Only if an external source feeds the 5V to A5.

If I'm not mistaken you can simulate by adding a switch and connect it to A5. $PortA5 should read the state of the switch (0 or 1).
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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: Decission won't switch

Post by JLeith »

Yes I have a state of A5 coming from another PIC.

It is setting it High.

John

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Decission won't switch

Post by kersing »

JLeith wrote:Yes I have a state of A5 coming from another PIC.

It is setting it High.
Are you outputting anything to port A or a5 elsewhere in your code?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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: Decission won't switch

Post by JLeith »

I have a QUAD Led using A0 - A4 and the Display A - G on Port D.

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: Decission won't switch

Post by JLeith »

Now I can't understand what is happening with Flowcode

I have what I think is a simple flow with 4 parts.
1. Set A5 High
2. copy A5 value to Display
3. Use the LCD to Display the value of Display. ( 0 )

I tried it live and I can't not read the value of A5 other then turning on a LED.

I need a method of reading A5 when it goes from Logic 1 to Logic 0. When it goes to Logic 0 I would like to set the LCD to display 0 0 0 0.

I have attached my Flowcode. Norw it is a little bashed up seeing I have tried eveything to get the Decission to follow A5.
Attachments
Team Display March 15 Wireless.fcfx
(39.04 KiB) Downloaded 194 times
Port A5 won't latch.jpg
Port A5 won't latch.jpg (82.2 KiB) Viewed 8244 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Decission won't switch

Post by medelec35 »

Hi John,
As kersing explained,
Within the same microcontroller, you can't set a pin high or low, then expect to be able to read the same pin.
When you read a pin the value read can only only be what is been made to do externally.
For example if a different microcontroller output is connected to the pin that is to be read.
Or a switch is connected that makes the pin to be read go high or low.

If the pin being read is also being used as an output to control say LED or 7seg, then when you turn it into an i/p then it will read what ever is on the pin via the LED.
So if the anode of LED is connected to +5V and the cathode is connected to the pin then the i/p would probably read high.
If the anode of LED is connected to the pin and the cathode connected to 0V then the i/p would read low even if just before reading pin it was set high.
It's no bug or strange behaviour, it's perfectly expected behaviour.
Martin

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: Decission won't switch

Post by JLeith »

I found an answer on a French YouTube. I could not understand the commentator but I could see the actions on the screen

I set PortA5 as a Input and then saved the value in the Input to "display"

Now I just going to try it win the hardware.

John
Attachments
PortA5 Saved.jpg
PortA5 Saved.jpg (31.19 KiB) Viewed 8239 times

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: Decission won't switch

Post by JLeith »

Well It didn't work in Hardware ?

maybe I will put in some delays to see if the Hardware is running to fast.

John
Attachments
Sad.jpg
Sad.jpg (5.69 KiB) Viewed 8238 times

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: Decission won't switch

Post by JLeith »

Well I have more work to do.

My display won't display 0 0 0 0

Only - - - 0

Here is ruff picture of what I would like to build
PIC 1 at Logic 1 on A5 PIC 2 display should be all Zero
Pic in Logic 0 on A5 PIC 2 display would be what it receives in the Wirless input. Example ( 0 5 4 2 )

I hoping the wireless will be simular to RS232 where I will send info to change 1 of the segments.

At this point I can scope A5 and I see PIC 1 sending to Logic 0 but the PIC 2 doesn't display correctly.

John
Attachments
Logic 0 & 1.jpg
Logic 0 & 1.jpg (22.69 KiB) Viewed 8216 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Decission won't switch

Post by medelec35 »

Hi John,
JLeith wrote:My display won't display 0 0 0 0

Only - - - 0
Quad 7seg LED displays can only show 1 digit at a time.
So if for example you sent 1234 to one 7seg at a time this would happen:

Code: Select all

1 to 7seg0:
7seg0 = 1 
7seg1 = Off 
7seg2 = Off
7seg3 = Off

Code: Select all

2 to  7seg1:
7seg0 = Off 
7seg1 = 2 
7seg2 = Off
7seg3 = Off

Code: Select all

3 to  7seg2:
7seg0 = Off 
7seg1 = Of
7seg2 = 3
7seg3 = Off

Code: Select all

4 to  7seg3:
7seg0 = Off 
7seg1 = Off
7seg2 = Off
7seg3 = 4
If you do nothing else so 7seg LED's are no longer refreshed then all you will see is 4 as that was the last quad 7seg LED to be set.

Reason for this is because the quad 7seg LED's have all the segments (a to g & . ) connected together to save pins on microcontroller.
only the anodes (common anode) or cathodes (common cathode) go to separate pins.

The only way to show all four displaying numbers is to keep refreshing, so persistence of vision makes it look like all four are on wen in reality only one is on at a time.

A common way to do this is to use timer interrupt.

I have posted several examples.
the latest one can be found here

Another issues is that each quad 7seg was not on for long enough before the next quad 7seg was on.

Martin
Martin

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: Decission won't switch

Post by JLeith »

Martin thank you for the info. Now that I see what you mean about the A-G being common.

And it is true the Quad can't store digits.

You are 100% correct in fooling the eye. In my Master project I have the Quad display in the Timer Interrup. And it works 100 %.

I think I'm going to take my Master Flowcode and load it into my receiver PIC.

Then change the flow to activate when A5 goes Low to call a Macro to read the MOSI signal.

Here is a sketch of my Master elements
Attachments
LCD - QUAD.jpg
LCD - QUAD.jpg (59.68 KiB) Viewed 8157 times

Post Reply