Decission won't switch
Moderator: Benj
- 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
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
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 (54.76 KiB) Viewed 8359 times
-
- 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
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
― C.S. Lewis
- 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
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
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
-
- 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
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
― C.S. Lewis
- 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
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
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
- 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
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
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
-
- 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
Only if an external source feeds the 5V to A5.JLeith wrote:So you are saying in the Hardware with A5 set high the world will turn correctly.
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
― C.S. Lewis
- 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
Yes I have a state of A5 coming from another PIC.
It is setting it High.
John
It is setting it High.
John
-
- 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
Are you outputting anything to port A or a5 elsewhere in your code?JLeith wrote:Yes I have a state of A5 coming from another PIC.
It is setting it High.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- 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
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.
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 (82.2 KiB) Viewed 8244 times
-
- 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
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.
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
- 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
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
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 (31.19 KiB) Viewed 8239 times
- 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
Well It didn't work in Hardware ?
maybe I will put in some delays to see if the Hardware is running to fast.
John
maybe I will put in some delays to see if the Hardware is running to fast.
John
- Attachments
-
- Sad.jpg (5.69 KiB) Viewed 8238 times
- 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
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
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 (22.69 KiB) Viewed 8216 times
-
- 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
Hi John,
So if for example you sent 1234 to one 7seg at a time this would happen:
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
Quad 7seg LED displays can only show 1 digit at a time.JLeith wrote:My display won't display 0 0 0 0
Only - - - 0
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
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
- 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
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
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 (59.68 KiB) Viewed 8157 times