Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:47 17 Sep 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MM+ bug in the SERVO command

Author Message
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 12:33am 18 Aug 2015
Copy link to clipboard 
Print this post

I have been experimenting with 4.7b23 and I am very much sure there is a bug in the SERVO command. Here is what happens.
With a servo with range 0.785...2.185, and central point at 1.485V:
First I have verified that the motor operates normally using a MX170 MM. For double security I have tested with two different servos of the same model (QZ509), and then with another servo of different model (QZ508).
The SERVO command behaves completely unpredictably, and from what I see, is only able to cover the voltages between 1.47 and 2.1. Voltages outside of this range result in no movement of the servo, or a constant buzzing.
The SERVO command on MX170 with the same parameters and same motors operates accurately.

There is also another, probably unrelated bug in the USB console. See the picture below. The start up message gets printed at random times, even if I am in the editor at the moment. The picture shows the terminal after about a minute without any activity from my side. This bug also doesn't seem to exist in the MX170 port.





http://rittle.org

--------------
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9643
Posted: 12:47am 18 Aug 2015
Copy link to clipboard 
Print this post

I have never seen that on the USB console, but I can simulate it with a lose main power connection - check there is nothing wrong with the power connections, or that there is nothing perhaps shorting MCLR to ground. This is exactly the message that comes up every time you pull MCLR low, or cycle power, which makes me wonder if you have a dicky power connection somewhere?

I will test the servo command, as I have one set up for this kind of thing, and I will post back.

EDIT: I can get full 180' control of my servo using the range 0.75 - 3.0
No buzzing or humming. I can manually select any position inbetween - no problems.

Are you sure you have your servo wired up right? Most of the ones on ebay or the like, don't come with wiring diagrams, so it is easy to get a wire in the wrong place... I guess you will have it right, cos you say you can make it work on a 170.

I am using one of those translucent blue eBay ones - SG90, but it is working fine on the MM+ beta 23 - for me - go figure..... Edited by Grogster 2015-08-19
Smoke makes things work. When the smoke gets out, it stops!
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 01:14am 18 Aug 2015
Copy link to clipboard 
Print this post

Yes, of course that's what I would have assumed too. But even with a 1k pull up resistor on the MCLR pin, the result is still the same. If I am the only one who is seeing this, probably it is another W10 effect.

