pulse duration measurement with flowcode

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

Moderators: Benj, Mods

User avatar
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: pulse duration measurement with flowcode

Post by Benj »

Hello Pravat,

Thanks for the C file I will have a look and investigate for you. Had a quick look and nothing is jumping out at me.

Flowcode for AVR is compatible with WINAVR as that is what Flowcode uses. Make sure you include the internals file in your AVR studio project.

Hello Echase,

Timer 1's duration really depends on the clock source but I doubt you will be able to get 10 seconds with a single count cycle, What would be better would be to use a timer with a fast interrupt rate and then use this as your base time period and simply count the number of interrupts you require before continuing.

The interrupt properties should allow you to switch to source to the external pin. If not then you will need to use C code.

The handler is the code that is ran when the interrupt is generated. When the handler is finished your program will resume where it left off.

Which version of Flowcode are you using? Timer 1 should be fully supported by default, no custom interrupts required.

No this is not how it works. The timer will increment 1 time every time the clock signal goes high and low. If you have a prescaler then the timer will divide down the number of input pulses to lengthen the counting period. The interrupt is generated when the count value rolls over from its max value to 0.

TMR 2 will have separate oscillator input pins for you to use with the LP crystal other then the main OSC1 and OSC2 pins.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Re: pulse duration measurement with flowcode

Post by echase »

Benj wrote:
What would be better would be to use a timer with a fast interrupt rate and then use this as your base time period and simply count the number of interrupts you require before continuing.

Which version of Flowcode are you using? Timer 1 should be fully supported by default, no custom interrupts required.
I guess I could use RB0/INT to interrupt every pulse to be measured and then count the number of 1mS periods in the pulse cycle using an internal clock I have already set up using TMR2. That would work up to 32 secs or even 64 if I reset the count to start at -32,000.

I am using V3. The only standard interrupt that uses TMR1 that I can see is the Port B interrupt one and there are no properties associated with this that enable me to change it to react to T1G in or change the prescalers.

pravat
Flowcode V4 User
Posts: 19
Joined: Thu Aug 05, 2010 4:47 am
Contact:

Re: pulse duration measurement with flowcode

Post by pravat »

Hi Benj,
I have certain querries regarding programming timers
(1) Can a timer based interrupt be enabled from di1 and disabled from di2?
(2) Can a interrupt be used more than once in the program after disabling the first time.
(3) if the answer is yes then is the handler code section to be modified for the number of times the same interrupt is called?

please help me out in this case
with regards
pravat :?

User avatar
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: pulse duration measurement with flowcode

Post by Benj »

Hello Pravat,

1) di1, di2? Can you explain.

2) Yes you can use an interrupt more then once. You however cannot make the interrupt call different macros when you re-enable it. The first macro is always the one that will be called by the code so if you need multiple macro functionality then add a decision to the top of the existing interrupt macro.

3) I think I answered this in 2.

pravat
Flowcode V4 User
Posts: 19
Joined: Thu Aug 05, 2010 4:47 am
Contact:

Re: pulse duration measurement with flowcode

Post by pravat »

Hello Benj
by di1 and di2 i mean digital input 1 and 2. My question is that can i enable timer0 interrupt by switch0(digital input1 high or low) and disable by switch1(digital input2 high or low) in flowcode and the same will run with flowkit.
with regards
pravat :?

User avatar
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: pulse duration measurement with flowcode

Post by Benj »

Hello,

Yes you can do that using input icons and decisions.

FlowKIT support will require the interrupt mod I detailed earlier which is also in the up coming update release of Flowcode.

pravat
Flowcode V4 User
Posts: 19
Joined: Thu Aug 05, 2010 4:47 am
Contact:

Re: pulse duration measurement with flowcode

Post by pravat »

Hi benj
can flowcode5 with flowkit work properly for this type of application because i could not use flowcode4 with flowkit for this application.

User avatar
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: pulse duration measurement with flowcode

Post by Benj »

Hello,

Yes interrupts will work with ICD in v5. You will not be able to step into the interrupt macro using the ICD but the interrupts will work ok and not cause issues alongside the ICD main program loop.

pravat
Flowcode V4 User
Posts: 19
Joined: Thu Aug 05, 2010 4:47 am
Contact:

Re: pulse duration measurement with flowcode

Post by pravat »

then i will wait for the flowcode which can handle interrupt macros with flowkit because in this case too the interrupt macros canot be debugged hence the overall behaviour of the processor can not be observed. :D
with regards
pravat

Post Reply