Author Topic: Input hexadecimal???  (Read 36351 times)

Ebby

  • Guest
Input hexadecimal???
« on: January 11, 2017, 08:51:44 PM »
Hi guys
We added load cell digitizer to the canbus line and displaying it on the screen. But the data that comes to the display is not correct.
For example in IFM we can get the no: 0.0126290 for unload load cell and when we put the 74kg on load cell the no. changed to 0.020848 and with the loadfactor 2500 :
0.0126290*2500=31.5725
0.0420848*2500=105.212
105.212-31.5725=73.6395

But in the Danfoss display unit 0.0126290 shows 3184174205 .
In the IFM program there is a Pointer function that can point to any data type or function block even to user-defined types. But  in plus one we cannot find it????

Offline jashom1

  • PLUS+1 Expert
  • ****
  • Posts: 80
  • Karma: +6/-0
Re: Input hexadecimal???
« Reply #1 on: January 11, 2017, 09:31:40 PM »
Hi Ebby,

Have you considered that the result that you are receiving on the CAN data could be a float?

Danfoss don't really do floats, but it is possible to make your own float to real number conversion.  I converted the data you were seeing (3184174205) into a float which gave me -0.0989465489983559 if that helps at all?

Cheers,

John.

Ebby

  • Guest
Re: Input hexadecimal???
« Reply #2 on: January 12, 2017, 12:23:21 AM »
Thanks John
could you please let me know what should I change in can input

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Input hexadecimal???
« Reply #3 on: January 12, 2017, 12:31:53 AM »
As Jashom said you cannot do floating point type numbers with  PLUS1 controllers, so that's one thing that you'll need to handle (which is pretty much as easy as just scaling down your load factor and maybe using bit shifting).  Also, is it possible that your Danfoss display isn't programmed to correctly unpack the data?  Double check which bytes you're combining, what order they're in, and what the scaling/offset is.

On that image you posted the red crosses indicate that those lines aren't actually connected, so that won't compile.  Ebby, we'd need technical documents on your sensor to say for sure if that looks correct.  Also, it seems weird that what I think are your first two bytes are S8 data type while 2 and 3 are U8 (and 4 - 7 are U16?).  I'd double check your data typing.
Controls Engineer
Hydra-Power Systems

Ebby

  • Guest
Re: Input hexadecimal???
« Reply #4 on: January 12, 2017, 09:46:13 PM »
I found Call POU block in the controller section and I am thinking should be able to point the data to the float and then real
could you please let me know is that correct and possible or not?
cheers
« Last Edit: January 12, 2017, 10:11:07 PM by Ebby »

Offline Marbek_Elektronik

  • PLUS+1 Guru
  • *****
  • Posts: 352
  • Karma: +8/-0
    • Marbek Elektronik
Re: Input hexadecimal???
« Reply #5 on: January 14, 2017, 10:27:17 AM »
Hello Ebby,
about your first picture 1. jpg:

Please consider the data format: you can't compine S8 with S8  to S16, and S16 with S16 to S32.
I didn't try it. But it can't work.

The data from Can bus is at first U8
Then you can combine U8 with U8 to U16, and U16 with U16 to U32.
Marbek Elektronik, Dipl.-Ing. Bernd Konrad
Dienstleistung, Entwicklung, Herstellung

Ebby

  • Guest
Re: Input hexadecimal???
« Reply #6 on: January 16, 2017, 08:49:09 AM »
The data is sent by load cell digitiser as a can message in mV per volt and is a float (eg. 0.0420848 ) and received by RX
I am trying to implement some code we found for "FLOAT TO INT"  as attatched. We can see all raw data at checkpoints up until the FLOATTOINT  function block but nothing after.
We have come a long way in the last month with PLUS1 but this one has us really stuck.
Any input at all is very much appreciated.


Offline jashom1

  • PLUS+1 Expert
  • ****
  • Posts: 80
  • Karma: +6/-0
Re: Input hexadecimal???
« Reply #7 on: January 17, 2017, 12:28:00 AM »
Hi Ebby,

I am assuming that you mean you are getting nothing that you are getting zero back from trying to convert a float of 0.0420848

That block will only give you the integer part of the float (which is zero), and not the fraction part which is what you want.

This website will give you some understanding on floats, but they definately mess with my head trying to convert them to real numbers, which would be nice if Danfoss could supply a block that would return an integer from a float with some nice resolution, say multiplied by 10000, or even a configurable resolution  ;)

https://www.h-schmidt.net/FloatConverter/IEEE754.html

Sorry I haven't got any good news for you!

John.

Offline jashom1

  • PLUS+1 Expert
  • ****
  • Posts: 80
  • Karma: +6/-0
Re: Input hexadecimal???
« Reply #8 on: January 17, 2017, 04:27:59 AM »
Second thoughts, you can actually get some good resolution if you use the float multiply block, and multiply the float before converting it to a real number.  You just have to be careful of over flowing.





Cheers,

John.


Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Input hexadecimal???
« Reply #9 on: January 17, 2017, 06:53:42 PM »
Ebby, you're correct that within the Call POU (Structured Text) block you can do floating point aka real data types.  However, you cannot output that data type, so you will have to convert back to some type of integer if that signal needs to go back outside of the Call POU.
Controls Engineer
Hydra-Power Systems

Ebby

  • Guest
Re: Input hexadecimal???
« Reply #10 on: January 18, 2017, 01:54:08 AM »
Well it seems we have a winner. Jashom1 has solved it. thankyou all so much for your time and input.Next is to get RS232 direct from display to printer.
See you all on the forums and thanks again

Offline sverreo

  • PLUS+1 Developer
  • ***
  • Posts: 21
  • Karma: +1/-0
Re: Input hexadecimal???
« Reply #11 on: November 30, 2023, 11:22:15 PM »
Dose anyone have the "float multiply block" that @jashom1 posted an image of in this thread?

Offline acmall

  • PLUS+1 Guru
  • *****
  • Posts: 201
  • Karma: +37/-1
Re: Input hexadecimal???
« Reply #12 on: December 01, 2023, 08:54:40 AM »
There is a block in the Utility FB Library called IEEE_754 which it states is for converting from IEEE_745 floating point representation to a fixed point notation if that helps.

You can install the Library from the Plus+1 Update Centre where it is listed as Utility Library 70380479

Offline sverreo

  • PLUS+1 Developer
  • ***
  • Posts: 21
  • Karma: +1/-0
Re: Input hexadecimal???
« Reply #13 on: December 01, 2023, 09:28:52 PM »
Cheers acmall, i didn't know it was there :)

I tested it a bit, and it seems i need to make some logic if the first decimal after the point (right side) is "0", then it gets lost in this function and the first decimal >0 is displayed...

Offline acmall

  • PLUS+1 Guru
  • *****
  • Posts: 201
  • Karma: +37/-1
Re: Input hexadecimal???
« Reply #14 on: December 04, 2023, 09:07:08 AM »
Hi sverreo, I can't help with the details as I have not used it. I just remembered seeing it in the library.