Welcome, Guest
Username: Password: Remember me

TOPIC: Modbus RTU tutorial

Re: Modbus RTU tutorial 6 years 7 months ago #9098

  • brunad
  • brunad's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 247
  • Thank you received: 48
  • Karma: 11
Hi.

At I1, you put a 32 bits int=-2147407768

Take a look at the formulae:


int32bitToEU.png


/Bruno
Last Edit: 6 years 7 months ago by brunad.
The administrator has disabled public write access.

Re: Modbus RTU tutorial 6 years 7 months ago #9099

  • ceccon
  • ceccon's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 46
  • Karma: 0
Hello Bruno, sorry my pour undertand but can you please be more specific?

you mean to change I1 >> 16 to I1 >> 32 in the code?

Thanks a lot
Best Regards
The administrator has disabled public write access.

Re: Modbus RTU tutorial 6 years 7 months ago #9100

  • brunad
  • brunad's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 247
  • Thank you received: 48
  • Karma: 11
Hi Ceccon.

No, input is already an Int32.
I mean you to change calculation. Your last commented line //OA1=... was wrong, because:

It seems you want to convert as input an Int32 i.e. in the range -2^(32-1) to 2^(32-1)-1 to obtain as output a float32 range of -10.0 to +10.0

Thus (in your screen shot) an input of -2147407768 would match with a -9,999646656 output

The principle is to apply only one formulae, something like:

output= min_output+(input-min_input)/(max_input-min_input)*(max_output-min_output)

OA1 = -10+(val-(-21474883648))/(2147483647-(-21474883648))*(10.0-(-10.0));

finally:

OA1 = range_low + (I1-(-21474883648))/4294967295 * (range_high-range_low);


/Bruno
Last Edit: 6 years 7 months ago by brunad.
The administrator has disabled public write access.

Modbus RTU tutorial 6 years 7 months ago #9101

  • brunad
  • brunad's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 247
  • Thank you received: 48
  • Karma: 11
Forget this, I just understand it can't apply in your case because I just read your manual page and I saw it was unusually and uselessly much more complicated ! :sick: :sick: :sick:

Let me see what we can do :silly:

/Bruno
Last Edit: 6 years 7 months ago by brunad.
The administrator has disabled public write access.
Time to create page: 7.771 seconds