Reading PORTB to Terminal

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Re: Reading PORTB to Terminal

Postby GettinBetter » Sun Jul 28, 2019 7:08 am

Setup:
EasyPIC V7 board/ICD3/MCC
Using PIC18F45K22/8MHz or 20MHz
XC8/C90.

Whoa! Really ..it's that simple?
Ok, that's fantastic...I'll setup the encoder on my dev board today, and have a go over the coming days.
Incidentally the encoder is an Autonics EP50S8-1024-3F-P-24, & I'll be attempting to run two of them plus two PWM's for the motors from a Bosch BNO055.
Does that mean I have to create the lookup table similar to the Bournes encoder, not that I mind, I'm just thinking of available memory & speed to access that table each time.

https://res.cloudinary.com/iwh/image/upload/q_auto,g_center/assets/1/26/Autonics_Rotary_Encoder_EP50S_Series_Data_Sheet.pdf

https://www.bosch-sensortec.com/bst/products/all_products/bno055

Regards
Les
History teaches us that history doesn't teach us.
User avatar
GettinBetter
 
Posts: 43
Joined: Wed Jun 06, 2018 8:48 pm

Re: Reading PORTB to Terminal

Postby ric » Sun Jul 28, 2019 8:59 am

The EP50S8-1024-3F-P-24 outputs 1024 states as a 10 bit gray code.
If you had a EP50S8-1024-2F-P-24 instead, it would output the binary position directly.
You can google "convert gray code to binary" there are a number of code algorithms to do it.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Reading PORTB to Terminal

Postby GettinBetter » Sun Jul 28, 2019 10:06 am

If you had a EP50S8-1024-2F-P-24 instead, it would output the binary position directly.

Ah crap, oh well, I'll have to put that one down to experience...don't fancy buying them again, they were quite expensive, maybe for the next model... but well spotted.

You can google "convert gray code to binary" there are a number of code algorithms to do it.


Yes, I've been at it since I last posted....lots of stuff for C# & C++ ....but I'm sure it's out there.. might just look for the XOR concept ... I'll see how the weekend goes searching.. thanks again for your input.

Regards
Les
History teaches us that history doesn't teach us.
User avatar
GettinBetter
 
Posts: 43
Joined: Wed Jun 06, 2018 8:48 pm

Re: Reading PORTB to Terminal

Postby ric » Sun Jul 28, 2019 10:14 am

Note, there is a good reason why encoders commonly use gray code.
It is designed so that only one bit ever changes from one state to the next, so you can't get an invalid value right on the transition.
(e.g. if one bit changes at a fractionally different time to another bit)

See: https://en.wikipedia.org/wiki/Gray_code
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Previous

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 12 guests

cron