Any strange behaviour, crashing issues etc, post them here! Problems compiling the firmware should go in the General support section rather than here
#32373
In the firmware (2019-02 in this case), look in maths.ino at lines 77 to 83:
Code: Select all
//Return x percent of y
//This is a relatively fast approximation of a percentage value.
unsigned long percentage(byte x, unsigned long y)
{
  return (y * x) / 100; //For some reason this is faster
  //return divu100(y * x);
}

this is correct ONLY IF y is 100, otherwise it is wrong.

what I suggest is:
Code: Select all
//Return x percent of y
//This is a relatively fast approximation of a percentage value.
unsigned long percentage(byte x, unsigned long y)
{
  return (y * x) / y; //For some reason this is faster
  //return divu100(y * x);
}

As i say, this is true only when the 'Y' value does not equal 100.
I see this function is used quite a lot in the code so i doubt Y is 100 every time!

What do you think? I will update my benchtop arduino in work tomorrow and see how it 'runs' when pulsed with my arduStim.

thanks
#32374
I'm not sure if I need more coffee, if I'm simply not understanding you or if this is doing something totally different to what you think...

As the comment indicates, the function returns the value of x% of y. Eg if x=50 and y=700, the return value should be 350 (50% of 700 is 350).

Your version of the function would return always just return the value of x because:
Code: Select all
(x * y) / y = x
MAP LOOKUP & TS DEFINITIONS

See how the write commands use the identifiers to […]

Ok, I feel so stupid. I was running the Uno output[…]

Let's all have a laugh for second. There's trash[…]

It has been done more than a few times, there was […]

Still can't find what you're looking for?