I have working RS485 network with PIC microcontrollers (master + 6 slaves). I intend to replace master with some hardware where LabVIEW would be installed. I already managed to put together test vi on PC with USB-FTDI-RS485 WE adapter, which is capable to communicate with one slave. Slave is responsible for meassuring of the consumption of electric energy and watter in my house.
The problem is in converting of recived data in byte array form to float form, it is not accurate enough. Attached picture shows which bytes aro for each varible and also shows what is correct values for kWh as also for m3. Please check also part of the vi, where converting take place. Jus have in mind that Microchip has diferent IEEE754 standard, where sign bit is shifted with exponent for one place.
Any suggestion or advice would be very appreciated.
Solved! Go to Solution.
Can you make a small example that contains the 2D array as default data (e.g. as a diagram constant) and the desired result. Looking at your big code gives me a hadeache (a severs case of sequenceitis and localitis ) and since we don't have you device, we cannot run it.
Conversion code seems a bit circuitous. Are you sure it is sound?
It seems you are using all bits, so how much more accurate are you expecting to get?
when you use a tool which outputs non-standard numbers you should provide a manual with a good (!) description of that numeric format!
The standard way of typecasting 4 bytes to a SGL does not work with your example data:
(Using Reverse1DArray to swap byte order doesn't yield in an expected result, too.)
USB adapter link: http://www.ftdichip.com/Products/Cables/USBRS485.htm
Their code sample was modified step by step to version 5 with help of some discusions from this forum.
Would you be so kind to change attached vi (your idea) and post it back so I can test it.
That link is just the USB to RS-485 converter. It has nothing to do with the actual data you are transmitting. How your floating point data is being encoded as 4 bytes on the PIC device you are communicating with is what matters.
Previous post was reply to Altenbach.
This one is reply to GerdW.
Sorry, you are right. Not enough informations from my side.
So, this is not standard IEEE754 conversion, where from MSB side first bit is sign bit, then eight bits for exponent and the rest of 23 bits for mantissa. Instead of this it is used Microchip conversion where from MSB side eight bits are used for exponent, then one bit for sign and rest of 23 bits same as before for mantissa. That's mostly all about my problem.
By the way, I am not a specialist in LabView.
Reply to RavensFan.
On PIC (slave) side variable is converted to byte array of 4 bytes.
RS485 transfer protocol: Master send to slave message of 8 bytes with slave addres and command for slave for respond. Slave compare addres and respond to master with it's status (first line of 8 bytes on the picture). Then master send new commnd for each byte of the variable. Becouse we have two variables (each contain 4 bytes) we have to repeat this proces 8 times.
File with precised description of this communication is attached, which is made by software "Serial Port Monitor" .
California_J wrote: Instead of this it is used Microchip conversion where from MSB side eight bits are used for exponent, then one bit for sign and rest of 23 bits same as before for mantissa.
Then this should work for you once you get the 4 bytes.
Hello crossrulz, would you be so kind to attach your vi here, becouse I have no idea how to build it.
That is a Snippet! Drag it to your LabVIEW block diagram to import the code directly.
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'