Page 1 of 1

Is it possible to use arduino functions with Flowcode?

Posted: Tue Sep 15, 2015 7:20 pm
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?

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

Posted: Wed Sep 16, 2015 4:22 pm
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?

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

Posted: Wed Sep 16, 2015 4:24 pm
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.

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

Posted: Wed Sep 16, 2015 4:37 pm
by Benj
Here you go, hopefully this should work fairly well.
PulseIn.fcfx
(8.11 KiB) Downloaded 345 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.

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

Posted: Wed Sep 16, 2015 8:15 pm
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);
}

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

Posted: Thu Sep 17, 2015 10:14 am
by Benj
Hello,

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

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

Posted: Wed Sep 23, 2015 7:43 pm
by 407charles
It's working as needed! thanks a lot for your help and support.