I'm trying to test a program, and not having another source of clocked pulses, I'm using my Arduino to interrupt itself: I've got pin 2 (PCINT0) hooked to pin 8 (PortB.0), with a pull up.
On the hardware, this works fine, but I'm not sure how to set up the simulation.
I'd also like to be able to use a push-button as a trigger, but that doesn't work even if I set it up (active high/low, hooked to INT0 pin).
See attached, sorry if it's over complicated.
Self-Triggered Interrupts
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Self-Triggered Interrupts
Hello,
Here is an example of shorting two pins together in the simulation.
Using the project explorer I created a macro for the PinChange event in the events tab.
I then created two single digital pin properties to allow me to select which pins will be shorted together.
In the PinChange event macro I then copy the value from pin1 to pin2 using a calculation icon.
If you run the simulation you will see clicking the switch on pin A0 lights the LED on pin A1.
Regarding the INT0 switch. Did you wire up your switch like this? i.e. so the input voltage is pulled to the other rail when the switch is not pressed.
The 1K resistor is not strictly needed but the 10K is. If you don't have the 1K and configure the pin as an output then there is a chance the pin will be damaged when you press the switch.
Here is an example of shorting two pins together in the simulation.
Using the project explorer I created a macro for the PinChange event in the events tab.
I then created two single digital pin properties to allow me to select which pins will be shorted together.
In the PinChange event macro I then copy the value from pin1 to pin2 using a calculation icon.
If you run the simulation you will see clicking the switch on pin A0 lights the LED on pin A1.
Regarding the INT0 switch. Did you wire up your switch like this? i.e. so the input voltage is pulled to the other rail when the switch is not pressed.
The 1K resistor is not strictly needed but the 10K is. If you don't have the 1K and configure the pin as an output then there is a chance the pin will be damaged when you press the switch.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Self-Triggered Interrupts
In trying to reproduce this, I can't see how to define the Pin Properties.
Ah! For those in a similar situation, here's what I tried:
-------------
Panel properties (i.e. click where buttons and lights etc are displayed, but NOT on any specific device.
Then back in the main window, click "properties" on the panel, where info on a particular component would typically be. Properties are there under "component" which is simply "panel". There you can add new, and "single digital pin" is on the list.
--------------
This wasn't working, and now it is. I'm not quite sure why yet. It seems like the macro is getting called, I have a debug variable which increments... but the INT0 pin-transition interrupt isn't triggering as it should?
Find updated version attached.
Thanks! I'm certainly making progress here. If there's documentation that better covers how to do this, please point me that way, and sorry for not finding it on my own.
-Abe.
P.S. Interface suggestion, though perhaps better saved until I know how to actually make it work: I'd suggest putting that as a button with Inputs and Outputs, etc. It'd seem to make the flow more uniform, it's the first place I looked, after trying to "add new" property, since in the file you posted it lists under "global" it would be nice to be able to add "properties" there for things like this, the same way I would a variable?
Ah! For those in a similar situation, here's what I tried:
-------------
Panel properties (i.e. click where buttons and lights etc are displayed, but NOT on any specific device.
Then back in the main window, click "properties" on the panel, where info on a particular component would typically be. Properties are there under "component" which is simply "panel". There you can add new, and "single digital pin" is on the list.
--------------
This wasn't working, and now it is. I'm not quite sure why yet. It seems like the macro is getting called, I have a debug variable which increments... but the INT0 pin-transition interrupt isn't triggering as it should?
Find updated version attached.
Thanks! I'm certainly making progress here. If there's documentation that better covers how to do this, please point me that way, and sorry for not finding it on my own.
-Abe.
P.S. Interface suggestion, though perhaps better saved until I know how to actually make it work: I'd suggest putting that as a button with Inputs and Outputs, etc. It'd seem to make the flow more uniform, it's the first place I looked, after trying to "add new" property, since in the file you posted it lists under "global" it would be nice to be able to add "properties" there for things like this, the same way I would a variable?
- Attachments
-
- RPM_Decision.fcfx
- (24.05 KiB) Downloaded 280 times