petsi - I have create this node-red flow. It ta...

I have create this node-red flow. It takes the AWA and put it again on the flow with a smooth path. It works with negative and positive values. anybody can try this flow and sayme if it works fine?
22 Replies
Teppo Kurki
Teppo Kurki2y ago
It will not work very well dead downwind when awa alternates from side to side
petsi
petsiOP2y ago
how I have to change the function to work?
petsi
petsiOP2y ago
ok, i think that now is ok
Teppo Kurki
Teppo Kurki2y ago
you could optimise it so that sin and cos is calculated once for each input. now they are called every time there is new input for all the old values
petsi
petsiOP2y ago
Ok, something like this?
Teppo Kurki
Teppo Kurki2y ago
I don't think that works - for each new wind value you get a new message object hmm, i just looked at the json, did not put this in node-red, so i may be mistaken... anyway, convert the angle first to [sin, cos], then keep a window buffer of them, then calculate the average by summing the sin and cos values
Henry
Henry2y ago
Following this thread with interest. Actually the maths for Yamartino’s method isn't too bad (sin, cos, sum and arctan). https://www.flyingcoloursmaths.co.uk/dictionary-of-mathematical-eponymy-yamartinos-method/ Plus this buffer array looks useful https://flows.nodered.org/node/node-red-contrib-buffer-array
petsi
petsiOP2y ago
I understand the method, I understand how it works but I don't know how to make it work with node red. I'm using chat gpt for create the instructions and I know why it don´t work, I'm not able.
Henry
Henry2y ago
Managed to get a process that seems to work. Is all in radians, but working on a KIP dashboard too. Is a buffer/array of 10.
No description
Teppo Kurki
Teppo Kurki2y ago
looks good to me! i actually managed to create a prototype for a standalone plugin that does this, see https://discord.com/channels/1170433917761892493/1240386036757168168
Henry
Henry2y ago
Plugin looks useful. Was useful too to actually practice/learn some signalk to get this working, so pleased I've had the practice.
petsi
petsiOP2y ago
Could you share the node red flow?
Henry
Henry2y ago
Will try and go onboard tomorrow and get a copy. Actually found an error in the arctan calculation over the weekend, but fixed bown
petsi
petsiOP2y ago
Thank you. I'm waiting and reading
Henry
Henry2y ago
This is the JSON BUT you need to edit the arctan function. Should be x,y not x/y
petsi
petsiOP2y ago
something like this? var apparentSin = msg.payload.angleApparentSIN var apparentCos = msg.payload.angleApparentCOS msg.payload = Math.atan(apparentSin) / Math.atan (apparentCos); return msg;
Henry
Henry2y ago
petsi
petsiOP2y ago
I have made an update of your code. I used at the start a input hgandler and a input handler next node and change the topic to environment.wind.angleApparent
petsi
petsiOP2y ago
Wind speed Apparent to wind speed apparent smooth. I use this flow to use with smooth polar performance plugin. with 5 average values gives good performances. what do you think about it? it's ok?
Henry
Henry2y ago
I think I took something like 10 but same principle.
petsi
petsiOP2y ago
And the same with yaw, pitch and roll

Did you find this page helpful?