multi input - single output %correlated

hi everybody!
i am experimenting a dificulty trying do something that i can't find any solution

i am trying to get a pwm output vary from a multiple of input but not only with fixed percentage
value from each other, example :

analogue input 1 : input 0 -5v but count for 10% of total output
analogue input 2 : input 0- 5v but count for 25% of total output
analogue input 3 : input 0 -5v but count for 45% of total output
analogue input 4 : input 0 -5v but count for 55% of total output
analogue input 5 : input 0 -5v but count for 35% of total output
analogue input 6 : input 0 -5v but count for 20% of total output
digital input read : input i-o but count for -45% of total output
digital input read : input i-o but count for -25% of total output

and most dificult to do for me its when another digital input read is activated
by a momentary shitch the mapping is only depended a 100% from 1 analogue input
and if you clic again its returning to the multi input mapping

i have already try a solution but i am pretty sure i am in the wrong way !!

const int analogInPin0 = A0;  
const int analogInPin1 = A1;
const int analogOutPin = 9; 
const int automanu = A3;
const int hbk = 2;

int sensorValue0 = 0;        
int sensorValue1 = 0;
int outputValue0 = 0;       
int outputValue1 = 0;
int outputValue2 = 0;
int sensorValue2 = 0;


void setup() {
  
  Serial.begin(9600); 
}

void loop() {
  
  sensorValue0 = analogRead(analogInPin0);
  sensorValue1 = analogRead(analogInPin1); 
  sensorValue2 = analogRead(automanu); 
  
  outputValue0 = map(sensorValue0, 0, 1800, 0, 255);  
  outputValue1 = map(sensorValue1, 0%1, 2046%50, 0%1, 255%50);
  outputValue2 = map(sensorValue2, 0, 2046, 0, 255);
  
  analogWrite(analogOutPin, outputValue0 + outputValue1); 
  
 if (sensorValue2 > 1)
  analogWrite(analogOutPin, 0);
   

  
  Serial.print("sensor = " );                       
  Serial.print(sensorValue0 + sensorValue1); 
  Serial.print("\t output = ");      
  Serial.println(outputValue0 + outputValue1 - outputValue2);   
  Serial.print("automanu = " );
  Serial.print(sensorValue2);

  
  delay(50);                     
}

i am gonna put you in situation
this is for a transmition controller for a car !!
i need several input like : throttle position , boost pressure , potentiometer input, 2 axis accelerometer, hand brake,
foot brake, switch to activate or deactivate.
the output is controlling a 70amp mosfet to put powerr into the transmition for 4wd control
i have already tested the board and this simple programation its working fine but i think i am gone in the wrong way of programing the good way

if you can suggest me a way of programing this i will be very happy
thank you

analogue input 1 : input 0 -5v but count for 10% of total output
analogue input 2 : input 0- 5v but count for 25% of total output
analogue input 3 : input 0 -5v but count for 45% of total output
analogue input 4 : input 0 -5v but count for 55% of total output
analogue input 5 : input 0 -5v but count for 35% of total output
analogue input 6 : input 0 -5v but count for 20% of total output
digital input read : input i-o but count for -45% of total output
digital input read : input i-o but count for -25% of total output

So, when the multi-input mode is operational, the various inputs are responsible for 260% of the output. How does that work? The %ages need to add up to 100%.

At the refinery I worked at we had several PID control loops that would have multiple inputs combined to become the input signal (process variable) for the PID controller. However in all cases one of the signals was considered the primary (or master input measurement, and the other inputs were only allowed to modify that value a fixed +/- percentage. These 'secondary' signal measurements were said to bias the primary input measurement to make up the composite input signal. Don't know if that applies or helps for your application or not, but there it is. :wink:

Lefty

It sounds like you are trying to create a weighted average.

To do that you assign a weight for each input. It could be the 'percentage' figures you listed. Multiply each input by its weight and add the results together, divide that by the sum of the weights. The result is the weighted average.

PaulS

the total do not need to be 100% beacause the maximum is 100% already!
some factor may induce a 100% of total example
i am cruising speed at 100km/h
so i have a 5% load with throttle maybe 15% on the trimm potentiometer
the rest still at zero
then im am flooring it ( tps ramp up with a filling 25% plus the accelerometer 45% boost comming un to the 15%
the rest still at zero even with all other factor comming up i dont care i need it to be at 100% at this moment
and for the digital input read i need to be minus %ages

retrolefty

that is a pretty good solution for my problem
i need something like that beacause the trimm potentiometer sould be a master solded at 100%
and coul be considered as a master trimm and all the other input could be aswell considered as secondary input
!!!!! i very interested by your solution

PeterH

as i need to consider all input '' not equal to 100% '' could this solution can be used ???
beacause if i do an average i could not assign a +value to each input more than the average total ....
it could be a problem .....!!

qpwerx:
PeterH

as i need to consider all input '' not equal to 100% '' could this solution can be used ???
beacause if i do an average i could not assign a +value to each input more than the average total ....
it could be a problem .....!!

Yes, it works fine. It doesn't matter whether your weights are 1, 2, 3, 4 or 10, 20, 30, 40 and it doesn't matter what they add up to.