Page 1 of 1

IR sensor exponential response

Posted: Mon Jan 20, 2020 11:57 am
by sundgau
Hello Benj,

I am currently working on the infrared sensor of the allcode.
In simulation, the response is linear and responds to the equation: IR = 4290-3*distance.

In practice, the answer is of exponential type and responds to an equation IR = 4890 * exp (-0.57 * distance), then I modify my program with a macro in which I call the macro simulation readIR:
.lecture_UINT = FormulaAllCode :: Read (.I)

and I convert the value using the following code:
.lecture_float = .lecture_UINT
.lecture_float = (-0.00333 * .lecture_UINT) + 14.3
.lecture_float = 4890 * exp ((-0.57 * .lecture_float))
.lecture_string = FloatToString $ (.lecture_float)
.lecture_UINT = StringToInt $ (.lecture_string)
.Return = .lecture_UINT

Could we have in the properties of the API the possibility of having the right equation and the parameters A and B of the exponential equation: A * exp (B * distance) configurable?
Simultaneous would allow to obtain results close to reality and to be able to compare the simulation and the measurements.

I tried to create a new model based on "FormulaAllCode API" but without success ... Can you see where the problem is?

thank you in advance

Bruno

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 12:34 pm
by Benj
Hi Bruno,

That's brilliant thanks for letting us know and yes I will certainly add this feature for you. What version of Flowcode are you currently using, just so I add the feature into the correct version.

Not sure what has gone wrong with your attempt, I'll investigate what might be the cause.

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 1:14 pm
by sundgau
I'm on flowcode7. Thank you so much!

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 1:56 pm
by Benj
Right I've made the changes you suggested and hopefully this will now do as you want. The default is the standard linear mode but if you change the property to exponential then it should allow you to enter A and B values. I've also added the initial calculations you mentioned but not made these configurable. Let me know how you get on and if it's working nicely I'll roll out the change to v8 too.
FormulaAllCodeP4.fcpx
(336.05 KiB) Downloaded 290 times
You might want to backup your component file first just in case I've happened to break anything :wink: It can happen especially in a component like this where it builds on a lot of other components.

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 2:15 pm
by sundgau
sorry but the component no longer appears in the components bar, nor in the search bar.
I unlocked the file, put it in the "components" directory and restarted Flowcode ...

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 2:19 pm
by Benj
Hello,

Hmm. It seems to be working well for me here. I'll do some checking.

Can you say what you mean by:
I unlocked the file
Do you mean downloaded?

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 2:24 pm
by sundgau
maybe "unlock"...

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 2:25 pm
by Benj
Aha ok thanks.

I tried your program again and the FA component appears as a white square but it does have the new property.

Adding the component again from the menu allows it to work. Hmm odd.

Can you create a new program and does it appear then?
Error.jpg
Error.jpg (44.41 KiB) Viewed 14256 times

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 2:34 pm
by sundgau
Ok, FA component appears as a white square with my file but i can't add the formula allcode API component

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 2:49 pm
by sundgau
My version of flowcode is 7.3.0.7 and I am using the update of the formula flowcode API component obtained here:
viewtopic.php?f=41&t=21574

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 2:49 pm
by Benj
Hmm,

I only edited the standard component, didn't have to touch the API version of the component?

Here's the API version atm.
FormulaAllCodeAPI.fcpx
(73.89 KiB) Downloaded 296 times

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 3:40 pm
by sundgau
great!

I still have two questions
Does the "IR simulation mode" parameter also work with line following sensors or only with distance sensors?

What documents, video or tutorial help you understand how to modify a component such as the "Formula AllCode API" knowing that this component can be linked to a "Formula AllCode RB4420" or to a "Bluetooth port" and that To do this, you must be able to configure the "API Target Method" parameter?

thank you so much

Re: IR sensor exponential response

Posted: Mon Jan 20, 2020 5:07 pm
by Benj
Hello,
Does the "IR simulation mode" parameter also work with line following sensors or only with distance sensors?
For now I have only edited the simulation IR distance sensors and not touched the IR line sensor values.
What documents, video or tutorial help you understand how to modify a component such as the "Formula AllCode API" knowing that this component can be linked to a "Formula AllCode RB4420" or to a "Bluetooth port" and that To do this, you must be able to configure the "API Target Method" parameter?
The main source of information is our user Wiki, it's not 100% and there are likely holes but we do try and improve it all the time.

This is the current WIKI
https://www.matrixtsl.com/wiki/index.ph ... Components

And here is the v7 version,
https://www.matrixtsl.com/wikiv7/index. ... Components

For each property, macro and parameter in a component we try and write a helpful and meaningful tooltip which is then automatically added to the wiki page. Again there is always room for improvement here as things that may be obvious to us are not always the same for our users. It's largely only obvious to us because we have created the functionality.

Some of these v8 pages may be useful for you in terms of making and customising components.
https://www.matrixtsl.com/wiki/index.ph ... t_Creation

Re: IR sensor exponential response

Posted: Tue Feb 18, 2020 3:28 pm
by sundgau
Hello, back for a second modeling of IR sensors.
First of all, a small modification concerning the exponential type equation: the equation which is best suited for a distance range from 15mm to 170mm is rather N = 2991 * exp (-0.04 * d) with d in mm. The coefficient of determination R² is 0.957.
(I had given you an equation with d in cm the last time, the equation should have been R = 4890 * exp (-0.057 * distance)) and not R = 4890 * exp (-0.57 * distance))

I have just used a second type of trend curve which corresponds even better: N = 806462 * d ^ (- 2.05). In this case, R2 = 0.991.

Will you be able to:
- correct the previous model for flowcodeV7: modification from cm to mm and default value of A and B: (N = A.exp (B.d)).
- Include a new IR simulation mode (POWER) with two parameters A and B: (A.d ^ B).

The Allcode simulation will be more accurate on a 3D route and will correspond much better on a real parourd. The choice of equations will allow us to adapt to all situations of range measurement.
I hope I didn't make a mistake this time!
Thank you so much.
Bruno

Re: IR sensor exponential response

Posted: Tue Dec 14, 2021 11:28 am
by sundgau
Hello,
I am now using Flowcode V9 and I have just noticed that there is no possibility to choose the IR sensor simulation mode.
Screen Shot 12-14-21 at 11.17 AM.JPG
Screen Shot 12-14-21 at 11.17 AM.JPG (28.82 KiB) Viewed 7472 times
The simulation on flowcode V7 gave excellent results to within 1mm. The measurements in real life also gave a rangefinder with an accuracy of 1mm over a distance of 15cm...

Can you put this option back on Flowcode V9 so that I can resume this work with my students?
Thanks in advance.

Bruno

Re: IR sensor exponential response

Posted: Tue Dec 14, 2021 4:07 pm
by Benj
Hello Bruno,

Many thanks for letting us know. It must have been missed in the v8 and v9 updates. I've now added it back into the v9 component for you. You can get the latest version of the component by clicking Help -> Library Updates.

Re: IR sensor exponential response

Posted: Wed Dec 15, 2021 4:50 pm
by sundgau
Thank you very much Benj.
I love this Formula allcode and your responsiveness with Flowcode V9
Best regards

Bruno