Тёмный
No video :(

External encoder Counter chip LS7366R 

Out of the BOTS
Подписаться 2,1 тыс.
Просмотров 15 тыс.
50% 1

Using a LS7366R counter chip to count a quadrature encoder for higher accuracy.

Опубликовано:

 

24 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 67   
@lentzintl
@lentzintl 2 года назад
Excellent! I was trying to figure out why you would want use the counter chip prior to buying everything for a project. Thanks!
@lentzintl
@lentzintl 2 года назад
Excellent! I was trying to figure out why you would want use the counter chip prior to buying everything
@mikegrundvig
@mikegrundvig 4 года назад
Very helpful! You saved me from wasting a lot of time going the wrong direction. Thanks!
@bobbob1730
@bobbob1730 6 лет назад
This is a really well made, informative video. Thanks for sharing!
@zumpitu
@zumpitu 5 лет назад
I think that the best solution will be to use an STM32 board, like a Nucleo that have the quadrature encoder integrated
@outofthebots3122
@outofthebots3122 5 лет назад
Yes I have now discovered that STM32 MCUs have hardware encoder counters on their timers so I use STM32 for projects that require a encoder counter.
@aakashdewangan7313
@aakashdewangan7313 Год назад
Thanks!
@capiberra4118
@capiberra4118 4 года назад
Interesting stuff. Thanks!
@aleXelaMec
@aleXelaMec 2 года назад
Thanks for sharing. But did you try to disable wifi first? Did you use interrupts as well?
@outofthebots3122
@outofthebots3122 2 года назад
WiFi running, that's the point to show encoder counting requires all the resources to not miss a tick
@aleXelaMec
@aleXelaMec 2 года назад
@@outofthebots3122 missed this. But if didnt, was this higher?
@outofthebots3122
@outofthebots3122 2 года назад
@@aleXelaMec it would be but your still missing the point that encoder counting takes up all your CPU resources so it means you can't do other things at the same time while counting a fast encoder. So if you want to be doing something and counting encoders at the same time then you need to use a hardware encoder counter rather than the CPU to count the encoder
@aleXelaMec
@aleXelaMec 2 года назад
@@outofthebots3122 hey, no, I got your point. At least since my issue is not prolong measurement. I need to count short pulses (around 300ms), but 6 chanels, 2 of each are fast. But thanks for the comment. Ill think about using external Dedicated counter.
@orhuk
@orhuk 5 лет назад
Based on the reference schematic in their datasheet, there are two capacitors near the crystal. Did you happen to work out what capacitor values to use?
@outofthebots3122
@outofthebots3122 5 лет назад
The capacitors need to match the crystal you use in order to make it resonant for a clocking signal. Instead of using a crystal oscillator I used the timer on the ESP32 to create the clocking signal as ESP32 can create clocking signal up to 40MHz.
@orhuk
@orhuk 5 лет назад
@@outofthebots3122 Care to share the schematics you used? I'm especially interested in how you wired up the clock from ESP32 to the LS7366R
@outofthebots3122
@outofthebots3122 5 лет назад
@@orhuk quote from datasheet ". Instead of a crystal the fCKi input may also be driven by an external clock.". I just set a timer on the ESP32 to create a high freq PWM with 50% duty and connected it to fCKi
@iainmalcolm1
@iainmalcolm1 6 лет назад
I'm using pigpio to do the counting, and running streaming video over wifi at the same time on a pi ZW. Although things appear to go wrong, it is actually just total cpu overload that is a problem. When I stop the streaming video it all catches up again and the counters are correct (or at least have only a very small error). What software are you using to count?
@outofthebots3122
@outofthebots3122 6 лет назад
I did write my own software to do the counting. What I found was the software was close to the external counter chip but it did miss some counts. The Quadrature encoders that use have 11 poles x 4 signals per pole x a 31:1 gear box so this is 1320 signals per rotate so if your rotating at 60RPM this 1320 signals per second. Quite often the motors can be spinning faster than 60RPM and usually I have at least 2 motors on any robot. Most processors with WiFi run the Wifi on a thread with high priority and when the processor is busy with maintaining the WiFi it will miss counts. You will notice this when you compare a software counter with the external counter or if you try to get a robot to drive a perfectly straight line. For my software counter code see my last video, at about 8mins you will see the code and at about 6mins a good explanation of how the code works ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-p4BCFhIuC88.html
@iainmalcolm1
@iainmalcolm1 6 лет назад
Not surprising really that a simple Python loop runs into trouble doing this. I use pigpio to count the pulses, so it's running in a real time process (i.e. high priority) and written in C I believe. I'm also running raspbian lite - so no gui and minimal system services. I found my first runs I had a rogue left over thread still runnig, once I rebooted I found I can stream video over wifi and use pigpio to count the pulses very accurately, There is a slight amount of jitter in the readings when streaming video over wifi, but the overall counts seem to be accurate.
@outofthebots3122
@outofthebots3122 6 лет назад
Without a doubt the C code of the pigpio library will be faster than the code from the other link. I started to use the ESP8266 and the ESP32 because they are a real time MCU rather than a micro computer running an OS. In the video above it is running on an ESP32 board so ti is a real time MCU without an OS and all code is compiled to machine code via an C interpreter. No matter how high priority the pigiop library is the OS is still in command and will always have higher priority over resources. At times my robot can have wheels turn as fast as 120RPM and I have a min of 2 wheels driving so this is in the order of 5280 pulses per second and because there is 2 encoders running at the same it it is possible that some of these signals can be at the same time. So signals can be under 0.1ms apart. I started to use a MCU because it is real time so can handle these super small time frames better but still found problems of missing signals and this is why I used the external counter chips and have 1 for each encoder running in parallel. It means signals don't get missed and it also means the over heads r removed from my master processor to allow it to do other stuff.
@m.a.sherif6878
@m.a.sherif6878 5 лет назад
hey would you be able to share the code that you wrote. I can't seem to understand how the spi.transfer function work. I checked the syntax but can't use it because I don't understand what buffer and val parameters are. would you be able to help on that as well. Thank you
@outofthebots3122
@outofthebots3122 5 лет назад
I would no longer have the code that I wrote for this video. What programming language are you using and what processor are you using??
@m.a.sherif6878
@m.a.sherif6878 5 лет назад
basically I am using Arduino nano to control the motor with an encoder (am-2816a) and an SPI (LS7366R). As the motor rotates the encoder reads the position sends it back to the Arduino through the SPI. I have gone through the research part and know how to do the wiring, but I am stuck with the Arduino program. there is an SPI library in the Arduino software that supports the SPI communication (SPI Pins), and there is a function that I want to use thats called SPI.transfer(). I am having troubles understanding how to use the function and how to receive and send data from and to the encoder. I have used a program that I found online and the output is always -1 even if the motor is at different speeds. I am guessing that there is something wrong with the program. check the links below to know what I have been looking at: arduino.stackexchange.com/questions/16348/how-do-you-use-spi-on-an-arduino Arduino program found online: github.com/werdroid/Arduino_LS7366R Arduino Nano www.farnell.com/datasheets/1682238.pdf encoder www.andymark.com/products/hall-effect-two-channel-encoder SPI lsicsi.com/datasheets/LS7366R.pdf Clock www.ctscorp.com/wp-content/uploads/MXO45.pdf @@outofthebots3122
@outofthebots3122
@outofthebots3122 5 лет назад
@@m.a.sherif6878 I don't use Ardunio myself so don't know the SPI library but the first link you posted seemed to me have all the info needed for using SPI. Also I have discovered that STM32 has builtin hardware encoders and there is an Ardunio port for the super common stm32f103c8t6 and it has an ardunio libiary for encoders counters see this thread www.stm32duino.com/viewtopic.php?f=18&t=4024&p=52829&hilit=encoders#p52829
@christiansrensen3810
@christiansrensen3810 5 лет назад
Enocders are hard for pro beginners..your vid here also stated..that many people that wants to try this gets hit by the wall accuracy...so my own test of encoders(gpio input) has also hit a wall. I can read stable 16 counts at 1000 Hertz pr Rpm...which is really not good enough... Now the chip you have is hard to get by(ls7366r) also the code for spi (a sample code) is also hard to get by....as many samples require the right set of parts.... So I think and hope for all on RPI and Arduino as probeginners that you will use a bit of time to make an in depth Tut vid. Every where on RU-vid and on forums you get small bits of the right way.. and for more people the making project it more important to know where you device is currently located then how fast it is going... In sense of robots/3d printers/conyouer belts/... So I wish for xmas, as you seam able to do this....and for all probeginners you will make an in depth project...easy to buy project... Maybe I am hoping for to much. But a man's gotta ask right... Btw thank for your vids. (Sry for my poor English).
@outofthebots3122
@outofthebots3122 5 лет назад
Yes good points. The LS7366 is not common found and the user has to write their own custom driver to use it. I have now found another option, the STM32 family of MCUs have hardware encoders on their timers. I am currently using a STM32F103C8t for a robot that I am building am are using the hardware encoders on it. The STM32F103C8t (known as the blue pill) is available everywhere for about $2 and has 4 hardware encoders on it see www.aliexpress.com/wholesale?catId=0&initiative_id=AS_20181217125901&SearchText=stm32f103c8t6. There is an ardunio port for it and there is already libraries for using the hardware timer encoders. If python is your preferred lanuage then there is the pyboard with the more powerful STM32F405RG MCU that runs micro-python see store.micropython.org/
@christiansrensen3810
@christiansrensen3810 5 лет назад
I have purchased the board. So now i Hope you will share some info on thatSTM32F103C8t . Will it handle highspeed as well? ... I have been looking a bit on the industrial encoders. And found that they are affortable for my project- By the way happy new year. I need to finish this project, an i am getting desperate. :-)
@outofthebots3122
@outofthebots3122 5 лет назад
@@christiansrensen3810 here is the reference manual for the stm32f103 www.st.com/content/ccc/resource/technical/document/reference_manual/59/b9/ba/7f/11/af/43/d5/CD00171190.pdf/files/CD00171190.pdf/jcr:content/translations/en.CD00171190.pdf you will find from page 329 is the info on the encoder counter. Basically it uses the timer counters to count the encoders. I program it in C but there is ardunio libraries to use the encoder counters as well. I used MX_cube to setup the timers as encoder counters then was just reading the timer_count register to get the current count.
@simonlaker2139
@simonlaker2139 3 года назад
Have you tried the teensy 4.0
@JonPaulKelly
@JonPaulKelly 4 года назад
Hello is there a link to your code for the software (without LS7366R) version of the code?
@outofthebots3122
@outofthebots3122 4 года назад
No the code I wrote was never saved
@Evgen-Evgen-Evgen
@Evgen-Evgen-Evgen 3 года назад
@@outofthebots3122 It seems like you don't want to share it
@nirajdalal7712
@nirajdalal7712 4 года назад
do we have any alternative to count encoder ticks ?
@outofthebots3122
@outofthebots3122 4 года назад
STM32 MCU have hardware encoder counters, this is what I use now
@enginulker3728
@enginulker3728 2 года назад
Hello Out of the BOTS. I'm going to do counter reading on stm32 using ls7366r, but I couldn't do it anyway. Can you help me ?
@outofthebots3122
@outofthebots3122 2 года назад
If you are using STM32 they have a hardware encoder counter on their timers
@enginulker3728
@enginulker3728 2 года назад
@@outofthebots3122 I know, but I want to read using an external encoder. How can I do this? can you help me?
@enginulker3728
@enginulker3728 2 года назад
@@outofthebots3122 Please, if you have the code for Stm32CubeIDE, can you share it? I need to finish this matter, it's urgent.
@outofthebots3122
@outofthebots3122 2 года назад
@@enginulker3728 No I won't have code
@enginulker3728
@enginulker3728 2 года назад
@@outofthebots3122 Okay, thank you for everything.
@PuskAxD
@PuskAxD 6 лет назад
Hi, nice job. How fast can this chip count? Would it be able to handle quadrature pulse at 2Mhz? I'm looking for something that could handle 4 encoders at 2Mhz, any suggestions? Thank you:)
@outofthebots3122
@outofthebots3122 6 лет назад
the LS7366R processing speed is set my an external clock signal. Running at 5v it can handle clock signals as fast at 40Mhz. It is recomended that the chip is clocked at 10x the speed of the encoder signals so it should handle signals up to 4Mhz. You will need a Ls7366R for each encoder and they can be chained together on the 1 SPI bus all with separate CS lines see page 14 of the data sheet www.lsicsi.com/pdfs/Data_Sheets/LS7366R.pdf
@PuskAxD
@PuskAxD 6 лет назад
Great, do you know perhaps where i could get a couple of these chips as soon as possible, EU zone?
@outofthebots3122
@outofthebots3122 6 лет назад
Google will find them for you. Mostly I have found US sellers
@PuskAxD
@PuskAxD 6 лет назад
Hey, I got the chip, its on a board, but should work the same: www.mikroe.com/counter-click Trying to make it work with 1 encoder. I got MISO,MOSI,SCK,CS connected to Raspberry PI3, and im using the bcm2835 driver for SPI. www.airspayce.com/mikem/bcm2835/group__spi.html Im using the datasheet for correct commands/registers, however the bytes read from chip are always all zeroes. Any help apreciated:)
@outofthebots3122
@outofthebots3122 6 лет назад
That little board is basically what I built the on a bread board as it was cheaper for me to do that. You will also need to set the enable pin to high before it will count and of course connect your power and gnd. There is a couple of register to write to for setup before reading the counter too.
@satipsrl5207
@satipsrl5207 Год назад
a question...i use this device on an arduino...does reading CNTR register influences the counting?Because on the data sheet productor writes (i understand this manner) to read back from OTR register...what is the right way ...?thank you
@outofthebots3122
@outofthebots3122 Год назад
Yes you can use this IC with any controller. Reading the CNTR register doesn't change the counting
Далее
How To Use A Rotary Encoder Without Software
29:41
Просмотров 16 тыс.
Quadrature Encoders
10:45
Просмотров 14 тыс.
Avaz Oxun - 10 yillik yubiley konsert dasturi 2023
2:52:33
OBLADAET - BARMAN
03:06
Просмотров 251 тыс.
Rotary Encoder (KY-040) Debounce Circuit Tutorial
15:03
Hacking a weird TV censoring device
20:59
Просмотров 3 млн
The Greenwich Meridian is in the wrong place
25:07
Просмотров 819 тыс.
HACKED!: Using an HDD Motor as a Rotary Encoder?!
8:21
Interfacing with Quadrature Encoders
9:00
Просмотров 16 тыс.
Turn any DC Motor into a Servo Motor
25:24
Просмотров 285 тыс.
How to use encoders (Optical, Hall Effect, Quadrature)
20:44
Absolute vs. Quadrature Encoders
6:10
Просмотров 23 тыс.