IR sensor exponential response

For Formula AllCode users to discuss projects, programs, and any other issues related to the Formula AllCode robotics platform.

Moderators: Benj, Mods

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

IR sensor exponential response

Postby sundgau » Mon Jan 20, 2020 11:57 am

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
Attachments
Formula AllCode API_V2.fcpx
(337.72 KiB) Downloaded 35 times
Formula AllCode API_V2.fcfx
(15.29 KiB) Downloaded 38 times

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: IR sensor exponential response

Postby Benj » Mon Jan 20, 2020 12:34 pm

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.

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: IR sensor exponential response

Postby sundgau » Mon Jan 20, 2020 1:14 pm

I'm on flowcode7. Thank you so much!

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: IR sensor exponential response

Postby Benj » Mon Jan 20, 2020 1:56 pm

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.06 KiB) Downloaded 44 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.

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: IR sensor exponential response

Postby sundgau » Mon Jan 20, 2020 2:15 pm

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 ...

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: IR sensor exponential response

Postby Benj » Mon Jan 20, 2020 2:19 pm

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?

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: IR sensor exponential response

Postby sundgau » Mon Jan 20, 2020 2:24 pm

maybe "unlock"...
Attachments
Screen Shot 01-20-20 at 02.22 PM 001.PNG
Screen Shot 01-20-20 at 02.22 PM 001.PNG (19.86 KiB) Viewed 3355 times
These users thanked the author sundgau for the post:
Benj (Mon Jan 20, 2020 2:25 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: IR sensor exponential response

Postby Benj » Mon Jan 20, 2020 2:25 pm

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 3352 times

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: IR sensor exponential response

Postby sundgau » Mon Jan 20, 2020 2:34 pm

Ok, FA component appears as a white square with my file but i can't add the formula allcode API component
Attachments
Screen Shot 01-20-20 at 02.29 PM.PNG
Screen Shot 01-20-20 at 02.29 PM.PNG (8.6 KiB) Viewed 3351 times

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: IR sensor exponential response

Postby sundgau » Mon Jan 20, 2020 2:49 pm

My version of flowcode is 7.3.0.7 and I am using the update of the formula flowcode API component obtained here:
https://www.matrixtsl.com/mmforums/viewtopic.php?f=41&t=21574

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: IR sensor exponential response

Postby Benj » Mon Jan 20, 2020 2:49 pm

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 35 times

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: IR sensor exponential response

Postby sundgau » Mon Jan 20, 2020 3:40 pm

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

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: IR sensor exponential response

Postby Benj » Mon Jan 20, 2020 5:07 pm

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

sundgau
Posts: 66
Joined: Mon Sep 26, 2011 4:18 pm
Has thanked: 5 times
Been thanked: 10 times
Contact:

Re: IR sensor exponential response

Postby sundgau » Tue Feb 18, 2020 3:28 pm

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
Attachments
chart1.png
chart1.png (8.41 KiB) Viewed 2921 times
chart2.png
chart2.png (8.38 KiB) Viewed 2921 times