03-15-2021 11:10 PM
Shift it 12 bits (-12) rather than 8.
But what data are you dealing with that is 2-1/2 bytes. (5 nibbles or 5 hex digits) ????
03-16-2021 02:17 AM
Hi RavensFan,
@RavensFan wrote:
But what data are you dealing with that is 2-1/2 bytes. (5 nibbles or 5 hex digits) ????
The encoder might output 20 bits of useful information.
The manual calls it "left aligned", I didn't understand that term until now…
03-16-2021 03:05 AM
Hi GerdW,
I have managed to convert the Hexademical values into angle (1-360) in decimal format.
However, when I rotate my encoder, the sum data which leads to angle displayed is incorrect and I have to stop and start to get the correct angle reading.
Do you know what's the issue? I have attached a screen recording as well.
Thanks.
Regards,
Ryan
03-16-2021 03:18 AM
@GerdW wrote:
Hi wiebe,
why do you use "AND 8" to get the status? I would use "AND 255" instead…
🌴😀 (:palmface:)
Yes, 255 is much better.
03-16-2021 03:21 AM - edited 03-16-2021 03:32 AM
Hi Ryan,
did you read the manual and do you understand how your encoder is working?
As I understood that manual you are reading absolute encoder positions. To get an angle you need to subtract a previous position from the current position to get the angle between both positions…
(I might be wrong, but that's how I understand it.)
Btw. why do you read 36 bytes from your encoder when the manual mentions just 4 bytes as response to the "3" command?
03-16-2021 03:46 AM
@Ryan777 wrote:I have managed to convert the Hexademical values into angle (1-360) in decimal format.
However, when I rotate my encoder, the sum data which leads to angle displayed is incorrect and I have to stop and start to get the correct angle reading.
Do you know what's the issue? I have attached a screen recording as well.
Thanks.
I'd toss in a Quotient & Remainder.
03-16-2021 04:13 AM
Hi GerdW,
I was testing out the V command which requires 36 bytes earlier, hence the 36.
Thank you so much for your help! I will continue to work on it!
Regards,
Ryan
03-17-2021 09:24 PM
Hi,
I am currently trying to export data from my indicator into an excel file. However my data hangs and repeat at the first reading and any rotation to my encoder does not do anything and the values will remain the same.
Anyone has idea where it might have went wrong? Thanks.
(The repeating and hanging of my encoder only comes in after I try to export the data)
Regards,
Ryan
03-18-2021 02:05 AM
Hi Ryan,
again you forgot to attach real code instead of just images…
@Ryan777 wrote:
I am currently trying to export data from my indicator into an excel file. However my data hangs and repeat at the first reading and any rotation to my encoder does not do anything and the values will remain the same.Anyone has idea where it might have went wrong? Thanks.
(The repeating and hanging of my encoder only comes in after I try to export the data)
You don't create "an Excel file", you create a simple formatted text file, also known as CSV…
How does your data "hang"?
When this "hang" only starts after including the WriteSpreadsheetFile function in the loop then this function probably is too slow and so influences the serial port readings. Have you tried to implement a producer-consumer scheme instead?
Have you tried to use faster file functions like WriteTextFile? Using this (with OpenFile before the loop) you don't need to open/close the file in each iteration!
03-18-2021 02:22 AM
Hi GerdW,
Thanks for taking the time to reply.
No I have not tried to implement a producer-consumer scheme yet (searched it up but not sure how do you connect it up)
I will try out the WriteTextFile function! Thanks!
Regards,
Ryan