As to the servos - another interesting thing about this bug is changing the CPU speed changes also the servo position in MM+
The servos are properly wired up (note I've got them running on MX170 without any problems) Edited by kiiid 2015-08-19
http://rittle.org

--------------
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9643
Posted: 01:26am 18 Aug 2015
Copy link to clipboard 
Print this post

Hmmmmmmmm - interesting.....

I have been playing with the servo command some more now, and note that it does not want to move at all, if you do small steps - this might be related to your initial report?

Example:

SERVO 1,1,0.7 - sets servo to one end [OK]
SERVO 1,1,0.8 - no movement.
SERVO 1,1,0.9 - no movement.
SERVO 1,1,1.0 - no movement.
SERVO 1,1,1.1 - no movement.
SERVO 1,1,1.2 - no movement.
SERVO 1,1,1.3 - no movement.
SERVO 1,1,1.4 - no movement.
SERVO 1,1,1.5 - no movement.

Now, issue SERVO 1,1,0.7 again, followed by SERVO 1,1,1.5, and I then get the movement. Perhaps there is something wrong here afterall?

EDIT: Yes, changing CPU speed changes servo position - pretty sure that should not be, but I might be wrong.
Edited by Grogster 2015-08-19
Smoke makes things work. When the smoke gets out, it stops!
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 01:38am 18 Aug 2015
Copy link to clipboard 
Print this post

Thanks for confirming it! I had started wondering how can something as simple as this cause me such problems
These servos are a big part in my project, so I guess I will have to wait a bit until Geoff release the updated version.Edited by kiiid 2015-08-19
http://rittle.org

--------------
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9643
Posted: 01:43am 18 Aug 2015
Copy link to clipboard 
Print this post

I will ask Geoff to check in with this thread. Not sure where on the planet he is at the moment, but I think he still has access to the net.

EDIT: Now on a 170, and notice that I can make the servo hum if I change from the default speed to CPU 30, so this is indeed an interesting one.

On the 170, I can't make it move small amounts either, only larger movements.
We'll wait and see what Geoff says.Edited by Grogster 2015-08-19
Smoke makes things work. When the smoke gets out, it stops!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3303
Posted: 02:30am 18 Aug 2015
Copy link to clipboard 
Print this post

Hi from Ireland!

The USB issue could be due to the control signals sent by the USB host. MMBasic uses a query from the host as the trigger to display the banner - this is how it knows that someone has started a terminal emulator on the host. Perhaps Win10 does these things differently. Another thing to investigate when I get back.

On PWM. The PWM frequency is NOT automatically readjusted when you change the CPU speed. So halving the CPU speed will halve the frequency of any open PWM channels. To avoid this close and reopen the channel.

I don't know that this is the issue that Kon is seeing. I will add the PWM function to the list of issues to be investigated. If all works out OK I should have a new beta out in early Sept.

Geoff
Geoff Graham - http://geoffg.net
 
jimbotron
Regular Member

Joined: 27/11/2013
Location: Australia
Posts: 50
Posted: 04:11am 18 Aug 2015
Copy link to clipboard 
Print this post

Are you powering the servo from the same supply as the Micromite. If so, try using a separate supply for the servo. I had similar problems and found that the servo was causing the voltage to dip when the motor started up.
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 05:29am 18 Aug 2015
Copy link to clipboard 
Print this post

That crossed my mind earlier today and I tried to separate the power supplies. Didn't help
http://rittle.org

--------------
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 04:31pm 18 Aug 2015
Copy link to clipboard 
Print this post

The SG90 servo supply is supposed to be powered from 6v. I'm using 5v and it's OK - also the pulse control signal itself is happy to be just 3.3v

Greg
 
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 06:41am 19 Aug 2015
Copy link to clipboard 
Print this post

Hi Geoff!
Thanks for the new version MM170 4.7B23. Since then I have no program loss during battery replacement. However, I have a little problem with the servo command.


SERVO 1,0.5,0.5,0.5 The Servos moves to the left end position.
.
. no movement from value 0.51 - 1.49 ms !!
.
SERVO 1,1.5,1.5,1.5 The Servos moves to the right end position.


The same program works with the same hardware and V4.6B2 or V4.7B8 without problems.


Thanks again for your fantastic work !
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3303
Posted: 08:19am 19 Aug 2015
Copy link to clipboard 
Print this post

Thanks PicFan, that code snipit will make it much easier to track down the bug.
Geoff Graham - http://geoffg.net
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 04:28am 04 Jan 2016
Copy link to clipboard 
Print this post

I have been using extensively the SERVO command in a design and should say 4.7b37 works quite well so far. There is only one little bug which should be very easy to fix, and it becomes apparent only after very long time of testing. The counter which is used in timer 2 or 3 should be cleared with every new SERVO command because otherwise some small glitches happen occasionally and the servo get bugged to a wrong position due to that.
Geoff, can you please add that to your TODO list for the next revision, so the servo operation can be perfect?
ThanksEdited by kiiid 2016-01-05
http://rittle.org

--------------
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3303
Posted: 02:32pm 07 Jan 2016
Copy link to clipboard 
Print this post

Hi Kon,

I have only just found this post.

It seems a bit strange that "some small glitches happen occasionally ". The timers are not complicated and the registers wrap around very frequently. I would have thought that any issues with them would show up immediately, not over a long time.

However, resetting the timer is extremely easy to implement so I have put it into the forthcoming V5.1. It will be interesting to see if it fixes your issue.

Geoff
Geoff Graham - http://geoffg.net
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 11:11pm 07 Jan 2016
Copy link to clipboard 
Print this post

Thanks Geoff,
As I said, the glitch is not obvious and may happen only under the right conditions. When updating the timer for a new PWM value, if the counter is not reset, a pulse with wrong length may be produced once, then depending on the exact moment when the servo is scanning, it might get wrong information and go to an invalid angle. It is difficult to reproduce it, but it happens.
http://rittle.org

--------------
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3303
Posted: 03:00am 08 Jan 2016
Copy link to clipboard 
Print this post

Sounds like an issue. I hope that resetting the timer works as it seems to me that the only sure solution would be to wait for a transition on the PWM output then make the change - and that would be complicated.
Geoff Graham - http://geoffg.net
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 11:00pm 09 Jan 2016
Copy link to clipboard 
Print this post

Thanks Geoff,
The same applies to the SERVO STOP command as well. I have noticed that on very rare occasions the servo moves to an invalid position after the command had been executed.
http://rittle.org

--------------
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025