TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Tue Jul 11, 2017 12:08 pm

Hi Gert,
I'm using Gertbot to control a DC brushed motor with Quadrature Encoder. It is stated in the Gertbot manual (page 44) that "Just as with the stepper count the three bytes make up a 24 bit signed number in the range of –4194303 to +4194303." But a 24-bit signed number should be in the range of –8388607 and 8388607 right? I have read the value from the encoder and always get value between –8388607 and 8388607, so I'm not sure it's correct or not.

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Tue Jul 11, 2017 12:21 pm

Gert van Loo wrote:
I think I have enabled the encoder but I can't work out how to read them.
You must use the 'quad_read' command. See the example usage in the test_driver.py code.

Where could I download the file "test_driver.py"? I could not find it on Gertbot's website. Is there any C or C++ version of it? Thanks!

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Tue Jul 11, 2017 6:08 pm

TrinhTUHH wrote:
Gert van Loo wrote:
I think I have enabled the encoder but I can't work out how to read them.
You must use the 'quad_read' command. See the example usage in the test_driver.py code.

Where could I download the file "test_driver.py"? I could not find it on Gertbot's website. Is there any C or C++ version of it? Thanks!
The python test code test_driver.py is packed together with the python drivers: https://www.gertbot.com/updates.html
On that same web page you find the 2.6 C drivers which have support for the quadrature encoder. e.g. https://www.gertbot.com/gbdownload/rev2 ... rs_2.6.zip.
The C drivers also have example code in them: test_gb_drivers.c.
I just noticed that I have not uploaded the GUI source code for version 2.6. I will see I will see if I can do that soon as
that has working code for the quadrature encoders in C++. (But it will take a bit more effort for you to find and extract that.)

Post edit: latest BETA code uploaded: https://www.gertbot.com/gbdownload/src/ ... rc_2.8.zip
Beware this is the very latest GUI with support for ramping up and down the speed of the stepper motors. A feature in the Gertbot 2.8 code which has not been released yet as I have not yet written and tested the drivers. (The code on the Gertbot seems to work)

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Mon Jul 17, 2017 1:41 pm

What's exactly the position value?
The position value read from "quad_read" command is said to be in a range of –4194303 to +4194303, but I don't really understand what it is. For example, I'm using a gearbox DC brushed motor with 64 CPR encoder and the gear ratio is 50:1, meaning the resolution is 3200 CPR. As my understanding when I read from the quadrature encoder, the ouput value should be in the range of 0 to 3200 or (-1600 to 1600), but here it returns different values. Could you please explain this to me? Thank you in advance!

Another question is about "quad_goto()" command. I used this command with different duty_cycle values with the same position and I realized that the motor did run faster or slower according to the duty_cycle but it did not move to that same position. As specially when I set duty_cycle equal to 30 or lower, the motor runs like forever. This is very weird.

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Tue Jul 18, 2017 6:58 am

I'll give a longer answer later. I am travelling at the moment.
As my understanding when I read from the quadrature encoder, the ouput value should be in the range of 0 to 3200 or (-1600 to 1600)
No that is wrong. It gives 3200 per revolution. Thus after ten revolutions the counter is 32000. That is why the gertbot has a range of 24 bits!.

I can't explain why it does not work when running slow unless they are magnetic coders and it is not changing fast enough to register.

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Tue Jul 18, 2017 9:49 am

Hi Gert,
Thank you for your reply!
By the way, when I built the GUI on Raspberry Pi 3 I always encountered this error: "gertbot.h: error: 'usleep' is not declared in this scope ...". So I just added this line " #include <unistd.h> " to the file "gertbot.h" and then remake and it worked. I don't know whether other people get the same problem but it works for me. Hope it help!
I have tried the gertbot_GUI version 2.8 and played around with the quadrature mode. There are some weird things that I noticed:
- If I don't turn on the Min-on and Max-on, the motor does not move to the target position. Either it does not run at all or stops after very short time.
- When Min-on and Max-on are set, everything works fine if the duty cycle is 100.0. However, if I set duty cycle smaller than 100, say 80 or 50, then the motor still moves in the same direction but it does not stop at the target position. It even passes the maximum position that I set before. Same thing happened when I implemented my own program with commands quad_read, quad_limit, etc.

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Wed Jul 19, 2017 12:19 pm

