Page 1 of 1

Streamboolout in Code component

Posted: Mon Dec 20, 2010 11:58 am
by nkiernan
Hi,
I have been using the code component to read the signal from a PWM module. The idea being to trigger every time the pulse from the PWM is high, and the frequency of the pulses varies (prototype for an engine dyno). I haven't been able to find a way to do this using the standard components.

I have the code component working and a scope shows the output to behave as expected. I am trying to use the 'streamboolout' function to output high every time a PWM high signal is detected so this can activate a counter.

I can't get the streamboolout to output any sort of signal, the bool output symbol on the right side of the code module us just grayed out, maybe I'm using the wrong syntax. I've tried:
streamboolout = 1;
streamboolout = 0;
streamboolout = high;
streamboolout = low; etc

How do I get the code component to output using streamboolout?

Re: Streamboolout in Code component

Posted: Mon Dec 20, 2010 11:28 pm
by Exo
Hey nkiernan, Welcome to Flowstone :)

Code: Select all

streamin pwm;
streamboolout high;
streamboolout low;
streamout countHigh;
float oldpwm;

high = (pwm>0) &(oldpwm<=0); //A streamboolout should be a comparison and not an actual variable.

countHigh = countHigh+(high&1);

oldpwm = pwm;


Something like that should work..... if your still having problems then post an .fsm file of what your trying to do and I'll see if I can see where you are going wrong.

Cheers ;)

Exo

Re: Streamboolout in Code component

Posted: Tue Dec 21, 2010 11:54 am
by nkiernan
Hey Exo, thank you for the welcome. I'm enjoying the experimentation with Flowstone, but coming from Pure Data there are certain objects missing that I'd be used to. Just getting my head around the work-arounds.

Thank you for the code advise also. I've attached the scaled down .fsm file I'm working on and have added the comments in the schematic to show where I'm having problems! I'm sure its something simple I'm missing. Sorry if I'm wasting your time on trivial inquiries.

Re: Streamboolout in Code component

Posted: Tue Dec 21, 2010 10:26 pm
by Exo
Ah I see what you are doing now....

To get from stream to "green" you need the component "Mono to Float" with a "ticker 100" .

I would do the counting in code though, the code component is sample accurate where as sampling to the "green" data is limited to 100hz.

Exo

Re: Streamboolout in Code component

Posted: Wed Dec 22, 2010 9:34 am
by nkiernan
Exo, thank you for your help. That makes good sense, I'll see how I get on with your suggestion. Thanks again.