Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:16 23 Jul 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 : SERVO command problem....

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9603
Posted: 02:11am 17 Aug 2015
Copy link to clipboard 
Print this post

Hi folks.

MM+ b23.

SERVO 1,0.85 works fine, but I have the servo on 1B, and if I try to specify ONLY 1B, it rejects the command every single time - I HAVE to specify 1A as well, and that is no good, as I have something else on the pin for 1A.

Manual, page 60 says:

  Quote  
The SERVO function will take control of any specified outputs and when stopped the pins will be returned to a high impedance "not configured" state.


However, in order to specify servo on 1B, I have to specify 1A, so I guess this is the problem, yes?

IE: SERVO 1,1,0.85 also works, but it causes errors on pin 48.

I cannot specify a zero for 1A(hinting to MMBASIC that I don't want to use 1A), as it rejects it.

Am I doing something wrong, or do I need to move the device currently on 1A?

1A currently uses a piezo sounder which is driven via the PWM command, but when you issue a SERVO command, this sounder then "Farts", as the lowest number I can assign it is 1 - this is no good.

So, is there a way to use the likes of 1B, but WITHOUT touching the pin for 1A, which is also needed on PWM 1A elsewhere in the program.

Hopefully I am making SOME kind of sense.....
Smoke makes things work. When the smoke gets out, it stops!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10287
Posted: 02:37am 17 Aug 2015
Copy link to clipboard 
Print this post

  Quote  So, is there a way to use the likes of 1B, but WITHOUT touching the pin for 1A, which is also needed on PWM 1A elsewhere in the program.


No.

Unfortunately, the way PWM and Servo work is that they associate a timer (in this case timer2 with the output compare (OC) channels. There are only two timers (2 and 3) that can be used for this.

Geoff has coded 3 OC channels onto timer 2 (PWM 1A, 1B, 1C), and 2 onto timer 3 (PWM 2A, 2B).

Without changing the firmware the channels are fixed. All channels on the same timer will have the same frequency although the duty cycle can of course be changed.

It may be possible that a CFunction could decouple 1A from timer 2 and set it up to use timer 3 but it really is a bit of a hack.

Edited by matherp 2015-08-18
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9603
Posted: 02:58am 17 Aug 2015
Copy link to clipboard 
Print this post

I will just change the piezo to the other controller. Luckily, I am not using both controllers, so one can have the servo on it, and the other can have the piezo on it - sorted!

Thanks for the confirmation - I was thinking that was probably the situation.....
Smoke makes things work. When the smoke gets out, it stops!
 
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