Getting the motor e...
 
Notifications
Clear all

Getting the motor encoders to work

57 Posts
5 Users
5 Likes
2,431 Views
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@zander 

The encoder link you gave uses a different setup (provides directional information).

The white line and pen tip are lining up after 10 rotations so my code is working (see image in previous post). It just takes less pulses then the 8000 it should require. It must be moving before it starts reading the encoder. I will figure it out.

Essentially I am using the same setup Bill used except I get more pulses from the encoder per rotation.
https://dronebotworkshop.com/robot-car-with-speed-sensors/

The pulse rate will depend on how fast the wheel is turning so I will get some figures on that to see how often the interrupt routine will need to read a pulse when the motor is going full speed.

This shows the circuit used in the encoder LM393 module used by Bill. Jaycar and Altronics do not sell that module. I recently bought some LM393's so I could build the same circuit but it would take up more room as the module uses smd components. I also note it is not wired as a schmitt trigger (no feedback resistor).

https://www.electroschematics.com/motor-speed-sensor-module-circuit/


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@byron 

I couldn't find my rpi pico so maybe I didn't buy one. I remember looking at them and thinking should I get one. Maybe I just got the esp32. I do have the RPi3 I don't know if that can do operations independent of the cpu.

 


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

Posted by: @robotbuilder

I do have the RPi3 I don't know if that can do operations independent of the cpu.

No, the rpi pico is an entirely different beast, it a microcontroller and not a Single Board Computer, and only the rpi pico has this PIO ability.

Quote:  a PIO is comparable to a tiny processor that runs code separately from the main Cortex-M0+. So what was previously accomplished by “bitbanging” protocols (and consuming CPU cycles), PIO does independently of the CPU.

On the RP2040, each PIO instance includes four state machines that can each run instructions stored in shared instruction memory. This memory can hold 32 instructions, and each state machine can utilize any of said instructions. Each state machine can also control any of the GPIO pins on the Pico.

Programming a PIO instance is easier than you might expect. Since it relies on special assembly instructions, you can write code in any editor (instead of a proprietary “Raspberry Pi Pico” IDE for example).

Which was probably what tempted you to consider buying one at one time.  They are only about $4 each so worthwhile have one or two to hand I would think.

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6963
 

@byron WOW, I did not know that about the PICO. That is very reminiscent of the multi-million dollar mainframes I used to work on. Do you have at hand the link to the manual that goes deeper than the above?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6963
 

@robotbuilder AH, now I see, I thought you were hand-assembling the ST and comparator. Like I said in the beginning, this is all new to me and works a lot differently than I imagined. Once I get my health under control and my workbench set up I will get started on my first robot so this conversation will get me started in the right direction.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
THRandell reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

Posted by: @zander

Do you have at hand the link to the manual that goes deeper than the above?

Here is a link to the Software Development Kit where you will find some info on the pio in one of the chapters.

https://www.raspberrypi.com/documentation/pico-sdk/index_doxygen.html#index

As you develop in C you should have the above doc to hand for all your pico developments 

Note: This group of libraries provides a thin and efficient C API / abstractions to access the RP2040 hardware without having to read and write hardware registers directly.

 

 

 

This post was modified 1 year ago by byron

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6963
 

@byron I do have that link, just too busy with other stuff since I get it and will be for the next 3 or 4 months then I will have time to look thru the doc. Thanks for reminding me.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

Posted by: @zander

@robotbuilder AH, now I see, I thought you were hand-assembling the ST and comparator.

What does ST stand for? I am hopeless remembering or figuring out acronyms.

 

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6963
 

@robotbuilder I can't spell Schmitt trigger so I thought ST would work. My bad.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@byron 

No, the rpi pico is an entirely different beast, it a microcontroller and not a Single Board Computer, and only the rpi pico has this PIO ability

Right. That would be a time consuming steep learning curve for me. I like to leverage on what I already know as I am really passed learning much new stuff.  These processors have certainly advanced since I learned Assembler on my TRS-80! My real interest now is higher level AI. The reality is a laptop gives you the best bang for bucks with all its support software for AI level programming. I was just going to use the Mega development board for the low level reflex code and simple motor/sensory programs all controlled by the laptop.

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@zander 

I am hand assembling the Schmitt Trigger.   I do not have the encoder module.

I noticed the module uses two 100n capacitors so maybe I will do the same.

The Schmitt trigger is a comparator ic with a feedback resistor.

 

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6963
 

@robotbuilder I am an old tube guy so I don't know much about IC's.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@zander 

I started with transistors,  much simpler to use then the old tubes 🙂

As my interest has been AI at the moment I have been finding links to explanations of how chatgpt works.

Just as when learning electronics I found one book would explain things that another book did not I find different utube explanations vary in how clearly they explain the large language models.

 


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

Posted by: @robotbuilder

I like to leverage on what I already know as I am really passed learning much new stuff

Me too! Definitely no ROS for me. 😎 

Posted by: @robotbuilder

I was just going to use the Mega development board for the low level reflex code and simple motor/sensory programs all controlled by the laptop.

That similar to what I had been playing with, an arduino uno for the low level on robot control (plus a rpi zero mainly for comms), with an rpi4 as the brains (which is not dissimilar in power to an old laptop) linked via wifi.

However the program on the brains, soon grows to be of a substantial size.  I program the brains in python making enabling the program to be broken down into modules (or many *.py files).  But looking at ROS I think it also breaks the whole into discrete modules that communicate between nodes and controller, or even node to node via a publish / subscribe mechanism not unlike the MQTT pub/sub.  At least that was how I understood it when I looked at this ROS stuff a few years ago.  How are you thinking of tackling the brains programming?  If you've started on it how large has your program grown?

For me its now time to start afresh and I've got a Teensy 4.1 board that I earmarked for the onboard controller, and probably the rpi4 can continue its command duties, perhaps assisted or augmented by a similar rpi4 doing service as a MQTT broker and database server for lookups etc but dedicated to Robot Control duties.

But following today newsletter from @dronebot-workshop maybe I will see what Bill and Chat-GPT comes up with.   Whats this new build bot going to be I wonder, an outside bot to wander the hills guided by those RTK boards Bill has (or had) in his junk box, or an indoor poodle bot to trot around serving tea and cucumber sandwiches. Is it going to be based on the new arduino giga?  (will the Chat be ready for it ).   Will Bill spill the beans, and give us a hint? 😍 

 

This post was modified 1 year ago by byron

   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 224
 

@robotbuilder

I was wondering, when you get the encoders under control are you planing to implement a PID controller to steer your robot?

 

Tom

To err is human.
To really foul up, use a computer.


   
ReplyQuote
Page 3 / 4