Gert van Loo wrote:I'll give a longer answer later. I am travelling at the moment.
As my understanding when I read from the quadrature encoder, the ouput value should be in the range of 0 to 3200 or (-1600 to 1600)
No that is wrong. It gives 3200 per revolution. Thus after ten revolutions the counter is 32000. That is why the gertbot has a range of 24 bits!.

I can't explain why it does not work when running slow unless they are magnetic coders and it is not changing fast enough to register.
You're right. I'm using a motor with magnetic encoder and it's probably the reason. So do you have any suggestion when using Gertbot with a magnetic encoder?

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Wed Jul 19, 2017 6:40 pm

So do you have any suggestion when using Gertbot with a magnetic encoder?
There is no solution, at low speed you magnetic flux change will be slow.
To use a famous quote: "I can't change the laws of physics" ( https://youtu.be/nfZ12UGiisM?t=23)

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Wed Jul 19, 2017 6:50 pm

Ok so I should not use it with low speed, but it should work ok for normal speed, right? But the position values that I read from the encoder sometimes fluctuate even when the motor runs at normal speed and in the same direction.

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Wed Jul 19, 2017 7:01 pm

Do you get errors?
The Gertbot increments an error counter when it detects an illegal transition |(e.g. 00 to 11 is illegal)
If so, the most likely cause is that the code changes faster then the 1000 Hz max speed.

(And yes, I am back from my business trip).

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Wed Jul 19, 2017 7:30 pm

No I did not get any errors.
Gert van Loo wrote:Do you get errors?
If so, the most likely cause is that the code changes faster then the 1000 Hz max speed.
Is there anyway to fix this?
And do you know why if I call "quad_on" command but not use "quad_limit" after that, the motor doesn't move at all. The same happens to the GUI.

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Thu Jul 20, 2017 7:19 pm

Is there anyway to fix this?
Not until I have some idea what the error might be. I need to think on that a bit. (Actually, I need to think on that A LOT)
Can you give me some input about what fluctuations you see?
And do you know why if I call "quad_on" command but not use "quad_limit" after that, the motor doesn't move at all. The same happens to the GUI.
Not yet! I have been perusing the code but did not see an obvious error.

Unfortunately I don't have access to a motor with encoder at the moment as a lot of my equipment is in storage.
I'll see what I can dig out over the weekend and come back to you.

p.s. I did see an error in the GUI which I have fixed:

Code: Select all

  // Pick up other flags which might have been set previously
  // (seq is: quad-on, change max/min/slow, quad off, quad-on)
  mess[2] |= mtrptr->cb_quad_max_on ->isChecked() ? QUAD_TOP : 0x00;
  mess[2] |= mtrptr->cb_quad_min_on ->isChecked() ? QUAD_BOT : 0x00;
  mess[2] |= mtrptr->cb_quad_slow_on->isChecked() ? QUAD_GOSLOW : 0x00;

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Thu Jul 20, 2017 7:23 pm

Thank you in advance! Next week I would try with a optical encoder and see what happens. The board is not with me right now so I would send you photos of the fluctuation next week!

Brych2011
Posts: 3
Joined: Thu Jul 20, 2017 5:58 pm

Re: Gertbot

Thu Jul 20, 2017 8:22 pm

Hello Gert,
I have recently bought a Gertbot but it seems not to be working. Despite carefully following instructions of connecting DC motors, I can't control them. Rest of the board, though, seems to be OK - it communicates with GUI, I can use GPIO pins.
I thought it was caused by the version difference between board software (it came to me with revision 2.3 installed), and GUI/python drivers. However, after updating Gertbot to 2.6 it still doesn't work.
I am a newbie in electronics, so I might have made some stupid mistakes.
Thank you in advance for your help, and I apologize for my imperfect english,
Bogdan

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Fri Jul 21, 2017 5:52 am

What voltage are your motors?
The gertbot needs at least 8V.

Brych2011
Posts: 3
Joined: Thu Jul 20, 2017 5:58 pm

Re: Gertbot

Fri Jul 21, 2017 9:09 am

So that's the 'stupid mistake' I was talking about. I was trying to use 6v power supply, since it is my motors' maximum voltage.
Thank you for clarification!
May I ask, is there any way to use my motors with Gertbot?
Thanks for help,
Bogdan

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Fri Jul 21, 2017 4:59 pm

You could try series resistors. I use them for my stepper motors too.

What would also be possible is to use a higher voltage (8V) and then make sure you do not exceed a
certain mark space ratio (75%).
It is a bit more dangerous, but technically perfectly safe, (I know that sounds contrasting).
The reason why it is safe, is that the Gertbot duty cycle is done in hardware. So no matter
what happens in the SW it will NOT suddenly be stuck permanently high.
The reason why it is dangerous: you must make sure you do not accidentally program
a duty cycle above 75%. Your average power (heat produced) will be the same as for 6V.

Additionally you can reduce the current by using a high switch frequency as the motor will start behaving more
like an inductor (coil).

Brych2011
Posts: 3
Joined: Thu Jul 20, 2017 5:58 pm

Re: Gertbot

Sat Jul 22, 2017 6:44 pm

Everything works like a charm!
Thank you for making the board and all your support,
Bogdan

User avatar
Gert van Loo
Posts: 2407
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot

Sat Jul 22, 2017 8:02 pm

Brych2011 wrote:Everything works like a charm!
Thank you for making the board and all your support,
Bogdan
Thank you.
It is always nice to hear that things work.
Too often there is only silence after my answers.

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Mon Jul 24, 2017 12:07 pm

Is it true that we should not change the duty cycle while running the "quad_read" command?

TrinhTUHH
Posts: 11
Joined: Wed Jun 14, 2017 12:27 pm

Re: Gertbot

Mon Jul 24, 2017 3:52 pm

Gert van Loo wrote:
Is there anyway to fix this?
Not until I have some idea what the error might be. I need to think on that a bit. (Actually, I need to think on that A LOT)
Can you give me some input about what fluctuations you see?
And do you know why if I call "quad_on" command but not use "quad_limit" after that, the motor doesn't move at all. The same happens to the GUI.
Not yet! I have been perusing the code but did not see an obvious error.

Unfortunately I don't have access to a motor with encoder at the moment as a lot of my equipment is in storage.
I'll see what I can dig out over the weekend and come back to you.

p.s. I did see an error in the GUI which I have fixed:

Code: Select all

  // Pick up other flags which might have been set previously
  // (seq is: quad-on, change max/min/slow, quad off, quad-on)
  mess[2] |= mtrptr->cb_quad_max_on ->isChecked() ? QUAD_TOP : 0x00;
  mess[2] |= mtrptr->cb_quad_min_on ->isChecked() ? QUAD_BOT : 0x00;
  mess[2] |= mtrptr->cb_quad_slow_on->isChecked() ? QUAD_GOSLOW : 0x00;
When I implemented my own code, the same problem happened. If I call the quad_read without calling quad_limit before it then the motor does not run. Is there any problem with the driver files also?
By the way, I found the reason for all the problems which I mentioned in previous posts. It is I set the duty cycle too high so the motor runs too fast compare to the reading speed of the encoder. This can be checked by running the GUI and enter the quadrature mode, then run the motor and come back to quad mode and click read continuously. If the error is non-zero then the motor is running too fast (this is already mentioned in the Manual but without the new version of the GUI, I cannot check it). Thank you very much for the new version 2.8 and all of your support!

Return to “Gertboard classic”

Who is online

Users browsing this forum: No registered users and 3 guests