Is it possible to use arduino functions with Flowcode?

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

Moderator: Benj

Post Reply
407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Is it possible to use arduino functions with Flowcode?

Post by 407charles »

I'm been trying to developed a program to capture frequency for different projects such as speed calculations. So far, I was not able to get it going with flowcode because there is no timing functions available. I was able to do it with the arduino software but I want to take the advantage of flowcode programing. Arduino has a function called "pulseIn()" and it does capture the period of a signal no shorter than 10us and as long as 3min. this is perfect for my application. I'm wondering if there is any way to use this function with flowcode; Do anybody knows?

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: Is it possible to use arduino functions with Flowcode?

Post by Benj »

Hello,

Yes it is possible but there isn't currently a component that will do this for you out of the box.

Is the Arduino PulseIn function blocking? E.g. it doesn't return until it has seen a complete period? Or does it return instantly and therefore use a form of interrupt to do the frequency monitoring?

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: Is it possible to use arduino functions with Flowcode?

Post by Benj »

I found more info here,

https://www.arduino.cc/en/Reference/PulseIn

Should be very easy to do. I'll try and write you a quick macro to replicate the functionality.

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: Is it possible to use arduino functions with Flowcode?

Post by Benj »

Here you go, hopefully this should work fairly well.
PulseIn.fcfx
(8.11 KiB) Downloaded 337 times
Depending on the speed of your device you might need to slightly lower the 10us delay in the PulseIn macro to make things more accurate.

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Is it possible to use arduino functions with Flowcode?

Post by 407charles »

I appreciate your help, I believe is the same concept because the minimum signal it can read (the Arduino pulseIn() ) is 10 us. There is a way to get the value of the whole period? Here is my arduino program. If I can read the whole period I can read speed and distance, I did the math to display hertz (that's the easy part right?). Your program reads the time of the positive transition. how can I achieve to read the whole period? it will be great if possible. Thanks a lot again for your time and help, I really appreciated.


#include <LiquidCrystal.h>
int input=12;
int count;
int high_time;
int low_time;
float time_period;
float frequency;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup()
{
pinMode(input,INPUT);
lcd.begin(16, 4);
}


void loop() {

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Frequency Meter");
lcd.setCursor(0,1);
lcd.print(frequency);
lcd.print(" Hz");


high_time=pulseIn(input,HIGH);
low_time=pulseIn(input,LOW);


time_period=high_time+low_time;
time_period=time_period/1000;
frequency=1000/time_period;


if (time_period == 0)
{
frequency = 0;
}
delay(100);
}

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: Is it possible to use arduino functions with Flowcode?

Post by Benj »

Hello,

I have created a second macro to allow you to measure a complete period.
PulseIn.fcfx
(12.65 KiB) Downloaded 354 times

407charles
Posts: 122
Joined: Thu Jun 26, 2014 12:01 pm
Has thanked: 41 times
Been thanked: 19 times
Contact:

Re: Is it possible to use arduino functions with Flowcode?

Post by 407charles »

It's working as needed! thanks a lot for your help and support.

Post Reply