Switches problem
Moderator: Benj
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Switches problem
I have a problem with switches. I think it is a small problem but I can’t figure it out.
I have four momentary buttons and I get them to work. They won’t come out of the loop.
It must be a simple error what I have made.
Attached is the fcfx file.
I hope that someone can find this error.
Thanks,
Frank
I have four momentary buttons and I get them to work. They won’t come out of the loop.
It must be a simple error what I have made.
Attached is the fcfx file.
I hope that someone can find this error.
Thanks,
Frank
- Attachments
-
- Switches Test - 01.fcfx
- (45.21 KiB) Downloaded 104 times
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: Switches problem
hi frank
from what i can see in your macros your main loop is "loop while 1" therefore continuously looping, I've changed the first 2 macros to "loop count 1" so they will only loop once and i changed the cross and corner macros to "loop count 4" as an example is this what you were looking for
bob
from what i can see in your macros your main loop is "loop while 1" therefore continuously looping, I've changed the first 2 macros to "loop count 1" so they will only loop once and i changed the cross and corner macros to "loop count 4" as an example is this what you were looking for
bob
- Attachments
-
- Switches Test - 01.fcfx
- (52.64 KiB) Downloaded 100 times
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Hi Bob,
Thanks for helping.
All Macro’s must loop forever until I press a switch for the next Macro. I have modified the file to show what I mean.
Frank
Thanks for helping.
All Macro’s must loop forever until I press a switch for the next Macro. I have modified the file to show what I mean.
Frank
- Attachments
-
- Switches Test - 02.fcfx
- (44.96 KiB) Downloaded 107 times
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
I have made a better flowcode but still the switches don’t work. And I can’t figure out why.
When I press a switch it must immediately show the Macro what belongs to the switch. Not waiting before the running Macro is finished.
Attached is what I have made so far.
When I press a switch it must immediately show the Macro what belongs to the switch. Not waiting before the running Macro is finished.
Attached is what I have made so far.
- Attachments
-
- Switches Test - 03.fcfx
- (44.68 KiB) Downloaded 101 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: Switches problem
Hi Frank,
Do you want to see if the attached flowchart does what you want it to do?
Do you want to see if the attached flowchart does what you want it to do?
- Attachments
-
- Switches Test - 04.fcfx
- (58.22 KiB) Downloaded 114 times
Martin
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Hi Martin,
Wow, very nice work !! Total different than I had in mind. It keeps me learning.
I will work on the Cross macro according the Arrow Left and Right tomorrow.
I will let you know how it goes and post the final fcfx code here for other users.
Wow, very nice work !! Total different than I had in mind. It keeps me learning.
I will work on the Cross macro according the Arrow Left and Right tomorrow.
I will let you know how it goes and post the final fcfx code here for other users.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Yes, this PCB (switch input) will be controlled by a other component what only give short pulses on the switch inputs on this PCB.
So, in simulation it works great. Tomorrow I will test this in hardware. (if I have no call for a “rush job”)
So, in simulation it works great. Tomorrow I will test this in hardware. (if I have no call for a “rush job”)
-
- 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: Switches problem
Hi, Frank.
The attached flowchart is designed to exit the current looping macro within 20ms of pressing a switch.
It should not matter where within the macro is currently being executed.
I can imagine that is more what you are after?
Note:
When running on hardware, the IsSim branch within Timer ISR is false
The attached flowchart is designed to exit the current looping macro within 20ms of pressing a switch.
It should not matter where within the macro is currently being executed.
I can imagine that is more what you are after?
Note:
When running on hardware, the IsSim branch within Timer ISR is false
- Attachments
-
- Switches Test - 05.fcfx
- (61.62 KiB) Downloaded 110 times
Martin
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Hi Martin,
I’m working with Switches Test - 04.fcfx. (05 gives errors, but that is for later)
The switches (B0, B1, B2 and B3) pin’s on the PIC gets a GND signal from optocouplers. So the switches are Active Low.
I thought it was easy to change this is this 04 code. But unfortunately not.
Can you tell me what I have to change to get this to work in Hardware?
I’m working with Switches Test - 04.fcfx. (05 gives errors, but that is for later)
The switches (B0, B1, B2 and B3) pin’s on the PIC gets a GND signal from optocouplers. So the switches are Active Low.
I thought it was easy to change this is this 04 code. But unfortunately not.
Can you tell me what I have to change to get this to work in Hardware?
-
- 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: Switches problem
Hi, Frank.
To change the flowchart so switches are active low, all you need to do is change the switch properties from active high to active low.
That is so the simulation will work correctly.
Then within the timer interrupt, I added a calculation icon, just below the input icon:
If the issue is a message stating 'This project was built with a newer version' etc that can be ignored.
If related to IsSim then make sure you run a full update with the Full-Database option.
If that does not fix it then there is a way around it.
To change the flowchart so switches are active low, all you need to do is change the switch properties from active high to active low.
That is so the simulation will work correctly.
Then within the timer interrupt, I added a calculation icon, just below the input icon:
Code: Select all
.Switch = 15 - .Switch
That can be fixed.
If the issue is a message stating 'This project was built with a newer version' etc that can be ignored.
If related to IsSim then make sure you run a full update with the Full-Database option.
If that does not fix it then there is a way around it.
- Attachments
-
- Switches Test - 04 Inverted.fcfx
- (50.06 KiB) Downloaded 78 times
Martin
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Hi Martin,
I had changed the properties of the switches from High to Low. That dint work, so I chanced so more things to see if it works. But it didn’t.
Your calculation did the job ! It works now perfectly
Many thanks !
I had changed the properties of the switches from High to Low. That dint work, so I chanced so more things to see if it works. But it didn’t.
Your calculation did the job ! It works now perfectly
Many thanks !
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Hi Martin,
On the PCB is also a remote control connect to D7, D0, C3 and C1 - Active High. I have to program the remote control (KEELOQ) and then I will try to implement this into the 04 - Inverted file.
On the PCB is also a remote control connect to D7, D0, C3 and C1 - Active High. I have to program the remote control (KEELOQ) and then I will try to implement this into the 04 - Inverted file.
-
- 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: Switches problem
Hi Frank,
Your welcome.
Is the remote is going to override the opto's?
Or will it be the other way around?
I'm just thinking what if both was active at the same time?
If I was you, I would give one priority over the other.
I can help you with that if required?
Your welcome.
Is the remote is going to override the opto's?
Or will it be the other way around?
I'm just thinking what if both was active at the same time?
If I was you, I would give one priority over the other.
I can help you with that if required?
Martin
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Hi Martin,
Thanks.
For what I understand is that the external box in the car will send pulses to the switches. So the working of this code is good. See YouTube link: https://youtu.be/ckraJEgPnIs . I have made a small test board with 5mm LEDs to see of it works.
So the remote control sends pulses from 0.5 second long in an Active High state directly to the PIC.
When I was developing this PCB I was unsure how this external box will work, that why I choose to use four extra pins for the remote control. Just to be safe.
Example:
When one of the switches is activating Macro1 and when I press a switch on the Remote Control for Macro2, than Macro2 must be active. And so on. Apart from each other.
Attached is the code so far I have.
Thanks.
For what I understand is that the external box in the car will send pulses to the switches. So the working of this code is good. See YouTube link: https://youtu.be/ckraJEgPnIs . I have made a small test board with 5mm LEDs to see of it works.
So the remote control sends pulses from 0.5 second long in an Active High state directly to the PIC.
When I was developing this PCB I was unsure how this external box will work, that why I choose to use four extra pins for the remote control. Just to be safe.
Example:
When one of the switches is activating Macro1 and when I press a switch on the Remote Control for Macro2, than Macro2 must be active. And so on. Apart from each other.
Attached is the code so far I have.
- Attachments
-
- Switches Test - 05 - Inverted Switches with RC.fcfx
- (52.22 KiB) Downloaded 62 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: Switches problem
Hi, Frank.
Wow, the video looks great!
Adding the extra switches that are active high making it slightly more complex.
I have done that for you.
What makes it more complex are the extra switches are C1,C3, D0 and D7 rather than D0, D1, D2 and D3 etc.
Now you can use the combination of active high and active low switches.
The command will always be the last switch detected.
Wow, the video looks great!
Adding the extra switches that are active high making it slightly more complex.
I have done that for you.
What makes it more complex are the extra switches are C1,C3, D0 and D7 rather than D0, D1, D2 and D3 etc.
Now you can use the combination of active high and active low switches.
The command will always be the last switch detected.
- Attachments
-
- Switches Test - 06 - Inverted Switches with RC.fcfx
- (54.22 KiB) Downloaded 65 times
Martin
-
- Posts: 192
- Joined: Mon Mar 04, 2013 8:07 pm
- Has thanked: 29 times
- Been thanked: 15 times
- Contact:
Re: Switches problem
Hi Martin,
Wow this works perfectly!! Thank you very much for this code. I'm trying to understand this code so that I can understand it better as well.
Unfortunately the pins have different ports and not D0, D1, D2 and D3. This has to do with how the PIC is placed on the PCB. I tried to keep lines as short as possible to all MOSFETs.
Thanks again.
Greeting,
Frank
Wow this works perfectly!! Thank you very much for this code. I'm trying to understand this code so that I can understand it better as well.
Unfortunately the pins have different ports and not D0, D1, D2 and D3. This has to do with how the PIC is placed on the PCB. I tried to keep lines as short as possible to all MOSFETs.
Thanks again.
Greeting,
Frank
-
- 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: Switches problem
Hi, Frank.
You are welcome.
I totally understand and that is how it should be done.
All I was saying it makes it slightly more complex.
I stated that in case you waned to see how the flowchart works.
That's excellent, I glad its working for you.
You are welcome.
I totally understand and that is how it should be done.
All I was saying it makes it slightly more complex.
I stated that in case you waned to see how the flowchart works.
Martin