Page 1 of 1

The MIAC dsPIC Interrup reset

Posted: Tue Jun 19, 2018 5:48 pm
by Monie Jacobsen
Hello everyone
When simulated in the Flowcode program, the codes work.
I am working to get MAC sdPIC with the attached codes to work in the real world?
Works to get attached codes to work with MAC sPICE Interrup reset function, but without success.
Have tried a lot ;-)
Would you like to help make the codes work?

Attach file:
MIAC dsPIC Interrup Induktiv Stop.fcfx
(76.08 KiB) Downloaded 308 times

Re: The MIAC dsPIC Interrup reset

Posted: Tue Jun 19, 2018 9:52 pm
by Benj
Hi Monie,

Can you explain what currently isn't working. I've had a look through your program and can spot a couple of things but not sure if they are related to the problem your having.

1) The timer interrupt is firing quite fast > 1000Hz, is this correct?

2) In TvangRunOstWest the only decision for Reset_Noed = 1 is directly after the variable is populated from the input. The other Reset_Noed = 0 clears will be overwritten before the decision. Maybe move the input icon to the no branch so the no branch gets at least one time to run every cycle?

As I say these could be unrelated.

Re: The MIAC dsPIC Interrup reset

Posted: Wed Jun 20, 2018 7:44 am
by Monie Jacobsen
Hi Benj

1: The timer interrupt is firing quite fast> 1000Hz, is this correct?
Answer: Do not know where to set the timer interrupt ??

2: Wishes that when the reset button is activated, East or West can be run again

3: Attempted to move the input icon to the no branch, but unsuccessfully.

I agree that I ignore any procedure ;-)
But can not see how it can correct to get the Reset button to work correctly.

The Reset button is a manual function.

Please help with your proposal to correct the codes so they work as desired.

Thank you very much in advance

Re: The MIAC dsPIC Interrup reset

Posted: Wed Jun 20, 2018 12:50 pm
by Benj
1: The timer interrupt is firing quite fast> 1000Hz, is this correct?
Answer: Do not know where to set the timer interrupt ??
Double click the Timer Interrupt enable icon in Main.
Then click the Properties... button.

Re: The MIAC dsPIC Interrup reset

Posted: Wed Jun 20, 2018 3:27 pm
by Monie Jacobsen
Hi Benj

Have tried The timer interrupt is firing quite fixed> 1000Hz;-)
EgenskaberInterrup.JPG
EgenskaberInterrup.JPG (46.83 KiB) Viewed 8088 times
Have tried the following file. But does not work in the real world
Attached file:
MIAC dsPIC Interrup Induktiv Stop.fcfx
(76.08 KiB) Downloaded 332 times
Would you be helpful. These codes would I be able to use in other projects!

Re: The MIAC dsPIC Interrup reset

Posted: Wed Jun 20, 2018 5:03 pm
by Benj
Hi Monie,

Can you explain what you need the program to do. it might be that the timer interrupt is not needed and we can simplify things.

Currently it looks like you have a timer interrupt that enables a flag, this interrupt is firing so fast that the flag might as well just be fixed to be 1.

You then have a edge triggered interrupt that fires based on a switch which allows you to go into different branches of the EastWest macro.

You also have a reset switch that is sampled as part of one of the EastWest branches that resets the state of the EastWest branch.

Re: The MIAC dsPIC Interrup reset

Posted: Wed Jun 20, 2018 5:34 pm
by Monie Jacobsen
Hello everyone
I underestimate much when I can not make myself understandable.
Action Description:
The program must stop interrupting East or West by Interrup when an Inductive Sensor is activated.
And by switch, stop reset to run again.
I want to use Interrupt as I want a global stop for ongoing action such as East - West - Up - Down.
I understand that I'm jammed in the codes ;-)

Re: The MIAC dsPIC Interrup reset

Posted: Fri Jun 22, 2018 11:38 am
by Monie Jacobsen
Hello everyone
If there is no one here that will help to make an example of a learning code example that Interrup resets with the device MIAC dsPIC.
I would like to welcome you with a code example of the above wish.

Re: The MIAC dsPIC Interrup reset

Posted: Mon Jun 25, 2018 9:46 am
by LeighM
Hi Monie

I think we have done an interrupt example in the past or could do another one, but I don't think this will necessarily help you.

You would still need to change the action of the main processing.
So in any loop that is running the motors you need to check for the Inductive Sensor and stop inputs, either directly or via an interrupt flag change.

Alternatively the best way to do this is via a "state machine" approach to programming.
Have a state variable that holds the current state of the process,
that is, a number that indicates what you are currently doing, nothing, moving left, right etc.
Use the main loop to monitor your various inputs (limit switch, stop etc) and the keypad.
Action is then taken on the various inputs depending upon the state, and moves to a new state.

This should also help to make the program more readable, and also avoid getting stuck in time consuming loops, which I think is causing the problems.

It is difficult to "fix" things in your current programs as it is not always obvious what you are trying to achieve.
Hope the above helps, but if you need any more specific help, ask again.
Best regards,
Leigh